Skip to content

fix(tui): save session exports to the working directory - #62253

Open
Tarquinen wants to merge 5 commits into
devfrom
export-cwd
Open

Tarquinen wants to merge 5 commits into
devfrom
export-cwd

Conversation

@Tarquinen

@Tarquinen Tarquinen commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Issue for this PR

Closes #53748

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

/export → Export saves the transcript to /tmp/session-<uuid>.md instead of the directory you launched opencode in, where v1 saved it. With a private /tmp the file can't even be found from outside. This saves it to the TUI's working directory (paths.cwd) again. I used that rather than the session's directory because, when attached to a remote server, the session's directory may not exist locally.

How did you verify your code works?

Ran the real TUI in a throwaway project and exported a session: on dev the file lands in /tmp, on this branch in the project directory with nothing written to /tmp. Typecheck and bun run check pass.

Screenshots / recordings

Before:

After:

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #61335

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix works. I ran /export → Export in the TUI with opencode-drive on both checkouts. On dev the dialog shows /tmp/session-<uuid>.md and the file is written there, readable by all local users (-rw-r--r--). With this change it is written to the project directory the TUI was launched in, and nothing goes to /tmp. tsc in packages/tui shows no new errors (same 26 environment-related errors as the base), and the export options dialog test passes.

Public API is unchanged. Only the location of the TUI's export file changes, back to the v1 behaviour.

Using the TUI's own working directory rather than the session directory is the right call, since the TUI process writes the file, including when attached with --server. No concerns.

Related: #61335

Before

After

@Tarquinen

Copy link
Copy Markdown
Member Author

Confusing bot pics because its already in /tmp ^

@Tarquinen Tarquinen changed the title fix(tui): save session exports to the working directory fix(tui): choose project or temp folder for session exports Nov 7, 2026
@Tarquinen Tarquinen changed the title fix(tui): choose project or temp folder for session exports fix(tui): save session exports to the working directory Nov 7, 2026

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commits work. I checked them in the TUI with opencode-drive: the export dialog now has a Save to: Project / Temp row with Project selected by default. Export with Project wrote session-<uuid>.md into the project directory, and with Temp it wrote to /tmp, as before. Copy is unaffected. The export dialog test passes, and tsc in packages/tui shows no new errors compared with the base. I only drove the default dialog; for the new-designs dialog I read the code, which handles the Location row the same way as Format.

Public API is unchanged, since the export options type is internal to the TUI.

No concerns.

Before

After

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v2 /export saves to /tmp/ instead of current working dir like v1

1 participant