Skip to content

feat(web): load model rows from /api.json#1496

Open
Hona wants to merge 2 commits intodevfrom
web-client-render-api-json
Open

feat(web): load model rows from /api.json#1496
Hona wants to merge 2 commits intodevfrom
web-client-render-api-json

Conversation

@Hona
Copy link
Copy Markdown
Member

@Hona Hona commented Apr 20, 2026

Summary

  • replace the giant server-rendered table body with a small shell and render model rows client-side from /api.json
  • stop embedding provider logos into the initial HTML, use /logos/{provider}.svg images instead, and show a loading/error row while data loads
  • keep the existing table UI and interactions while cutting the initial HTML payload from about 17.3 MB to about 7.7 KB

Testing

  • bun run build

Shrink the initial HTML payload by keeping the table shell server-rendered and filling rows client-side. This preserves the current UI while removing the giant SSR table from the document.
Copilot AI review requested due to automatic review settings April 20, 2026 07:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Moves the model table from server-rendered HTML to client-side rendering backed by a /api.json endpoint, substantially reducing initial HTML payload while preserving the existing table UX (search/sort/copy).

Changes:

  • Add /api.json route to serve generated provider/model data with caching.
  • Update SSR to render only the table shell plus a loading row, letting the client populate rows.
  • Implement client-side fetch/render pipeline (including logo <img> usage) and keep existing interactions working.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/web/src/server.ts Adds /api.json route to serve provider/model data with cache headers.
packages/web/src/render.tsx Removes server-rendered table rows; renders a small <tbody> placeholder with loading state.
packages/web/src/index.ts Fetches /api.json, renders rows client-side, and preserves sorting/search/copy behaviors.
packages/web/src/index.css Styles new provider logo <img> usage and loading/error rows.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +176 to +179
<tbody id="table-body">
<tr class="loading-row">
<td colspan={25}>Loading models...</td>
</tr>
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

colspan is hard-coded to 25 here; the same count is also duplicated in the client code for loading/error rows. To reduce the chance of future mismatches when table columns change, consider deriving the colspan from the number of <th> elements (or sharing a single constant used by both render and client code).

Copilot uses AI. Check for mistakes.
Comment thread packages/web/src/index.ts
Comment on lines +44 to +49
const COLUMN_COUNT = 25;
const modal = document.getElementById("modal") as HTMLDialogElement;
const modalClose = document.getElementById("close")!;
const help = document.getElementById("help")!;
const search = document.getElementById("search")! as HTMLInputElement;
const tableBody = document.getElementById("table-body")! as HTMLTableSectionElement;
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The column count is hard-coded here and needs to stay in sync with the rendered table header and the server-rendered loading row’s colspan. Consider deriving this dynamically from the DOM (eg, document.querySelectorAll('table thead th').length) to avoid future drift when columns are added/removed.

Suggested change
const COLUMN_COUNT = 25;
const modal = document.getElementById("modal") as HTMLDialogElement;
const modalClose = document.getElementById("close")!;
const help = document.getElementById("help")!;
const search = document.getElementById("search")! as HTMLInputElement;
const tableBody = document.getElementById("table-body")! as HTMLTableSectionElement;
const tableBody = document.getElementById("table-body")! as HTMLTableSectionElement;
const COLUMN_COUNT = tableBody.closest("table")?.querySelectorAll("thead th").length ?? 0;
const modal = document.getElementById("modal") as HTMLDialogElement;
const modalClose = document.getElementById("close")!;
const help = document.getElementById("help")!;
const search = document.getElementById("search")! as HTMLInputElement;

Copilot uses AI. Check for mistakes.
Normalize built and served logo SVGs so currentColor resolves to the themed gray used before provider logos moved to external images.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants