fix(vscode): force fresh ACP session on new-session action#2874
fix(vscode): force fresh ACP session on new-session action#2874yiliang114 wants to merge 2 commits intomainfrom
Conversation
Ensure explicit new-session actions bypass active ACP session reuse so the VS Code sidebar clears context correctly. Add regression coverage for the agent manager and webview new-session entry points.
Replace the runtime import of `isSupportedImageMimeType` from `@qwen-code/qwen-code-core` with a local `SUPPORTED_PASTED_IMAGE_MIME_TYPES` set in the vscode-ide-companion package. The webview is bundled for a browser environment where Node.js-only core modules are unavailable, so keeping the MIME list local avoids esbuild failures during development. Added tests to verify the local list stays aligned with core and that the webview bundle does not contain core runtime imports.
📋 Review SummaryThis PR addresses issue #2847 by fixing a bug where clicking the "+" (new session) button in the VSCode sidebar silently reused the existing ACP session instead of creating a fresh one. The fix introduces a 🔍 General Feedback
🎯 Specific Feedback🟡 High
🟢 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. |
Summary
createNewSession()silently reused the existing ACP session when one was already active, so clicking the "+" (new session) button in the sidebar had no effect — context, model info, and usage stats were never reset.forceNewoption toAgentSessionOptionsand pass{ forceNew: true }from all explicit new-session call sites (SessionMessageHandler,WebViewProvider). The implicit bootstrap path continues to reuse existing sessions as before.isSupportedImageMimeTypefrom@qwen-code/qwen-code-coreinimageSupport.ts— the webview is bundled for a browser environment where Node.js-only core modules cause esbuild failures during development. Replaced with a localSUPPORTED_PASTED_IMAGE_MIME_TYPESset, with a test that pins it to the core-supported list.Files changed
qwenAgentManager.tsforceNewoption, bypass session reuse when setSessionMessageHandler.ts{ forceNew: true }for explicit new-session actionsWebViewProvider.ts{ forceNew: true }for sidebar new-session buttonimageSupport.tsforceNewbehavior and bundle safetyTest plan
qwenAgentManager.test.ts— verifiesforceNew: truecreates a fresh session even when one existsSessionMessageHandler.test.ts— verifies new-session webview message passesforceNewWebViewProvider.test.ts— verifies sidebar action passesforceNewimageSupport.test.ts— verifies local MIME set stays aligned with coreimageSupport.bundle.test.ts— verifies webview bundle has no core runtime importsCloses #2847