···11# Canvas Exit Terminal Blank Tracking
2233Last updated: 2026-04-15
44-Status: Open, intermittent, narrowed from occlusion-only suspicion to host reattachment failure
44+Status: Open, intermittent, now confirmed to affect both Canvas exit and Canvas entry via host ownership races
5566## Symptom
7788When leaving Canvas and returning to the normal worktree terminal view, the terminal area can appear blank.
99+1010+As of 2026-04-15, the reverse direction is also reproducible:
1111+1212+- after the app has been running for a while, entering Canvas from a normal worktree tab can open a blank Canvas card
1313+- the selected tab/worktree remains logically correct
1414+- unlike the earlier exit symptom, tab switching, creating a new tab, or switching away and back does not reliably recover the blank card
9151016Typical behavior:
1117···7783- a later teardown or host rebuild removes the surface from the active view tree
7884- the normal terminal host does not currently guarantee that its `documentView` still owns the surface after updates
7985- once detached, occlusion recovery is irrelevant because there is no live host left to present the surface
8686+8787+The newly observed Canvas-entry failure sharpens the theory further:
8888+8989+- the canvas host can successfully take ownership of the selected surface
9090+- the previous terminal host may still run a defensive `ensureSurfaceAttached()` while it is already leaving the window hierarchy
9191+- because that reattach path only checked "not attached to my document view", it could steal the surface back from the live canvas host
9292+- once the stale terminal host deinitializes, AppKit removes that stolen surface again, leaving Canvas blank with no active host
80938194What now looks less likely:
8295···203216- two tabs only
204217- selected tab surface detached after briefly reaching terminal-sized bounds
205218- no reattach log observed afterward
219219+- reverse repro also confirmed: entering Canvas can blank the selected card immediately
220220+- in the failing entry log, `hostReattach wrapper=<terminal>` fires after `host=canvas` is already attached and visible
221221+- the stale terminal wrapper later deinitializes and the surface ends up detached (`attached=false window=false`)
206222207223Current tactical response:
208224···210226- add host wrapper diagnostics to correlate `surface ↔ wrapper ↔ canvas/terminal`
211227- attempt a narrow fix: terminal host reattaches the surface if updates/layout find it missing
212228- add a detach-time safety net so a just-detached surface asks its last terminal host to try reattachment on the next main-loop turn
229229+- refine that narrow fix so terminal reattach only runs after the surface has actually left the view tree; it must not steal a surface currently owned by Canvas
213230214231Expected interpretation of the next repro:
215232