feat: add assistant metadata to session export #6611
Merged
+498
−94
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.
Summary
Adds assistant metadata (mode/model/duration) to session transcript exports and adds option to open in editor without saving to file.
Changed Files
packages/opencode/src/cli/cmd/tui/ui/dialog-export-options.tsx- addedassistantMetadataandopenWithoutSavingcheckbox optionspackages/opencode/src/cli/cmd/tui/routes/session/index.tsx-showAssistantMetadatasignal, conditional file save logicpackages/opencode/src/cli/cmd/tui/util/transcript.ts- extracted transcript formatting logic (new file)packages/opencode/test/cli/tui/transcript.test.ts- 15 tests for transcript formatting (new file)Export Dialog Options
Output Format
When "Include assistant metadata" is enabled:
## Assistant (Build · claude-sonnet-4-20250514 · 5.4s) Hi there!When disabled:
## Assistant Hi there!Test Coverage
15 tests covering:
formatAssistantHeader- metadata enabled/disabled, missing completion time, agent titlecasingformatPart- text, synthetic text skip, reasoning on/off, tool with/without details, tool errorsformatMessage- user messages, assistant messages with metadataformatTranscript- complete transcript with/without metadataNote
This PR was written with AI assistance.
AI Session Export
{ "info": { "title": "Add assistant metadata to session export", "agent": "opencode", "model": "claude opus 4.5" }, "summary": [ "user requested adding mode/model to export command as third option", "agent explored codebase to find export dialog and session index", "agent added modelInfo option to DialogExportOptions", "agent updated export logic to include mode/model/duration in transcript", "user requested enabling by default and asked about naming", "agent renamed modelInfo to assistantMetadata throughout", "user requested tests", "agent extracted transcript formatting into testable utility", "agent created 15 tests covering all formatting functions", "agent refactored session index to use new utility", "user requested ability to open in editor without saving file", "agent added saveToFile checkbox option", "user requested renaming to 'Open without saving' for backwards compat", "agent renamed to openWithoutSaving (default: off)" ] }