Skip to content

feat: persist terminal sessions via tmux for cross-restart continuity#53

Closed
Bono2007 wants to merge 5 commits intokaanozhan:mainfrom
Bono2007:feature/tmux-session-persistence
Closed

feat: persist terminal sessions via tmux for cross-restart continuity#53
Bono2007 wants to merge 5 commits intokaanozhan:mainfrom
Bono2007:feature/tmux-session-persistence

Conversation

@Bono2007
Copy link
Copy Markdown

Summary

  • Fix double paste in terminal — removed manual clipboard.readText() on Cmd+V/Ctrl+Shift+V; xterm.js handles paste natively via the DOM paste event, avoiding the duplicate input
  • Skip permissions toggle — adds a --dangerously-skip-permissions toggle in the UI, visible only when Claude Code is the selected AI tool
  • tmux session persistence — terminals now survive app restarts; each terminal is backed by a tmux session (frame-term-N) that keeps running after Frame closes; on next launch, sessions are detected and reattached automatically

How it works

  • src/main/tmuxManager.js — low-level tmux operations (create/attach/kill/list sessions)
  • src/main/terminalPersistence.js — stores terminal metadata to userData/terminal-sessions.json
  • ptyManager — spawns PTY via tmux attach-session instead of a raw shell; restores sessions on startup
  • Renderer — tries to restore persisted terminals on launch; creates a fresh one only if none are found
  • Falls back to plain PTY if tmux is not installed on the system

Test plan

  • Open Frame, create one or more terminals, run a long-running command (e.g. ping google.com)
  • Quit Frame completely
  • Reopen Frame — terminals should reappear with the command still running
  • Close a terminal tab — its tmux session should be killed (tmux list-sessions should no longer show it)
  • Verify paste works without duplication (Cmd+V in terminal)
  • Verify skip-permissions toggle appears only for Claude Code, not other AI tools

- Add tmuxManager.js: low-level tmux session create/attach/kill/list
- Add terminalPersistence.js: JSON storage of terminal metadata in userData
- ptyManager: spawn PTY with tmux attach-session instead of raw shell
- ptyManager: add restoreTerminals() to reattach to surviving tmux sessions
- renderer/terminalManager: add restorePersistedTerminals() IPC call
- multiTerminalUI: restore sessions on startup, create new only if none found
- Add TERMINALS_RESTORE / TERMINALS_RESTORED IPC channels

Falls back to plain PTY if tmux is not installed.
Pass -u flag to all tmux invocations (create-session, attach-session)
to force UTF-8 mode. Also inject LANG/LC_ALL=en_US.UTF-8 when the
host locale is not already UTF-8, so accents (ç, é, è…) render correctly.
Instead of falling back to en_US.UTF-8, derive the UTF-8 variant
from the user's existing LANG (e.g. fr_FR.ISO-8859-1 → fr_FR.UTF-8).
process.env.LANG is unset when Frame launches from /Applications.
Query defaults read -g AppleLocale as fallback, then pass LANG/LC_ALL
explicitly via both the exec env and -e flags on new-session so the
shell inside tmux also inherits the correct UTF-8 locale.
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.

2 participants