You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add native /export support 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
N/A — this change is a VSCode webview/extension behavior update prepared from a CLI workflow. Reviewers can validate it with the steps below.
Dive Deeper
This PR adds a dedicated VSCode-side export flow instead of sending /export through the normal chat prompt path.
Main changes:
Intercept /export in the VSCode companion before it is sent to the agent.
Default bare /export to HTML so slash-command selection works immediately in the current companion UX.
Support /export md, /export json, and /export jsonl through the same native flow.
Add a new sessionExportService that loads the real recorded session, reuses the existing export formatters, opens a native Save As dialog, and writes the chosen file.
Show a native success notification with an Open File action after export completes.
Update the top-level /export slash-command description so the completion menu documents the supported non-default formats.
Add regression coverage for slash-command parsing, export execution, and handler interception/error handling.
This PR adds native /export command support to the VSCode Companion, enabling users to export session history directly from the IDE with CLI-parity formats (HTML, Markdown, JSON, JSONL). The implementation is well-structured with proper separation of concerns, comprehensive test coverage, and good error handling. The code follows existing project conventions and integrates cleanly with the existing export infrastructure.
🔍 General Feedback
Architecture: Excellent separation of concerns with a dedicated sessionExportService that encapsulates all export logic, keeping the message handler clean and focused.
Code Reuse: Good reuse of existing export formatters from cli/src/ui/utils/export/index.js - maintains consistency between CLI and VSCode experiences.
Testing: Comprehensive test coverage for both the export service and message handler interception, including edge cases like cancellation and error scenarios.
User Experience: Native Save As dialog and success notification with "Open File" action provides IDE-native UX that feels polished.
Error Handling: Proper error propagation to both VSCode notifications and webview, with appropriate user messaging.
🎯 Specific Feedback
🟡 High
File: packages/vscode-ide-companion/src/services/sessionExportService.ts:52-56 - The EXPORT_CONFIG constant uses as unknown as Config which bypasses type safety. This could lead to runtime issues if the config interface changes. Consider creating a proper minimal config object or extracting the required config methods from the actual config service.
File: packages/vscode-ide-companion/src/webview/handlers/SessionMessageHandler.ts:275-291 - The resolveSessionWorkingDir method has a fallback to process.cwd() which may not be appropriate in all VSCode workspace scenarios. Consider making this more explicit about when the fallback is used or throwing an error if no valid working directory can be determined.
🟢 Medium
File: packages/vscode-ide-companion/src/services/sessionExportService.ts:60-72 - The parseExportSlashCommand function uses zero-width space removal (\u200B) which is also done in SessionMessageHandler.ts:284. Consider deduplicating this logic into a shared utility to ensure consistency.
File: packages/vscode-ide-companion/src/services/sessionExportService.ts:88-100 - The renderExportContent function has a default case that throws for unsupported formats, but the type system should prevent this. Consider using assertNever pattern or removing the default since TypeScript exhaustiveness checking will catch missing cases.
File: packages/vscode-ide-companion/src/webview/handlers/SessionMessageHandler.ts:370-383 - The export command interception happens after the empty message guard. If someone sends /export with only zero-width spaces, it would be caught by the empty guard first. Consider the order of operations here.
🔵 Low
File: packages/cli/src/ui/commands/exportCommand.ts:324-327 - The description update mentions "Other formats: md, json, jsonl." but doesn't mention that HTML is the default. Consider making this clearer: "Export session to HTML (default), md, json, or jsonl format."
File: packages/vscode-ide-companion/src/services/sessionExportService.ts:44-49 - The SAVE_DIALOG_FILTERS object uses lowercase extensions (['html'], ['md'], etc.). Consider using uppercase for consistency with typical file dialog conventions (['HTML'], ['MD']), though this is cosmetic.
File: packages/vscode-ide-companion/src/webview/handlers/SessionMessageHandler.test.ts:44-58 - The mock for parseExportSlashCommand in the test file is simplified and doesn't match the real implementation's error-throwing behavior. Consider importing and using the real function or making the mock more faithful.
File: packages/vscode-ide-companion/src/services/sessionExportService.ts:127-132 - The success message format Session exported to ${formatLabel}: ${result.filename} differs slightly from the CLI format. Consider aligning these for consistency across interfaces.
✅ Highlights
Excellent test coverage: The test files cover parsing, execution, cancellation, and error handling scenarios thoroughly.
Clean interception pattern: The /export command is intercepted before being sent to the agent, preventing unnecessary round-trips and providing native IDE behavior.
Proper type safety: Good use of TypeScript's discriminated unions and type guards (isSessionExportFormat, SessionExportFormat type).
User-friendly error messages: Error messages are clear and actionable, with proper VSCode notification integration.
Consistent with CLI: Reuses the same export formatters and filename generation logic, ensuring consistent output between CLI and VSCode.
Good documentation: The PR description includes a detailed testing matrix and reviewer test plan.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
N/A — this change is a VSCode webview/extension behavior update prepared from a CLI workflow. Reviewers can validate it with the steps below.
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