fix: Gate Roo router model fetches to reduce webview memory usage #8911
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.
Problem
Users reported increased webview memory usage starting in v3.29.0, causing crashes. Investigation identified that router model fetches were triggering excessive memory allocation and reconciliation in the webview.
Root Causes Identified
Solution
Implemented a surgical, focused fix that gates Roo Code Cloud router model traffic:
Changes Made
Gate auth-driven Roo refresh (ExtensionStateContext.tsx)
requestRooModelswhen auth transitions to true AND current provider === "roo"Provider-filtered router model fetches (useSelectedModel.ts)
DYNAMIC_ROUTER_PROVIDERSset to identify which providers need router modelsuseRouterModelsfor static providers (anthropic, openai-native, etc.)providers: [selectedProvider]to fetch only needed modelsBackend provider filter support (webviewMessageHandler.ts)
message.values.providersfilter when presentObservability (useRouterModels.ts)
Test Coverage
requestRooModelswhen provider === "roo"Impact
Before:
After:
Safety
Files Changed
webview-ui/src/context/ExtensionStateContext.tsxwebview-ui/src/components/ui/hooks/useSelectedModel.tswebview-ui/src/components/ui/hooks/useRouterModels.tssrc/core/webview/webviewMessageHandler.tswebview-ui/src/context/__tests__/ExtensionStateContext.roo-auth-gate.spec.tsx(new)src/core/webview/__tests__/webviewMessageHandler.routerModels.spec.ts(new)webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts(updated)Manual Testing
requestRooModelson auth changesrouterModelspayload contains only "roo" keyImportant
Optimizes Roo provider model fetches by gating requests to reduce memory usage, with tests added for new behavior.
ExtensionStateContext.tsxto only triggerrequestRooModelswhen provider is "roo".useSelectedModel.tsto only fetch models for dynamic providers.webviewMessageHandler.tsto honormessage.values.providersfilter for router model fetches.ExtensionStateContext.roo-auth-gate.spec.tsxto test auth-driven Roo model requests.webviewMessageHandler.routerModels.spec.tsto test provider filtering in model fetches.useSelectedModel.spec.tsfor static provider gating behavior.useRouterModels.tsfor request/response tracking.This description was created by
for 66e3f28. You can customize this summary. It will automatically update as commits are pushed.