Skip to content

fix: prevent split-group container teardown when switching worktrees - #726

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/brennanb2025-fix-split-group-container-teardown
Apr 16, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/brennanb2025-fix-split-group-container-teardown

Conversation

@brennanb2025

Copy link
Copy Markdown
Contributor

Summary

  • Bug: Switching to a newly-activated worktree (with no split-group layout yet) caused the split-group container to unmount, destroying PaneManagers, xterm.js buffers, and PTY connections for all previously mounted worktrees. Switching back lost all terminal scrollback and shell sessions.
  • Fix: Replace the effectiveActiveLayout gate with anyMountedWorktreeHasLayout — the container stays mounted (hidden via CSS) as long as any mounted worktree has a layout, preventing teardown while the legacy fallback renders the new worktree.
  • Tests: Extract getEffectiveLayoutForWorktree and anyMountedWorktreeHasLayout into split-group-mount.ts with 9 unit tests covering the core bug scenario and edge cases.

Test plan

  • pnpm test — all 1730 tests pass
  • pnpm run typecheck — clean
  • Manual: open split pane → switch to new worktree → switch back → split panes preserved
  • E2E coverage in companion branch (brennanb2025/brennanb2025-playwright-split-groups-tests), depends on this landing first

…ktree

When the split-group renderer path is enabled, the container was
conditionally mounted based on effectiveActiveLayout (the active
worktree's layout). Switching to a newly-activated worktree that has no
split-group layout yet caused the container to unmount, destroying
PaneManagers, xterm buffers, and PTY connections for ALL previously
mounted worktrees.

Fix: use anyMountedWorktreeHasLayout to keep the container mounted
whenever any mounted worktree has a layout. When the active worktree
has no layout, hide the container with CSS instead of unmounting it,
so the legacy fallback renders while existing worktree state is
preserved.
Extract getEffectiveLayoutForWorktree and anyMountedWorktreeHasLayout
into a standalone helper so the container-teardown fix is covered by
unit tests. Remove FIX.md.
@brennanb2025
brennanb2025 merged commit 48c2493 into main Apr 16, 2026
1 check passed
@brennanb2025
brennanb2025 deleted the brennanb2025/brennanb2025-fix-split-group-container-teardown branch April 16, 2026 21:29
brennanb2025 added a commit that referenced this pull request Apr 19, 2026
Adds Playwright coverage for two high-regression areas identified from the
last 200 PRs:

- worktree-lifecycle.spec.ts: guards removeWorktree cleanup (#532),
  worktree switch with right sidebar open (#598/#628/#726), and
  cross-worktree tab isolation (#542/#554).
- tab-close-navigation.spec.ts: guards visual-neighbor activation on
  editor/diff close (#693) and Landing fallback when the last visible
  surface closes (#677).
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