fix(vscode-ide-companion): preserve model metadata on switch - #2591
Conversation
📋 Review SummaryThis PR fixes a state synchronization issue in the VSCode IDE Companion where the context-left indicator showed stale model context window sizes after switching models within the same chat tab. The fix ensures that 🔍 General Feedback
🎯 Specific Feedback🟢 Medium
🔵 Low
✅ Highlights
|
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
…dicator fix(vscode-ide-companion): preserve model metadata on switch
TLDR
Fix the VSCode IDE Companion issue where the context-left indicator kept showing the previous model context window size after switching models within the same chat tab.
This change makes model switch events reuse the full cached model metadata instead of emitting a minimal model object, so _meta.contextLimit is preserved and the indicator updates immediately for the newly selected model.
Screenshots / Video Demo
Dive Deeper
The root cause was in
QwenAgentManager.setModelFromUi().After a successful model switch, the extension proactively emitted
onModelChanged, but it used a synthetic object containing only the selected model id and a fallback name. That object dropped_meta.contextLimit, which the webview uses to derive the context window limit for the indicator. As a result, switching models in place could leave the indicator showing a stale total context size until a new chat tab reinitialized the full model state.This fix updates the switch path to:
baselineAvailableModelsModelInfowhen presentbaselineModelInfoA regression test was added to ensure
setModelFromUi()emits the selected model with_meta.contextLimitintact.Reviewer Test Plan
cd packages/vscode-ide-companionnpm test -- src/services/qwenSessionUpdateHandler.test.ts src/services/qwenAgentManager.test.tscd packages/vscode-ide-companionnpm run check-typesTesting Matrix
Local verification completed:
npm test -- src/services/qwenSessionUpdateHandler.test.ts src/services/qwenAgentManager.test.tsnpm run check-typesnpx eslint src/services/qwenAgentManager.ts src/services/qwenAgentManager.test.tsLinked issues / bugs
Resolves #2515