Feature: add "Copy as Markdown" context menu action (#21) - #22
Merged
thegoodengineer merged 1 commit intoAug 14, 2026
Merged
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #21
Feature
Tree items already carry a
contextValue(treeProvider.ts, set to the pass/fail/unknown status), but no context menu was ever wired up to use it. Right-clicking a history entry did nothing TruthLog-specific — you had to click the row, wait for the read-only editor tab to open, select all, copy, then switch back and paste. This adds a "Copy as Markdown" right-click action that collapses that into one click, matching the extension's own stated purpose: giving you ground truth to paste back into a conversation with an AI agent when it misreports a result.Implementation
extension.ts: addedrenderAsMarkdown(execution), which wraps the existingrenderOutputDocument()header+output formatting (already used for the "click to open output" viewer) in a fenced markdown code block — no new formatting logic invented, just reused and wrapped so it pastes cleanly into a markdown-rendering chat. Registered a new command,truthlog.copyAsMarkdown, that resolves the target execution and writes the rendered markdown viavscode.env.clipboard.writeText.executionIdFromCommandArg()to accept either a bare execution id (string) or the fullExecution-shaped object. This matters because VS Code invokes aview/item/contextcommand with the selected tree element itself as the argument (the actualExecutionobject, sinceTruthLogTreeProvideris aTreeDataProvider<Execution>) — unliketruthlog.openOutput, which is wired to a manually-specified id viaitem.command.arguments. Falls back gracefully (logs a warning, no-op) if the argument doesn't resolve to a valid id, and shows a warning message if the execution is no longer in history (cleared or trimmed) — mirroring the existing fallback text inOutputFileSystemProvider.readFile.package.json: added thetruthlog.copyAsMarkdowncommand declaration (with a$(copy)icon), hid it from the command palette (when: "false", matchingtruthlog.openOutput's existing pattern, since it needs a selected item to make sense), and added acontributes.menus.view/item/contextentry keyed offview == truthlog.historyso it shows up in the right-click menu for history rows.No architecture changes, no new state, no new settings.
Testing
npm run compilepasses cleanly with no errors.src/test/suite/recording.test.ts, following the existing pattern used fortruthlog.openOutput:truthlog.copyAsMarkdownwith the fullExecutionobject (matching how a real context-menu click invokes it) and asserts the clipboard contains a properly-fenced (```-delimited) block including the command text, the exit code line, and the raw outputrenderAsMarkdown/renderOutputDocumentformatting logic in a standalone plain-Node script (bypassing the blocked Electron host) — confirmed the fence markers, command text, exit-code line, and marker output all appear exactly as the new tests assert.npm test(the Electron-hosted VS Code integration suite) in this environment — same Windows-sandbox limitation as those PRs (Code.exedoesn't launch as a real GUI app here, matching why this repo's own CI only runs the integration suite onubuntu-latestunderxvfb). This PR's CI run will be the first real execution of the new tests.