Skip to content

Add JSON chat history export with full metadata - #1378

Open
mikemikimike wants to merge 2 commits into
Nano-Collective:mainfrom
mikemikimike:fix/export-json-1309
Open

mikemikimike wants to merge 2 commits into
Nano-Collective:mainfrom
mikemikimike:fix/export-json-1309

Conversation

@mikemikimike

@mikemikimike mikemikimike commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add /export --json support with a generated JSON filename.
  • Treat explicit .json filenames as JSON exports while preserving Markdown exports.
  • Preserve the complete Message[] transcript and include session date, provider, model, token count, and session working directory metadata.
  • Use atomic writes for explicit JSON export paths.
  • Keep the lazy command registry description synchronized with the JSON export behavior.

Tests

  • pnpm exec ava source/commands/export.spec.tsx (32 passed)
  • pnpm run test:format
  • pnpm run test:types
  • pnpm run test:types:vscode
  • pnpm run test:lint
  • pnpm run test:knip
  • pnpm run test:audit
  • pnpm exec changeset status
  • Full pnpm run test:ava is not clean on Windows because of existing platform-specific failures; all export command tests pass.

Fixes #1309

Issue: #1309

@github-actions

Copy link
Copy Markdown
Contributor

nc-review: comments — 1 important, 1 nit

@mikemikimike — a few things worth a look, none blocking.

Adds /export --json and .json-extension auto-detection, serialising the full Message[] transcript with session metadata to disk. The implementation is correct: argument parsing, atomic writes for explicit JSON paths, generated names via writeUniqueFile, and path containment all behave as described. Tests cover the new metadata round-trip and the explicit-filename path. One documentation-syncing issue and one minor UX gap are worth raising.

🟠 important · completeness · source/commands/lazy-registry.ts:128

The lazy-registry entry for export still has description: 'Export the chat history to a markdown file'. CLAUDE.md states: 'Keep the description in sync with the module's own description field — they should match.' This description surfaces in /help and the slash-command picker, so users will see the stale text after this PR ships. Update it to 'Export the chat history to a markdown or JSON file' to match the module.

⚪ nit · design · source/commands/export.tsx:104

/export --json <file.json> silently ignores <file.json>userProvided is false whenever args[0] === '--json', so the second arg never reaches requestedFilename. Not a regression (the previous code never accepted a filename alongside a flag either) but worth a thought: either treat /export --json <file> as user-provided JSON, or reject the extra arg with an explanatory message.


🔴 blocking · 🟠 a reviewer would ask for a change · ⚪ optional

Automated code review — correctness, security, design, tests, plus duplicates and scope. A human still decides; this is not a substitute for review and is not exhaustive. The required status checks separately cover lint, formatting, types, unused dependencies, the test suite and the build. This bot never merges. Maintainers can rerun with /re-review.

@github-actions github-actions Bot added the agent:comments nc-review left non-blocking findings label Sep 18, 2026
@mikemikimike

Copy link
Copy Markdown
Contributor Author

/re-review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:comments nc-review left non-blocking findings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Export chat history to JSON with full tool call and token metadata (/export --json)

1 participant