anomalyco / anomalyco/opencode
tui: /export reports failure and drops editor edits when the external editor exits non-zero
@kommander is already working on this.
Since Aug 23, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
/export writes the transcript file first and then opens it in $EDITOR. If the editor exits non-zero, the promise rejects into the outer catch and the TUI shows "Failed to export session" - even though the export file was already created successfully on disk. Any edits saved in the editor before the non-zero exit are also silently discarded, because the post-editor rewrite (if (result !== undefined) await writeExport(filepath, result)) never runs.
Relevant path in packages/tui/src/routes/session/index.tsx (session.export handler):
await writeExport(filepath, transcript)- file is writtenconst result = await openEditor({...})-openEditorrejects on any non-zero editor exit (packages/tui/src/editor.ts: rejects withEditor exited with ...instead of returning)- rejection skips both the rewrite and the success toast, landing in
catch-> "Failed to export session"
So the reported outcome is wrong (the export exists), and the user cannot tell whether their file was written or whether their editor edits survived.
Steps to reproduce
- Set
EDITORto a command that exits non-zero, e.g. a script containing justexit 1(or use vim and quit with:cq). - In a TUI session with messages, run
/exportand confirm the default filename. - Observe the "Failed to export session" error toast.
- Check the working directory:
session-<id>.mdexists and contains the full transcript - the export actually succeeded. - With an editor like vim: make an edit, save, quit via
:cq- the exported file still has the pre-edit content; the edit is gone without any warning.
Operating System
Windows 11 (logic is platform-independent)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.