Skip to content

The model listing answers from a cache and refreshes behind it - #342

Merged
mattshax merged 1 commit into
mainfrom
models-swr
Sep 15, 2026
Merged

mattshax merged 1 commit into
mainfrom
models-swr

Conversation

@mattshax

Copy link
Copy Markdown
Member

Every load of the model list fetched the gateway catalog and pinged each provider family (about a second on dev, several seconds where the gateway and providers are further away and each user's credential probes on its own), and the client asked three times per mount.

Server: the computed listing is cached per viewer and credential (the listing is shaped by the viewer, since shared providers are labeled with their owner). A load inside the 60 s fresh window is answered from cache; an older one is answered from cache and refreshed in the background (deduplicated), so the next load is current; only the first load per credential waits. ?refresh=1 drops the probes and recomputes before answering, and the key test in Settings clears every listing. The last-call-failed decoration is applied after the cache so it stays live.

Client: one deduplicated request (fetchModels in api.ts) serves the picker, the banner, the credential notice, and the fleet page, with a 15 s reuse. Freshness without a reload: refetch when the tab becomes visible and every five minutes while visible; the picker is remounted only when the set of marked models changes, never mid-reply.

Measured on dev: first load 1.2 s, next three under 10 ms, forced refresh 0.4 s. Tests cover cached loads, refresh seeing a changed catalog, and the live decoration. 187 server and 12 web tests pass.

Every load of the model list fetched the gateway catalog and pinged
each provider family, about a second here and several on a deployment
whose gateway and providers are further away, and the client asked
three times per mount. The computed listing is now kept per viewer and
credential: a load inside the fresh window is answered from it, an
older one is answered from it too and refreshed in the background so
the next load is current, and only the first load per credential waits.
?refresh=1 is the user saying "look again"; it drops the probes and
recomputes before answering, and a key test in Settings clears every
listing. A model whose last call failed is decorated after the cache,
so that mark stays live.

On the client one request serves the picker, the banner, the
credential notice, and the fleet page, with a fifteen-second reuse so a
remount does not refetch. Status stays fresh without a reload: the list
is asked again when the tab comes back into view and every five
minutes while it stays visible, and the picker is remounted only when
the set of marked models actually changes, since a remount mid-reply
would drop the visible stream.

Measured on the dev server: first load 1.2 s, the next three under ten
milliseconds, a forced refresh 0.4 s.
@mattshax
mattshax merged commit d35cb56 into main Sep 15, 2026
2 checks passed
@mattshax
mattshax deleted the models-swr branch September 15, 2026 19:42
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.

1 participant