feat(vscode-companion): enable Plan Mode toggle and approval UI#2551
Conversation
📋 Review SummaryThis PR enables Plan Mode in the VSCode Companion extension, achieving feature parity with the CLI. The implementation includes four key changes: updating the approval mode cycle, adding Tab key shortcut for mode cycling, fixing a bug where cancelling 🔍 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. |
|
Addressed one follow-up regression in the When the user selects “No, keep planning”, the session should stay in Plan Mode, and the corresponding |
tanzhenxin
left a comment
There was a problem hiding this comment.
The Plan Mode toggle and approval UI is a fantastic addition to the VS Code experience. Really thoughtful UX work here. Approving — go ahead and merge when you're happy with it! 🚀
- Add Plan Mode to the approval mode cycle (plan → default → auto-edit → yolo → plan) - Add Tab key shortcut to cycle approval modes in the input field - Fix cancel handling for exit_plan_mode: reject plan without aborting agent session - Add plan approval UI in PermissionDrawer with markdown content rendering Closes #1985 Made-with: Cursor
cc90772 to
24a6739
Compare
wenshao
left a comment
There was a problem hiding this comment.
No issues found. LGTM! ✅ — gpt-5.4 via Qwen Code /review
wenshao
left a comment
There was a problem hiding this comment.
Pulled to a worktree and ran unit-level (L1) + real-VSCode Extension Host (L2) verification. Also noting that @tanzhenxin already signed off on this PR on 2026-04-16 (fantastic addition... go ahead and merge when you're happy with it! 🚀); that APPROVED was auto-dismissed on the 2026-04-18 merge-conflict resolution push, not because the substance changed.
L1 — unit tests (vitest)
vitest run across the vscode-ide-companion package:
- 30 files / 193 tests pass, 1 skipped, 0 failed
- Specifically covers the regression the PR fixes:
WebViewProvider.test.ts > marks rejected switch_mode permission requests as failed without cancelling the session— validates that rejectingexit_plan_modemarks the permission request as failed while keeping the agent session alive (the exact bug the PR body calls out)
L2 — real VSCode Extension Host (xvfb + @vscode/test-electron)
Downloaded VSCode 1.116.0, launched it under xvfb-run via @vscode/test-electron, loaded this PR as a development extension, and ran Mocha tests inside the extension host. Both pass:
qwen-code-vscode-ide-companion (PR #2551 — Plan Mode)
✔ extension is present, activates cleanly, and exposes contributed commands
✔ acpTypes NEXT_APPROVAL_MODE cycles plan → default → auto-edit → yolo → plan
2 passing (265ms)
Exercised in a real Electron runtime:
- Extension activation — no uncaught exceptions during startup; extension host exited cleanly (code 0)
- All 4
contributes.commandsentries registered against the realvscode.commandsAPI:qwen-code.openChat,qwen-code.focusChat,qwen-code.newConversation,qwen-code.showLogs NEXT_APPROVAL_MODEinacpTypes.tshas the fullplan → default → auto-edit → yolo → plancycle — the centrepiece of this PR (previouslyyolo → default, skippingplan)
Gaps L2 doesn't cover
- Tab-key keypress routing into the mode cycle — lives inside the webview's React input field, needs Playwright/RTL-in-webview to assert directly
PermissionDrawerplan markdown rendering — visual, same constraint
That surface is covered by @tanzhenxin's 2026-04-16 hands-on approval (dismissed only because of the subsequent merge-conflict resolution push).
CI
13/13 green.
LGTM.
…LM#2551) * feat(vscode-companion): enable Plan Mode toggle and approval UI - Add Plan Mode to the approval mode cycle (plan → default → auto-edit → yolo → plan) - Add Tab key shortcut to cycle approval modes in the input field - Fix cancel handling for exit_plan_mode: reject plan without aborting agent session - Add plan approval UI in PermissionDrawer with markdown content rendering Closes QwenLM#1985 Made-with: Cursor * fix(vscode-ide-companion/webview): finalize rejected plan prompts
TLDR
Enable Plan Mode in the VSCode Companion extension, achieving feature parity with the CLI:
plan → default → auto-edit → yolo → plan)exit_plan_modeincorrectly aborted the agent sessionScreenshots / Video Demo
N/A — targeted local verification has been completed; broader manual verification is still recommended.
Dive Deeper
1.
acpTypes.ts— Mode cycle mappingUpdated
NEXT_APPROVAL_MODEfromdefault → auto-edit → yolo → default(skipping plan) to the fullplan → default → auto-edit → yolo → plancycle so users can enter Plan Mode via the UI toggle button.2.
App.tsx— Tab key shortcutAdded
handleInputKeyDownhandler that cycles approval modes when Tab is pressed while the input field is focused and the completion menu is closed, aligning with the CLI's Shift+Tab behavior.3.
WebViewProvider.ts— Cancel handling fixWhen the
exit_plan_modetool presents the plan approval prompt and the user selects "No, keep planning", acanceloptionId is sent. Previously, all cancel responses triggeredcancelCurrentPrompt()+streamEnd, terminating the agent session. However, forswitch_modekind tool calls (i.e.exit_plan_mode), cancel means "reject the plan and stay in plan mode" — the agent should keep running. Added anisSwitchModeguard to prevent incorrectly aborting the agent.4.
PermissionDrawer.tsx— Plan approval UIswitch_modekind tool callstoolCall.contentand renders it viaMarkdownRenderermax-h-[60vh]to ensure option buttons remain visibleReviewer Test Plan
exit_plan_mode, verify the PermissionDrawer shows:Testing Matrix
Linked issues / bugs
Closes #1985