feat(vscode-ide-companion): support local clear slash commands#3111
feat(vscode-ide-companion): support local clear slash commands#3111yiliang114 wants to merge 1 commit intofollowup/2874-review-suggestionsfrom
Conversation
📋 Review SummaryThis PR adds local slash command support ( 🔍 General Feedback
🎯 Specific Feedback🟢 Medium
export function isLocalFreshSessionCommand(input: string): boolean {
const trimmed = input.trim();
if (!trimmed.startsWith('/')) {
return false;
}
const token = trimmed.split(/\s+/, 1)[0]?.toLowerCase() ?? '';
const normalized = token.slice(1);
return LOCAL_FRESH_SESSION_COMMANDS.some((command) => command === normalized);
}
🔵 Low
✅ Highlights
|
wenshao
left a comment
There was a problem hiding this comment.
No issues found. LGTM! ✅ — gpt-5.4 via Qwen Code /review
TLDR
✅ Add a local
/clearslash command to the VS Code IDE Companion so it is visible in slash completion and can explicitly trigger the fresh-session reset flow.✅ The companion now supports
/clear,/reset, and/newas equivalent entry points, while avoiding false positives for plain text likeclear.❓ This is a stacked follow-up and targets
followup/2874-review-suggestions, notmain.Screenshots / Video Demo
N/A — this change is mainly about slash-command discoverability and session reset behavior, and I have not recorded a separate demo.
Reviewers can validate it directly in the VS Code IDE Companion using the test plan below.
Dive Deeper
Background and Motivation
In
#2621, VS Code extension users explicitly asked for a more obvious way to clear the current context and start a fresh session, instead of relying only on the existingNew SessionUI.The CLI already exposes
/clear, with/resetand/newas aliases, but the VS Code IDE Companion did not surface that workflow explicitly.Design Approach
This change does not introduce a second session-reset implementation. Instead, it reuses the companion’s existing “start a new session and clear the current conversation UI” flow.
The implementation works in three layers:
/clearis discoverable.sendMessagepathway.SessionMessageHandlerintercepts local fresh-session commands and routes them into the existinghandleNewQwenSession()logic instead of treating them as normal prompts.Implementation Details
localSlashCommands.ts/clear,/reset, and/newclearcommand into ACP-providedavailableCommandsApp.tsx/${command.name}SessionMessageHandler.tsconversationCleared/clearstarts a fresh session/resetworks as an aliasclearis still treated as a normal promptclearBackward Compatibility
This does not change normal message submission behavior.
Only explicit slash commands
/clear,/reset, or/newtrigger the local fresh-session path. Plain text likeclearcontinues to be sent as a normal prompt.Performance Considerations
The change is limited to lightweight command merging and a small pre-send string check. It does not add any heavy state management or new async flows.
Runtime overhead should be negligible, and the main regression points are covered by targeted tests.
Reviewer Test Plan
Automated Verification
Run:
cd packages/vscode-ide-companion npx vitest run src/webview/handlers/SessionMessageHandler.test.ts src/webview/providers/WebViewProvider.test.ts src/webview/utils/localSlashCommands.test.ts npm run build:devManual Validation
/clin the input box and confirm/clearappears in slash completion./clearand confirm the current conversation is cleared and a fresh session starts./resetand send it, then confirm it behaves the same as/clear./newand send it, then confirm it behaves the same as/clear.clearand send it, then confirm it is treated as a normal message rather than resetting the session.clearcommand, confirm the slash list does not show duplicates.Testing Matrix
Notes:
Linked issues / bugs
Related to #2621