Skip to content

tui: /export reports failure and drops editor edits when the external editor exits non-zero #44299

Closed

Description

@aniruddhaadak80

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):

  1. await writeExport(filepath, transcript) - file is written
  2. const result = await openEditor({...}) - openEditor rejects on any non-zero editor exit (packages/tui/src/editor.ts: rejects with Editor exited with ... instead of returning)
  3. 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

  1. Set EDITOR to a command that exits non-zero, e.g. a script containing just exit 1 (or use vim and quit with :cq).
  2. In a TUI session with messages, run /export and confirm the default filename.
  3. Observe the "Failed to export session" error toast.
  4. Check the working directory: session-<id>.md exists and contains the full transcript - the export actually succeeded.
  5. 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)

Activity

  1. added a commit that references this issue on Aug 26, 2026
    477ae61
  2. neriousy commented on Oct 19, 2026

    @neriousy
    Member

    This is fixed in v2: /export writes the transcript and shows a result dialog instead of opening $EDITOR. An editor exit can no longer cause a false export failure or discard edits in that flow. Upgrade with npm i -g @opencode/cli@latest. If you still see this on v2, please open a new issue with the details.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions