You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
P1: Bind terminal sessions to the current worktree and clean up removed threads #1183
Audit #1180, 2026-09-10. Baseline: checkout 9fc8645; fetched origin/main bf6fb02 has identical relevant implementation. This is implementation backlog, not a shipped fix.
Evidence
electron/terminal.js returns an existing live session by threadId before comparing the requested root. A fake-child check of the real module called open(id, '/tmp/old') then open(id, '/tmp/new'); the second call still reported '/tmp/old'.
electron/ipc.js resolves worktreePath || project.path on every terminal call. A shell opened before materialization can keep running in the main checkout after its thread acquires a worktree.
Source tracing found no terminal cleanup in electron/services.js purgeThread/deleteThread or Store.removeThread. Pane unmount preserves sessions. After permanent deletion terminal:close rejects Unknown thread, leaving cleanup until app exit. Root reuse was reproduced with a fake child; deletion leakage is source-confirmed, not measured against live user processes.
Change
Bind sessions to thread plus execution root/host. On root change, make stale ownership visible and require safe reattachment before accepting another command. Do not silently kill a running job or silently continue in the old checkout. Use a shared permanent-removal cleanup path for thread deletion, project removal and retention. Preserve ordinary pane hide/show reattachment. Expose Close session separately from Restart.
Acceptance
Opening before worktree materialization cannot silently execute later commands in the main checkout.
Merge/reclaim cannot leave a seemingly valid terminal attached to a removed directory.
Permanent removal releases owned shells and descendants with correct platform handling.
Closing a pane may retain the session; Close session explicitly terminates it.
Cover root changes, reattachment, deletion and project removal; never signal unrelated processes.
Coordinate with #147's session manager and the PTY upgrade under #1180.
A stale shell only gets a warning. terminal:write still accepts input (electron/terminal.js:485), so the "require safe reattachment before accepting another command" requirement is not met.
On WSL the shell starts in the project root, not the worktree (terminal.js:357), so it can run commands in the main checkout.
Fixed: open reports a stale root and supports moving to the current worktree (terminal.js:328-337), and trashing a thread kills its terminals (services-threads.js:1176). Closing in the 2026-10-09 board cleanup (#1532).
Activity
Merge pull request #1502 from currentbits/coder/1501-g4-lazy-git-pane…
currentbits commentedon Oct 9, 2026
Gap pass #1532 checked this against main @24d3c36b (v0.24.0). It is mostly shipped:
staleRoot(electron/terminal.js:337).services-threads.js:1176). Every permanent removal goes throughpurgeThread.Keeping this open for two gaps:
terminal:writestill accepts input (electron/terminal.js:485), so the "require safe reattachment before accepting another command" requirement is not met.terminal.js:357), so it can run commands in the main checkout.currentbits commentedon Oct 9, 2026
Fixed:
openreports a stale root and supports moving to the current worktree (terminal.js:328-337), and trashing a thread kills its terminals (services-threads.js:1176). Closing in the 2026-10-09 board cleanup (#1532).