Skip to content

fix(terminal): preserve live sessions when moving tabs between groups#47

Merged
GOODBOY008 merged 7 commits into
GOODBOY008:mainfrom
htazq:fix/preserve-terminal-sessions-on-group-move
Jul 16, 2026
Merged

fix(terminal): preserve live sessions when moving tabs between groups#47
GOODBOY008 merged 7 commits into
GOODBOY008:mainfrom
htazq:fix/preserve-terminal-sessions-on-group-move

Conversation

@htazq

@htazq htazq commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • keep live tab content mounted in stable per-tab portal containers
  • let the recursive grid move lightweight portal hosts instead of remounting terminals
  • preserve active-group behavior, active-tab visibility, reconnect behavior, and normal cleanup when a tab is actually closed
  • add a regression test that moves a live terminal tab into a new group without mounting or unmounting either terminal again

Root cause

MOVE_TAB_TO_NEW_GROUP replaces a grid leaf with a branch. React consequently unmounts the old TerminalGroupView, which previously owned every live PtyTerminal in the source group. The cleanup closes each WebSocket and backend PTY, and the replacement layout starts new shells.

Stable keys cannot preserve components that move across different parents or whose parent hierarchy changes, so this separates live tab ownership from the layout tree.

User impact

Moving or splitting tabs now changes only their layout. Existing xterm instances, WebSocket connections, PTY sessions, terminal history, and running foreground commands stay alive.

Testing

  • pnpm test -- src/__tests__/terminal-tab-portals.test.tsx src/__tests__/grid-renderer.test.tsx ? 2 files, 5 tests passed
  • pnpm build ? passed
  • scoped ESLint for the three changed terminal components ? passed with one pre-existing grid-renderer.tsx warning
  • full Vitest run ? 31 files / 467 tests passed; 14 pre-existing environment/mock failures remain in connection.test.ts, pty-terminal-activation.test.tsx, and pty-terminal-scrollbar.test.tsx
  • full ESLint remains blocked by the pre-existing settings-modal.tsx:293 error

Fixes #46
Related to #7

@htazq htazq marked this pull request as ready for review July 16, 2026 04:22
@GOODBOY008 GOODBOY008 self-requested a review July 16, 2026 11:06

@GOODBOY008 GOODBOY008 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@htazq LGTM

@GOODBOY008 GOODBOY008 merged commit e8d285b into GOODBOY008:main Jul 16, 2026
4 checks passed
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.

Moving a tab to a new group remounts terminals and restarts PTY sessions

2 participants