Skip to content

fix: instant terminal switching — keep sessions alive (VSCode-style) - #23

Merged
aterrylu merged 1 commit into
mainfrom
terry/instant-terminal-switching
Mar 11, 2026
Merged

fix: instant terminal switching — keep sessions alive (VSCode-style)#23
aterrylu merged 1 commit into
mainfrom
terry/instant-terminal-switching

Conversation

@aterrylu

Copy link
Copy Markdown
Owner

Summary

  • Eliminate violent flashing/redraw when switching between sessions
  • Keep all terminal instances alive in memory (like VSCode terminal tabs)
  • Switch = toggle CSS visibility, not destroy + recreate + replay buffer

What changed

  • SessionViewManager: Renders a SessionPane for each live session, only the active one is visible
  • SessionPane: Extensible view container (terminal now, future: VNC/graphics)
  • useTerminal: Takes explicit sessionId param so multiple instances coexist
  • Removed: TerminalView component and key={sessionId} forced remount

Before

Session switch → unmount terminal → close WebSocket → mount new terminal → new WebSocket → replay 1MB buffer → flash

After

Session switch → display: none on old → display: block on new → instant

Test plan

  • Create 2+ sessions, switch between them — should be instant, no flash
  • Kill a session — its terminal instance is cleaned up
  • Theme changes apply to all active terminals
  • PTY exit (close Claude Code) properly cleans up
  • Reconnect on tab focus change still works

🤖 Generated with Claude Code

Replace destroy-and-recreate pattern with persistent session views.
All terminal instances stay alive in memory; switching sessions just
toggles container visibility. Eliminates violent redraw/flashing.

- SessionViewManager: renders all live sessions, toggles display
- SessionPane: extensible view container per session (terminal now,
  VNC/graphics views in the future)
- useTerminal: takes explicit sessionId param for multi-instance use
- Remove TerminalView (replaced by SessionPane)
- Remove key={sessionId} from App.tsx (was forcing remounts)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@aterrylu
aterrylu enabled auto-merge (squash) March 11, 2026 22:36
@aterrylu
aterrylu merged commit aa23fa8 into main Mar 11, 2026
1 check passed
@aterrylu
aterrylu deleted the terry/instant-terminal-switching branch March 11, 2026 22:36
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.

1 participant