Goal
On app startup, read all saved layouts from electron-store (windowLayouts key) and recreate each window with its saved tabs, panes, cwds, and active session.
Scope
- After
app.on('ready') fires and the sidecar is up (app/index.ts:330), iterate windowLayouts entries
- For each entry: create a
BrowserWindow at the saved position/size, wait for renderer load, then drive a sequence of RPC calls to recreate the layout
- Reuse the saved
windowUid so the next save round-trips to the same slot
Restoration sequence per window
- Open window with saved position/size
- Wait for renderer ready
- For each tab in saved layout:
- Send RPC
'create tab' with saved tabName
- For each pane in the tab's BSP tree (root → leaves):
- If root: spawn shell with
cwd from saved cwds[sessionUid]
- If split: send RPC
'split pane' with parent UID, direction, sizes
- If web pane: send RPC
'open web pane' with URL from saved webUrls[sessionUid]
- Send RPC
'set active session' with saved activeSessionUid
Existing primitives
app/ui/window.ts:189 createSession() already supports cwd option — pass through saved cwd
bridge.ts:718 updateSessionLayout() flows BSP coords back; should round-trip cleanly
- Web pane creation already exists via
/api/web-pane and renderer webUrl handling
New RPC handlers needed (renderer side)
'replay tab' — create a tab with given name + initial cwd
'replay split' — split a given pane in a given direction with given sizes
'replay web pane' — open a web pane in a given pane slot with given URL
'replay set active' — set the active session
These are thin wrappers around existing Redux actions (split, setActive, etc.).
Edge cases
- Saved cwd no longer exists → fall back to home directory (existing
createSession already validates with existsSync)
- Saved layout references a window position off-screen → clamp via existing
windowUtils.positionIsValid()
- Multiple saved windows → open them sequentially to avoid race conditions
Files touched
app/index.ts — startup hook reads layouts and orchestrates restore
lib/index.tsx or renderer entry — handle replay RPCs
lib/actions/term-groups.ts — may need a replaySplit action that takes explicit sizes
Depends on
#82 (save layout) — without saved data there's nothing to restore
Goal
On app startup, read all saved layouts from
electron-store(windowLayoutskey) and recreate each window with its saved tabs, panes, cwds, and active session.Scope
app.on('ready')fires and the sidecar is up (app/index.ts:330), iteratewindowLayoutsentriesBrowserWindowat the saved position/size, wait for renderer load, then drive a sequence of RPC calls to recreate the layoutwindowUidso the next save round-trips to the same slotRestoration sequence per window
'create tab'with savedtabNamecwdfrom savedcwds[sessionUid]'split pane'with parent UID, direction, sizes'open web pane'with URL from savedwebUrls[sessionUid]'set active session'with savedactiveSessionUidExisting primitives
app/ui/window.ts:189 createSession()already supportscwdoption — pass through saved cwdbridge.ts:718 updateSessionLayout()flows BSP coords back; should round-trip cleanly/api/web-paneand rendererwebUrlhandlingNew RPC handlers needed (renderer side)
'replay tab'— create a tab with given name + initial cwd'replay split'— split a given pane in a given direction with given sizes'replay web pane'— open a web pane in a given pane slot with given URL'replay set active'— set the active sessionThese are thin wrappers around existing Redux actions (split, setActive, etc.).
Edge cases
createSessionalready validates withexistsSync)windowUtils.positionIsValid()Files touched
app/index.ts— startup hook reads layouts and orchestrates restorelib/index.tsxor renderer entry — handle replay RPCslib/actions/term-groups.ts— may need areplaySplitaction that takes explicit sizesDepends on
#82 (save layout) — without saved data there's nothing to restore