-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat: optimize router model fetching with single-provider filtering #8956
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
Conversation
- Simplify backend to use single provider filter instead of array - Use existing isDynamicProvider from @roo-code/types instead of duplicating - Update frontend to request only the needed provider - Gate router model fetches entirely for static providers - Remove unnecessary debug logging - Update tests to reflect new behavior This combines and improves upon PRs #8916 and #8917 by: 1. Using a simpler single-provider API (provider: string instead of providers: string[]) 2. Leveraging existing type definitions from packages/types 3. Eliminating race conditions through simpler request/response matching 4. Reducing payload sizes and network usage Closes #8916 Closes #8917
Review SummaryI've reviewed the latest changes to this PR. The critical issue from the previous review has been resolved. Issues Found
StatusAll issues have been addressed. The PR is ready for merge. |
| const msgProvider = message?.values?.provider as string | undefined | ||
|
|
||
| // Verify response matches request | ||
| if (provider !== msgProvider) { | ||
| // Not our response; ignore and wait for the matching one | ||
| return | ||
| } |
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.
Critical bug: The backend never includes the provider in the response values, so msgProvider will always be undefined. When a provider filter is used (e.g., provider="roo"), the check provider !== msgProvider evaluates to "roo" !== undefined, which is always true, causing the response to be ignored indefinitely. The promise will timeout after 10 seconds, breaking router model fetching for all dynamic providers. The backend needs to include the provider in the response: provider.postMessageToWebview({ type: "routerModels", routerModels, values: { provider: requestedProvider } })
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.
Cannot approve due to critical issue found. The response matching bug must be fixed before this PR can be merged.
The frontend needs the provider in message.values.provider to match requests with responses. Without this, all filtered requests would timeout after 10 seconds.
* Correct tool use suggestion to improve model adherence to suggestion (RooCodeInc#8315) * Correct tool use suggestion to improve model adherence to suggestion * tweak * removing user hint when refreshing models (RooCodeInc#7710) * feat(zgsm): add quota info display and periodic updates * Show the Roo provider on the welcome screen (RooCodeInc#8317) * wip: Website Improvements (RooCodeInc#8303) Co-authored-by: Matt Rubens <[email protected]> * refactor: remove pr-reviewer mode (RooCodeInc#8222) * feat: add animated quota display with staggered transitions * Merge remote-tracking branch 'upstream/main' into roo-to-main * web: More website copy tweaks (RooCodeInc#8326) Co-authored-by: Matt Rubens <[email protected]> * fix: remove <thinking> tags from prompts for cleaner output and fewer tokens (RooCodeInc#8319) Co-authored-by: Roo Code <[email protected]> Co-authored-by: Hannes Rudolph <[email protected]> * Upgrade Supernova (RooCodeInc#8330) * chore: add changeset for v3.28.9 (RooCodeInc#8336) * Changeset ver
Problem
The existing PRs #8916 and #8917 implemented provider filtering but used an array-based approach. Per mrubens' feedback, this should be simplified to use a single provider filter instead.
Solution
This PR combines and improves upon #8916 and #8917 by:
provider: stringinstead ofproviders: string[]isDynamicProviderfrom@roo-code/typesinstead of duplicating provider listsChanges
Backend (
src/core/webview/webviewMessageHandler.ts)providersarray to singleproviderstring filterproviderFilterinstead ofrequestedSetFrontend (
webview-ui/src/components/ui/hooks/)provideroptionisDynamicProviderfrom types to determine when to fetchconsole.debugloggingTests
Impact
Before:
After:
Addresses mrubens' Comments
✅ PR #8916: "Is there a reason for this filter to be an array?" - Now uses single provider
✅ PR #8916: "...make a function that only fetches one...Or just do it all in one PR" - Combined in one PR with simplified API
✅ PR #8917: "isn't this already in the types somewhere?" - Now uses
isDynamicProviderfrom types✅ PR #8917: "Can we remove this debug logging?" - All debug logging removed
Testing
Closes #8916
Closes #8917
Important
Optimize router model fetching by switching to single-provider filtering, improving performance and simplifying code.
providers: string[]toprovider: stringinwebviewMessageHandler.tsfor filtering router models.providerFilterinstead ofrequestedSet.useRouterModelsinuseRouterModels.tsnow accepts a singleproviderand anenabledflag.useSelectedModelinuseSelectedModel.tsupdated to useisDynamicProviderand gate fetches for static providers.webviewMessageHandler.routerModels.spec.tsto verify single-provider filtering.useSelectedModel.spec.tsto reflect changes in loading and error states for static providers.This description was created by
for 9dac237. You can customize this summary. It will automatically update as commits are pushed.