Skip to content

Fix terminal surfaces staying occluded after a worktree selection flap - #759

Merged
sbertix merged 2 commits into
mainfrom
sbertix/gh-757-terminal-window-freezes-after-first-prom
Aug 2, 2026
Merged

Fix terminal surfaces staying occluded after a worktree selection flap#759
sbertix merged 2 commits into
mainfrom
sbertix/gh-757-terminal-window-freezes-after-first-prom

Conversation

@sbertix

@sbertix sbertix commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Closes #757

Summary

Terminal panes could freeze after an agent's first prompt: the picture stopped at the last frame, typing / Ctrl+C / scrolling appeared dead, and closing the tab was the only way out.

Root cause is a one-way occlusion latch. Deselecting a worktree occludes and unfocuses every surface (setAllSurfacesOccluded()), but re-selection never re-asserted activity; the only heals lived in view-layer onAppear / onChange, which do not fire when the detail view never remounts. A transient selection flap inside a single render commit (for example the selected sidebar row moving when the first presence flip lands) latched the renderer off while the pty kept draining, so input was still delivered invisibly and window shortcuts kept working.

The fix derives surface activity from worktree selection at a single selection choke point, fails open on unknown window visibility, heals from user input at a key window using the window's fresh readings, reads window activity from the observed window instead of NSApp.keyWindow, force-emits a fresh read on app activation, wakes dormant tabs from the selection commit, and logs every occlusion transition so any future report is diagnosable from logs.

Also aligns the agent presence liveness sweep with #748: kill(pid, 0) returning EPERM means the process is alive but unsignalable, not dead.

Type of change

  • Bug fix (the linked issue is a bug report)
  • Feature (the linked issue is a feature request marked ready)
  • Documentation
  • Other (please describe)

How was this tested?

A regression test reproduces the latch deterministically (worktree select, deselect, re-select with spy surfaces; it fails without the fix), plus reducer-level coverage for the cold-cache flap, the user-input heal including the covered-window negative, stale heal closures staying inert, dormant wake gating, the surfaceActivity truth table, and the EPERM probe.

  • make check passes (format + lint)
  • make test passes
  • I built and ran the app to confirm the change works

Checklist

  • This pull request is linked to an issue with Closes # above.
  • For a feature, the linked issue is labeled ready.
  • I am the author of this work and accountable for it; no commit is authored or co-authored by an AI agent.
  • I have read the Contributing guide and the Code of Conduct.

sbertix added 2 commits August 2, 2026 22:52
Deselecting a worktree occludes and unfocuses every surface, but
re-selection never re-asserted activity: the view-layer sync only fires
on a remount, so a transient selection flap inside one render commit
left the picture frozen at the last frame while the pty kept draining
and input was delivered invisibly (#757).

Derive surface activity from worktree selection at a single selection
choke point, fail open on unknown window visibility, heal from user
input at a key window using the window's fresh readings, read window
activity from the observed window instead of NSApp.keyWindow, force a
fresh emit on app activation, wake dormant tabs from the selection
commit, and log occlusion transitions.
kill(pid, 0) fails with EPERM for sandboxed processes that are still
running; only ESRCH proves death. Aligns the presence sweep with
ProcessLiveness and cross-references the mirrors.
@sbertix
sbertix enabled auto-merge (squash) August 2, 2026 20:57
@sbertix
sbertix merged commit 05a300e into main Aug 2, 2026
3 checks passed
@sbertix
sbertix deleted the sbertix/gh-757-terminal-window-freezes-after-first-prom branch August 2, 2026 21:06
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 window freezes after first prompt on grok-cli

1 participant