Skip to content

fix(terminal): prevent dead terminal after split via WebGL lifecycle and worktree dedup - #1298

Merged
Jinwoo-H merged 3 commits into
mainfrom
Jinwoo-H/daemon-issue-3-fix-v3
May 1, 2026
Merged

Jinwoo-H merged 3 commits into
mainfrom
Jinwoo-H/daemon-issue-3-fix-v3

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented May 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • WebGL dispose/reattach across DOM reparent: wrapInSplit() and insertPaneNextTo() reparent pane containers, which can silently invalidate WebGL contexts (Chromium reclaims oldest context near its ~8–16 limit without firing contextlost). Now disposes WebGL before the DOM move and reattaches after layout settles (200ms timer).
  • Worktree dedup race fix: createWorktree() appended the new worktree unconditionally, but the file watcher / 3s poll can trigger fetchWorktrees() between the backend creating the worktree and the callback running — producing duplicate entries. Now checks before appending, plus belt-and-suspenders dedup in the useAllWorktrees selector.
  • Diagnostic health check: Logs [split-diag] DEAD TERMINAL 1s after split when the buffer has data but serialize() is empty (true dead terminal, not slow PTY spawn).

Test plan

  • Create 20+ worktrees with setup-split config — verify no blank/dead terminals
  • Drag-reorder panes — verify terminals stay alive after reparent
  • Check console for [split-diag] logs — should show healthy or no content yet, never DEAD TERMINAL
  • Verify existing pane-manager unit tests pass

Made with Orca 🐋

Jinwoo-H and others added 3 commits May 1, 2026 01:04
…attach and worktree dedup

Two root causes for intermittent blank terminals after setup-script splits:

1. WebGL context invalidation during DOM reparent — wrapInSplit() detaches
   and reattaches the existing pane's container, which can silently kill the
   WebGL context (Chromium reclaims oldest context near its ~8-16 limit
   without firing contextlost). Fix: dispose WebGL before the DOM move,
   reattach in the 200ms scheduleSplitScrollRestore timer. Same pattern
   applied to insertPaneNextTo (drag-drop reorder).

2. Duplicate worktree entries causing React key collision — race between
   createWorktree (appends unconditionally) and file-watcher/poll triggering
   fetchWorktrees (replaces array with list that already includes the new
   worktree). Fix: check for existing entry before appending, plus
   belt-and-suspenders dedup in the useAllWorktrees selector.

Also adds diagnostic health check (1s after split) to detect dead terminals
in the field — only flags when buffer has data but serialize() is empty.

Co-authored-by: Orca <[email protected]>
@Jinwoo-H
Jinwoo-H merged commit b4f1f0e into main May 1, 2026
2 checks passed
mralexsaavedra pushed a commit to mralexsaavedra/orca that referenced this pull request May 2, 2026
Jinwoo-H added a commit that referenced this pull request May 3, 2026
Resolved conflicts across shared settings, preload APIs, runtime RPC, and
the experimental settings pane. Kept both the Mobile Pairing feature (HEAD)
and the Sidekick feature (main) as sibling experimental entries, with
Orchestration shifting to index 3 in EXPERIMENTAL_PANE_SEARCH_ENTRIES.

Extracted HiddenExperimentalGroup and SupportedAgentsDisclaimer from
ExperimentalPane.tsx into their own files to stay under the 400-line
oxlint cap after the merge increased the file size.

In pane-tree-ops.ts, kept main's PR #1298 WebGL reattach logic (moved to
pane-split-scroll.ts) and dropped HEAD's inline pendingSplitScrollState
workaround. Kept the mobile-fit-override lookup from HEAD.

In runtime-rpc.ts, kept main's sweepOrphanedRuntimeSockets startup call
alongside HEAD's WebSocket transport. Renamed singular transport field
to transports array in runtime-metadata.test.ts fixtures.

In orca-runtime.ts, merged main's getEffectiveHooks(repo, worktreePath)
signature with HEAD's setupDecision/shouldRunSetupForCreate logic.

In pty.ts, preserved HEAD's semantics of notifying runtime?.onPtyData
before the isDestroyed() check so mobile clients still receive data when
the desktop window is closed.

Co-authored-by: Orca <[email protected]>
nwparker pushed a commit that referenced this pull request May 14, 2026
… TUI cursor drift (#1413)

PR #1298 schedules scroll-restore + terminal.refresh(0, rows-1) at ~32ms
and 200ms after a split to preserve scrollback through DOM reparenting.
When a full-screen TUI (Claude Code, vim, less) is drawing at that
moment, forceViewportScrollbarSync's scrollLines(-1)/(+1) jiggle and the
buffer repaint race the TUI's next write — the TUI's cursor lands one
row below where it expects and a residual fragment is left at the old
row.

Alt-buffer has no scrollback, so scroll restore has nothing legitimate
to do there. Gate the restore + refresh behind buffer.active.type, but
keep the WebGL reattach callback firing so #1298's dead-canvas fix is
preserved. Normal-buffer splits are unchanged.

Bisected against origin/main: bug appears at b4f1f0e (#1298), absent at
its parent be0e3c2.

Co-authored-by: Orca <[email protected]>
AmethystLiang added a commit that referenced this pull request May 15, 2026
* fix: address pr-bug-scan validated finding from #1857

Restored alt-buffer guards at both the double-rAF and 200ms phases of scheduleSplitScrollRestore so TUI panes skip restoreScrollState+refresh, blocking the #1298 cursor-drift regression.

* fix: preserve split scroll state around alternate buffers

---------

Co-authored-by: orca-bug-scan-bot <[email protected]>
Co-authored-by: Jinjing <[email protected]>
aashishtamsya added a commit to aashishtamsya/orca that referenced this pull request Jul 24, 2026
…ab switch

Previously, restoreScrollStateNow returned 'skipped' for any terminal in
alternate buffer mode (OMP, vim, htop, etc.), so scroll position was always
lost when switching tabs and returning. Now restores viewport Y directly
via scrollToLine for alternate buffers — safe because tab switches have no
active draw race. The split-reparent path (scheduleSplitScrollRestore)
still defers alternate buffers to guard against stablyai#1298.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
… TUI cursor drift (stablyai#1413)

PR stablyai#1298 schedules scroll-restore + terminal.refresh(0, rows-1) at ~32ms
and 200ms after a split to preserve scrollback through DOM reparenting.
When a full-screen TUI (Claude Code, vim, less) is drawing at that
moment, forceViewportScrollbarSync's scrollLines(-1)/(+1) jiggle and the
buffer repaint race the TUI's next write — the TUI's cursor lands one
row below where it expects and a residual fragment is left at the old
row.

Alt-buffer has no scrollback, so scroll restore has nothing legitimate
to do there. Gate the restore + refresh behind buffer.active.type, but
keep the WebGL reattach callback firing so stablyai#1298's dead-canvas fix is
preserved. Normal-buffer splits are unchanged.

Bisected against origin/main: bug appears at 9ad7206 (stablyai#1298), absent at
its parent 73b65c7.

Co-authored-by: Orca <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix: address pr-bug-scan validated finding from stablyai#1857

Restored alt-buffer guards at both the double-rAF and 200ms phases of scheduleSplitScrollRestore so TUI panes skip restoreScrollState+refresh, blocking the stablyai#1298 cursor-drift regression.

* fix: preserve split scroll state around alternate buffers

---------

Co-authored-by: orca-bug-scan-bot <[email protected]>
Co-authored-by: Jinjing <[email protected]>
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.

1 participant