feat(vscode-companion): support /export session command#2592
Conversation
📋 Review SummaryThis PR adds native 🔍 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. |
tanzhenxin
left a comment
There was a problem hiding this comment.
Nice one! Having /export session support in the VS Code companion is a great quality-of-life improvement. Looks good to me — merge at your convenience! 👍
dc9e209 to
e31ae84
Compare
wenshao
left a comment
There was a problem hiding this comment.
[Critical] packages/cli/src/utils/earlyInputCapture.ts:221 drops a real standalone ESC key pressed during startup. shouldReplayPendingAtStop() only replays pending bytes when classifyEscapeSequence(...) === 'user', but a lone ESC is classified as incomplete, so it is discarded when capture stops before another byte arrives. That means the new early-input capture path can still lose a real user keystroke in the startup window it is supposed to protect.
Suggested fix: treat a standalone trailing ESC as replayable user input at stop time, while still dropping known terminal-response prefixes such as ESC[?, ESC[>, ESC], ESCP, ESC_, and ESC^.
— gpt-5.4 via Qwen Code /review
|
Review summary from Qwen Code ( I found 2 blocking issues in the PR-introduced changes:
Notes:
— gpt-5.4 via Qwen Code /review |
Add nested /export completion and ACP command availability for the VS Code companion. Reuse the shared export flow, write to the default path, and show clickable export results in chat.
Restore the CLI export description to the existing wording. Keep the VS Code companion error message consistent with the required /export subcommands.
Handle local markdown file links in assistant messages even when automatic file-link detection is disabled. Normalize encoded paths and line fragments so exported files can be opened from the VS Code webview.
… alias Remove duplicate AvailableCommand import caused by merge, and add vitest resolve alias for @qwen-code/qwen-code/export so the session export service tests can resolve the CLI export module from source.
a073857 to
92bf609
Compare
The test mock was only setting up getCommands but getAvailableCommands calls getCommandsForMode. Add getCommandsForMode to the mock and set up test data on it instead.
|
@wenshao 关于 review summary 中提到的 TS4111 问题: 确认检查过,本仓库的 tsconfig 中 未启用 这应该是 bot review 的误报(可能假设了更严格的 TS 配置)。PR 代码无需改动。 |
…alog - Fix file:/// URI handling in MarkdownRenderer: normalizeExplicitFileLink now strips the file:// scheme before checking isAbsolutePath, so exported file links are properly recognized and clickable - Replace direct cwd file write with vscode.window.showSaveDialog() so users can choose the export destination and filename - Handle cancelled save dialog gracefully (return null, skip success message)
…lenames - normalizeExplicitFileLink now returns early for file:// URIs without splitting on #, since vscode.Uri.file() encodes # as %23 in the path. This prevents filenames containing # from being truncated after decode. - Explicit-link click handler now only fires for file:// URI hrefs, not arbitrary relative paths. This prevents model-generated markdown links from bypassing enableFileLinks=false and opening arbitrary files. - Remove unused KNOWN_FILE_EXTENSIONS constant.
…tale JSDoc - Add showSaveDialog mock to sessionExportService.test.ts - Update existing test to verify save dialog is called with correct args - Add test for cancelled save dialog returning null - Fix JSDoc that incorrectly claimed fallback-to-cwd behavior
…/ URIs The previous commit scoped handleContainerClick to only intercept file:// URIs, which broke normal markdown file-path links like [export.html](/tmp/my%20dir/export.html) and links with #L... line fragments. This restores the original explicit-link path handling (absolute paths and known-extension relative files) while keeping the new file:// URI support.
803d591 to
02449fd
Compare
…mmands test After merging main, getAvailableCommands now calls config.getDisabledSlashCommands() which was not mocked in the getAvailableCommands test block. The missing mock caused the call to throw, caught by the try/catch which returned [], failing the assertion.
* feat(vscode-companion): support /export session command * fix(vscode-ide-companion/webview): prefer ACP session id for export * feat(vscode-ide-companion): support /export slash command Add nested /export completion and ACP command availability for the VS Code companion. Reuse the shared export flow, write to the default path, and show clickable export results in chat. * fix(export): align slash command messaging Restore the CLI export description to the existing wording. Keep the VS Code companion error message consistent with the required /export subcommands. * fix(webui): support explicit markdown file links Handle local markdown file links in assistant messages even when automatic file-link detection is disabled. Normalize encoded paths and line fragments so exported files can be opened from the VS Code webview. * test(vscode-ide-companion): make export path assertion cross-platform * fix(vscode-ide-companion): use public session export entrypoint * fix(cli): replay standalone ESC after early capture * fix(vscode-ide-companion): resolve rebase artifacts and vitest export alias Remove duplicate AvailableCommand import caused by merge, and add vitest resolve alias for @qwen-code/qwen-code/export so the session export service tests can resolve the CLI export module from source. * fix(cli): fix getAvailableCommands test mock to use getCommandsForMode The test mock was only setting up getCommands but getAvailableCommands calls getCommandsForMode. Add getCommandsForMode to the mock and set up test data on it instead. * fix(vscode-ide-companion): fix export file link click and add save dialog - Fix file:/// URI handling in MarkdownRenderer: normalizeExplicitFileLink now strips the file:// scheme before checking isAbsolutePath, so exported file links are properly recognized and clickable - Replace direct cwd file write with vscode.window.showSaveDialog() so users can choose the export destination and filename - Handle cancelled save dialog gracefully (return null, skip success message) * fix(webui): scope file link handler to file:// URIs only, fix # in filenames - normalizeExplicitFileLink now returns early for file:// URIs without splitting on #, since vscode.Uri.file() encodes # as %23 in the path. This prevents filenames containing # from being truncated after decode. - Explicit-link click handler now only fires for file:// URI hrefs, not arbitrary relative paths. This prevents model-generated markdown links from bypassing enableFileLinks=false and opening arbitrary files. - Remove unused KNOWN_FILE_EXTENSIONS constant. * fix(vscode-ide-companion): update export tests for save dialog, fix stale JSDoc - Add showSaveDialog mock to sessionExportService.test.ts - Update existing test to verify save dialog is called with correct args - Add test for cancelled save dialog returning null - Fix JSDoc that incorrectly claimed fallback-to-cwd behavior
TLDR
Add native
/exportsupport to the VSCode Companion so users can export the current session directly from the IDE with CLI-parity formats and IDE-native save/open UX.Screenshots / Video Demo
Kapture.2026-04-18.at.23.19.40.mp4
Dive Deeper
This PR adds a dedicated VSCode-side export flow instead of sending
/exportthrough the normal chat prompt path.Main changes:
/exportin the VSCode companion before it is sent to the agent./exportto HTML so slash-command selection works immediately in the current companion UX./export md,/export json, and/export jsonlthrough the same native flow.sessionExportServicethat loads the real recorded session, reuses the existing export formatters, opens a native Save As dialog, and writes the chosen file.Open Fileaction after export completes./exportslash-command description so the completion menu documents the supported non-default formats.Touched areas:
packages/vscode-ide-companion/src/services/sessionExportService.tspackages/vscode-ide-companion/src/webview/handlers/SessionMessageHandler.tspackages/cli/src/ui/commands/exportCommand.tsReviewer Test Plan
npm exec --workspace=packages/vscode-ide-companion vitest -- --run src/services/sessionExportService.test.ts src/webview/handlers/SessionMessageHandler.test.tsnpm exec --workspace=packages/cli vitest -- --run src/ui/commands/exportCommand.test.tsnpm run build --workspace=packages/vscode-ide-companion/export/export md/export json/export jsonl/exportdefaults to HTMLOpen Fileaction/exportarguments show an error instead of sending a chat promptTesting Matrix
Linked issues / bugs
Resolves #1991