[PR #6611] feat: add assistant metadata to session export #12002

Closed
opened 2026-02-16 18:16:56 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6611

State: closed
Merged: Yes


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 - added assistantMetadata and openWithoutSaving checkbox options
  • packages/opencode/src/cli/cmd/tui/routes/session/index.tsx - showAssistantMetadata signal, conditional file save logic
  • packages/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

[ ] Include thinking
[ ] Include tool details
[x] Include assistant metadata
[ ] Open without saving
  • Open without saving (default: off) - when checked, opens transcript in editor without creating a file
  • Include assistant metadata (default: on) - includes mode/model/duration per assistant turn

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 titlecasing
  • formatPart - text, synthetic text skip, reasoning on/off, tool with/without details, tool errors
  • formatMessage - user messages, assistant messages with metadata
  • formatTranscript - complete transcript with/without metadata

Note

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)"
  ]
}

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6611 **State:** closed **Merged:** Yes --- ## 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` - added `assistantMetadata` and `openWithoutSaving` checkbox options - `packages/opencode/src/cli/cmd/tui/routes/session/index.tsx` - `showAssistantMetadata` signal, conditional file save logic - `packages/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 ``` [ ] Include thinking [ ] Include tool details [x] Include assistant metadata [ ] Open without saving ``` - **Open without saving** (default: off) - when checked, opens transcript in editor without creating a file - **Include assistant metadata** (default: on) - includes mode/model/duration per assistant turn ## Output Format When "Include assistant metadata" is enabled: ```markdown ## Assistant (Build · claude-sonnet-4-20250514 · 5.4s) Hi there! ``` When disabled: ```markdown ## Assistant Hi there! ``` ## Test Coverage 15 tests covering: - `formatAssistantHeader` - metadata enabled/disabled, missing completion time, agent titlecasing - `formatPart` - text, synthetic text skip, reasoning on/off, tool with/without details, tool errors - `formatMessage` - user messages, assistant messages with metadata - `formatTranscript` - complete transcript with/without metadata --- > [!NOTE] > This PR was written with AI assistance. <details><summary>AI Session Export</summary> <p> ```json { "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)" ] } ``` </p> </details>
yindo added the pull-request label 2026-02-16 18:16:56 -05:00
yindo closed this issue 2026-02-16 18:16:56 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12002