Skip to content

Add terminal layout persistence and restoration#205

Merged
sbertix merged 1 commit intomainfrom
sbertix/layout-restoration
Apr 2, 2026
Merged

Add terminal layout persistence and restoration#205
sbertix merged 1 commit intomainfrom
sbertix/layout-restoration

Conversation

@sbertix
Copy link
Copy Markdown
Collaborator

@sbertix sbertix commented Apr 1, 2026

Summary

  • Add terminal layout persistence: tabs, splits, and per-pane working directories are saved to layouts.json on app quit and worktree removal
  • Restore layouts automatically when reopening a worktree, gated behind a new Restore Terminal Layout toggle in Appearance settings
  • Layouts are always persisted regardless of the toggle, so enabling it can retroactively restore the most recent session — but only if the worktree hasn't been loaded yet or its terminal state has no open tabs

Details

  • New TerminalLayoutSnapshot model captures the full tab/split tree including split ratios, tab metadata (title, icon, tint color), and focused pane index
  • LayoutsPersistenceKey provides a @Shared persistence key backed by layouts.json
  • WorktreeTerminalManager gains saveLayoutSnapshot / loadLayoutSnapshot closures wired in supacodeApp.swift
  • Snapshots are saved on worktree selection change, worktree pruning, and applicationWillTerminate
  • Restoration skips setup scripts and gracefully handles partial failures (logs warnings, falls back to default tab)
  • SplitTree.inserting now accepts an optional ratio parameter to preserve split proportions
  • TerminalTabID and TerminalTabTintColor gain Codable conformance

Test plan

  • TerminalLayoutSnapshotTests — round-trip encoding/decoding, leaf count, first leaf extraction
  • WorktreeTerminalManagerTests — snapshot capture and persistence on selection change
  • SettingsFeatureTests — toggle persists to settings file
  • Manual: open multiple tabs/splits, quit, relaunch — verify layout is restored
  • Manual: toggle setting off, quit, relaunch — verify a single default tab opens
  • Manual: toggle setting on after a previous session — verify retroactive restoration

Closes #204

Save and restore tabs, splits, and working directories across sessions.
Layouts are persisted to layouts.json on app quit and worktree removal,
and optionally restored when reopening a worktree (gated behind a new
"Restore Terminal Layout" toggle in Appearance settings).
@sbertix sbertix requested a review from khoi April 1, 2026 22:32
Copy link
Copy Markdown
Contributor

@khoi khoi left a comment

Choose a reason for hiding this comment

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

good feature to have

@sbertix sbertix merged commit 562977d into main Apr 2, 2026
1 check passed
@sbertix sbertix deleted the sbertix/layout-restoration branch April 2, 2026 12:45
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.

Terminal session persistence

2 participants