Skip to content

feat: say where each upstream's model list stands, and let the page ask for missing ones - #47

Merged
fylorn merged 2 commits into
mainfrom
feat/model-status
Sep 19, 2026
Merged

fylorn merged 2 commits into
mainfrom
feat/model-status

Conversation

@fylorn

@fylorn fylorn commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Summary

The upstream page shows "not fetched" for upstreams whose models core had already fetched, failed to fetch, or cannot fetch at all:

  • The overview only carried model_source (discovered / manual / none), so "not asked yet", "key refused" and "offers no list" were indistinguishable.
  • Background fetches (at startup, daily, after an address or key change) finished without an event, so the page kept whatever it read at startup.

This adds what the page needs to show the real state and to fetch missing lists without the user asking.

  • Status on the views. ProviderView gains model_status (pending / listed / no_list / failed), model_fetching, model_checked_at_ms and model_error; ProviderModelsView gains status and fetching. Status and source are separate on purpose: a failed fetch can still be backed by a manual list.
  • models_changed event when a fetch starts and when its answer is recorded (after the catalog is republished, so a reload sees the new count).
  • POST /models/refresh for page visits: asks the enabled upstreams with no answer, a failed answer or an expired one, in the background, and returns the names it started on. It skips upstreams asked in the last minute, upstreams already being asked, and upstreams that offer no list until that answer expires.
  • In-flight asks are counted per upstream, so a background round and a user refresh do not clear each other's state; the background round skips upstreams already being asked. An ask dropped because the config changed meanwhile releases its count without touching the answer.

Test plan

  • Unit tests: which upstreams a page visit asks; two asks at once; an ask dropped by a config change; a failure backed by a manual list.
  • Control tests: the page refresh reports two models_changed and ends listed with the right count, then asks nothing on a second visit; a refused key ends failed with the reason.
  • cargo fmt, cargo clippy --workspace --all-targets -D warnings, cargo test --workspace, scripts/smoke.sh (51 pass, 0 fail; covers the new endpoint and fields).

🤖 Generated with Claude Code

…sk for missing ones

The overview only said where a list came from (discovered, manual, none), so
an upstream not asked yet, one whose key was refused and one that offers no
list all read as "not fetched". And background fetches finished without
telling anyone, so the upstream page kept what it read at startup until
something else made it reload.

- ProviderView and ProviderModelsView carry the fetch status (pending /
  listed / no_list / failed), whether a fetch is in flight, when the list was
  last checked and why it failed.
- Every fetch reports models_changed when it starts and when its answer is
  recorded.
- POST /models/refresh asks, in the background, the enabled upstreams with
  no answer, a failed one, or an out-of-date one. It skips upstreams asked in
  the last minute, upstreams being asked, and upstreams that offer no list
  until that answer expires, and returns the names it started on.
- In-flight asks are counted per upstream, so a background round and a user
  refresh at the same time do not clear each other's state, and the
  background round skips upstreams already being asked.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Thanks for the PR. One thing before review: this targets main, and it should target dev.

main is a release-only line — branch-protected, linear history, and every commit on it is a tagged release snapshot. Routine work lands on dev and reaches main with the next release. GitHub pre-filled main here because it is the default branch, so this is our defaults being unhelpful rather than anything you did wrong.

No need to close and reopen: click Edit next to the PR title and change the base branch to dev. The commits and the discussion carry over.

See CONTRIBUTING.md and CONTRIBUTING.md for the branch contract.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@fylorn
fylorn merged commit afee659 into main Sep 19, 2026
1 check passed
@fylorn
fylorn deleted the feat/model-status branch September 19, 2026 11:03
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