Skip to content

Split-screen tab groups with canonical group/item model - #520

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/splitscreen-md-terminal
Apr 12, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/splitscreen-md-terminal

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Apr 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Re-lands split-screen tab groups (originally PR #393, reverted in PR #403) with a fundamentally revised architecture. The previous attempt overlaid groups on top of multiple competing tab authorities (terminal, editor, browser slices), requiring constant cross-slice synchronization that broke tab switching. This implementation uses a canonical group/item model where TabsSlice owns tab membership, order, and per-group activation, while domain slices retain only content/runtime state.

What's included

Core tab group architecture

  • TabGroupPanel and TabGroupSplitLayout components for rendering split groups
  • TabGroupLayoutNode tree for split layout with split/focus/close/move actions
  • Single-group mode uses the same state model (one group = one leaf)
  • Group focus drives keyboard tab cycling and new-tab placement
  • Session persistence and hydration for group/item/layout state

Terminal split-group support

  • Terminals render from group/item state while PTY lifecycle stays in TerminalSlice
  • Per-leaf PTY ID snapshots so multi-pane terminals re-attach each pane to its own shell across layout remounts
  • Three-priority reattach strategy: snapshot PTY (verified live) > eager buffer handle (startup reconnect) > tab-level fallback
  • Unmount cleanup guards PTY preservation to layout-only remounts, preventing leaked backend shells

Editor split-group support

  • Editor tab instances point at shared underlying document state
  • Preview replacement and pin/close are group-local at the tab-instance layer
  • Same file can appear in multiple groups without corruption

Browser split-group support

  • Browser tabs participate in the unified tab group model

Hydration fixes

  • Promote first surviving tab as activeTabId when transient tabs (diff, conflict-review) are dropped during restore
  • Prefer non-empty groups when selecting the active group after restore
  • Extract shared hydration helpers to tabs-helpers.ts

Bug fixes

Test plan

  • Split a terminal tab into a new group, verify both groups render independently
  • Split-pane terminal across groups: verify each pane re-attaches to its own shell on remount
  • Open the same editor file in two groups, edit in one, verify the other reflects changes
  • Close the last tab in a group, verify the group collapses and focus moves correctly
  • Restart the app with split groups open, verify layout, active tabs, and PTYs restore correctly
  • Restart with a persisted diff tab that has no backing file state, verify active group falls back to one with surviving tabs
  • Keyboard terminal open (Cmd+t) operates within the focused group
  • Single-group mode behaves identically to pre-split UX
  • pnpm test passes for tabs, tabs-hydration, tabs-helpers, and editor test suites
image

@brennanb2025 brennanb2025 changed the title fix: split-screen terminal PTY reattach and hydration fixes feat: re-land split-screen tab groups with canonical group/item model Apr 12, 2026
@brennanb2025 brennanb2025 changed the title feat: re-land split-screen tab groups with canonical group/item model Split-screen tab groups with canonical group/item model Apr 12, 2026
…ile fix

- Capture per-leaf PTY IDs in layout snapshots so multi-pane terminals
  re-attach each pane to its own shell instead of all panes racing onto
  the single tab-level ptyId.
- Three-priority reattach strategy: snapshot PTY (verified live) >
  eager buffer handle (startup reconnect) > tab-level fallback.
- Promote first surviving tab as activeTabId when transient tabs are
  dropped during hydration, preventing blank restored groups.
- Prefer non-empty groups when selecting the active group after restore.
- Guard unmount cleanup to only preserve PTYs when the terminal tab
  still exists in store, preventing leaked backend shells.
- Fix onPinFile in TabGroupPanel to use the unified tab UUID (second
  parameter) instead of the file path, which was silently no-oping.
- Extract shared helpers to tabs-helpers.ts and add test coverage.
The handleRestartCodexPane callback was missing effectiveVisibleRef and
restoredPtyIdByPaneId after those fields were added to PtyConnectionDeps.
The tab-level ptyId fallback in connectPanePty had no guard against
multi-pane scenarios. When a user split a pane, the new pane reattached
to the original pane's PTY instead of spawning a fresh shell, replacing
the original pane's data handler in the singleton dispatcher.

Add a pane count check so the fallback only fires for single-pane tabs.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/splitscreen-md-terminal branch from 8c32d95 to 556a28a Compare April 12, 2026 07:56
@brennanb2025
brennanb2025 merged commit 839d871 into main Apr 12, 2026
1 check passed
@brennanb2025
brennanb2025 deleted the brennanb2025/splitscreen-md-terminal branch April 12, 2026 08:10
heyramzi added a commit to heyramzi/orca that referenced this pull request Apr 12, 2026
The split-screen tab groups PR (stablyai#520) changed Terminal.tsx to render
TabGroupSplitLayout only for the active worktree. When switching
worktrees, React unmounts the previous TabGroupPanel and all its
TerminalPane children, triggering the useEffect cleanup that destroys
PaneManagers, PTY transports, and kills terminal processes. This made
every worktree switch kill running Claude Code / Codex sessions.

Render TabGroupSplitLayout for ALL mounted worktrees and toggle
visibility with CSS (hidden class) instead of conditional rendering.
This matches the pattern the old rendering path used before stablyai#520,
where all worktrees were always mounted with absolute positioning
and display toggling. Terminal components stay in the React tree
across worktree switches, preserving PTY connections and scrollback.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
brennanb2025 added a commit that referenced this pull request Apr 12, 2026
brennanb2025 added a commit that referenced this pull request Apr 12, 2026
Reapplies the fixes from #542 which were reverted in #546 as part of
the #520 revert chain.

- Replace single-value initialTabCreationGuardRef with a Set so
  closing the last tab no longer auto-spawns a replacement terminal
- Upgrade all stopPropagation to stopImmediatePropagation as
  defense-in-depth against duplicate window-level keydown handlers

The focusedGroupId change from #542 is omitted because it targeted
TabGroupSplitLayout from #520, which remains reverted. The current
code already gates isActive on isVisible, providing the same
protection.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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