-
Notifications
You must be signed in to change notification settings - Fork 25
fix: heal llm-router provider visibility and stale config UI states #808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
20b0fe9
fix(llm-router): rediscover all unavailable providers, guard routing,…
anthonyiscoding ab26d08
fix(llm-router): register console UI first and stop embedding stale u…
anthonyiscoding f057c2d
fix(console-ui): retry failed asset-trigger registrations with backoff
anthonyiscoding 4fb713a
fix(console): gate model picker on llm-router and recover without pag…
anthonyiscoding b8aad43
fix(harness): ride out router startup races and heal outage-born sess…
anthonyiscoding d4c1a76
fix(ci): rustfmt cleanups, eval compile against Option strategy, lock…
anthonyiscoding f278e25
test: cover the invalid-state fixes
anthonyiscoding d392f5d
fix: address CodeRabbit review findings
anthonyiscoding 48a911d
fix(ci): regenerate eval wire-schema goldens against current harness …
anthonyiscoding File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { | ||
| isLlmRouterAvailable, | ||
| LLM_ROUTER_WATCH_FN, | ||
| LLM_ROUTER_WORKER_NAME, | ||
| } from './use-llm-router-status' | ||
|
|
||
| describe('llm-router presence probe wiring', () => { | ||
| it('probes the llm-router worker with its own watch handler id', () => { | ||
| // The model picker's router::* reads gate on THIS worker — gating on the | ||
| // harness blanked the picker whenever the harness was slow or absent. | ||
| expect(LLM_ROUTER_WORKER_NAME).toBe('llm-router') | ||
| // Must be unique per presence probe so the browser-local `worker` trigger | ||
| // handlers never collide (shell uses console::shell-watch). | ||
| expect(LLM_ROUTER_WATCH_FN).toBe('console::llm-router-watch') | ||
| }) | ||
|
|
||
| it('gates on both presence and the initial probe settling', () => { | ||
| expect(isLlmRouterAvailable({ present: true, loading: false })).toBe(true) | ||
| expect(isLlmRouterAvailable({ present: true, loading: true })).toBe(false) | ||
| expect(isLlmRouterAvailable({ present: false, loading: false })).toBe(false) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { | ||
| isWorkerPresent, | ||
| useWorkerPresence, | ||
| type WorkerPresence, | ||
| } from './use-worker-presence' | ||
|
|
||
| /** | ||
| * Presence probe for the `llm-router` worker. The router owns every | ||
| * `router::*` RPC the model picker reads (`provider::list`, `models::list`) | ||
| * and the change triggers it subscribes to, so provider/model UI gates on | ||
| * THIS worker's presence — gating on the harness starved the picker whenever | ||
| * the harness was slow or absent while the router was healthy. Thin wrapper | ||
| * over the generic worker-presence probe. | ||
| */ | ||
|
|
||
| /** Engine worker name for the llm-router worker. */ | ||
| export const LLM_ROUTER_WORKER_NAME = 'llm-router' | ||
| /** Base id for the browser-local handler bound to the `worker` trigger. */ | ||
| export const LLM_ROUTER_WATCH_FN = 'console::llm-router-watch' | ||
|
|
||
| export type LlmRouterStatus = WorkerPresence | ||
|
|
||
| /** | ||
| * @param enabled - only run against the real backend; pass `false` for the | ||
| * mock/Storybook backend (treats the router as present so the picker shows | ||
| * in isolation). | ||
| */ | ||
| export function useLlmRouterStatus(enabled: boolean): LlmRouterStatus { | ||
| return useWorkerPresence({ | ||
| workerName: LLM_ROUTER_WORKER_NAME, | ||
| watchFnId: LLM_ROUTER_WATCH_FN, | ||
| enabled, | ||
| }) | ||
| } | ||
|
|
||
| /** | ||
| * Whether the router's `router::*` functions are registered and safe to | ||
| * trigger. False during the initial presence probe and while the router is | ||
| * absent. | ||
| */ | ||
| export function isLlmRouterAvailable(status: LlmRouterStatus): boolean { | ||
| return isWorkerPresent(status) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useWorkerPresenceonly performs the workers-list read at mount and then relies on lifecycle events. If llm-router is absent for that first probe and is added while the browser socket is disconnected, the add event is lost andpresentremains false indefinitely.useModelPickerSourcecannot repair this case because its reconnect listener is only installed whenrouterAvailableis already true. Please make this presence probe reconnect-aware so an absent-to-present transition cannot require a page reload.