Fix restored browser split portal after Cmd-D
Summary
- add behavior coverage for a restored persistent SSH workspace with a left terminal pane and right browser pane
- rearm browser portal-host replacement across the whole workspace after split topology changes, not only the two panes directly involved in the split
Verification
- Red: cloud Mac
xcodebuild -project cmux.xcodeproj -scheme cmux-unit -configuration Debug -destination platform=macOS -derivedDataPath /tmp/cmux-4893-red test -only-testing:cmuxTests/TabManagerSessionSnapshotTests/testRestoredPersistentSSHBrowserSiblingAcceptsPortalHostAfterTerminalSplitfailed on commit4ddcc80a6at the post-split browser portal-host claim - Green: same focused cloud Mac command passed on commit
88648bbfe - Local tagged reload:
./scripts/reload.sh --tag 4893-cmd-d-browser
Closes https://github.com/manaflow-ai/cmux/issues/4893
Need help on this PR? Tag @codesmith with what you need. Autofix is disabled.
[!NOTE]
Medium Risk
Touches split/restore paths for remote SSH terminals and browser portal claiming; behavior is covered by new session-restore tests but affects live split topology and Ghostty startup config.
Overview
Fixes Cmd‑D terminal splits in restored persistent SSH workspaces so sibling browser panes can reclaim a portal host after topology changes, and so remote attach/fork startup does not send a local cwd into Ghostty (which mis-handles inline scripts as relative paths).
Portal hosts: After any split, browser panels across all panes are rearmed for the next distinct portal claim (deduped per panel), not only the two panes directly involved in the split.
Remote terminal creation: Shared terminalConfigTemplateForStartupCommand sets waitAfterCommand and clears inherited workingDirectory when the split uses the workspace’s remote startup command. The new surface gets workingDirectory: nil while the intended path is stored via updatePanelDirectory; failed splits/tabs also drop stale panelDirectories entries.
Tests: Restored terminal|browser layout accepts a replacement portal host after a terminal split; restored SSH Cmd‑D split keeps ssh-pty-attach without requestedWorkingDirectory but preserves cwd in panelDirectories.
Reviewed by Cursor Bugbot for commit 0d8f8f322a3bd1e75fe169799ea525c086ff6d7a. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
Fixes browser portal reattachment after Cmd‑D splits in restored persistent SSH workspaces and prevents sending a local cwd to Ghostty for remote‑startup splits (attach and fork). Also consolidates remote‑startup config into a shared helper; portal rearming scans all panes (deduped), and SSH splits track cwd in panel state instead of Ghostty config (addresses #4893).
- Bug Fixes
- Rearm browser portal-host replacement across the whole workspace after split topology changes; dedupe per browser panel.
- For remote‑startup terminal splits (
ssh-pty-attach, remote fork): clear inherited/surface cwd; record cwd viaupdatePanelDirectory; clean uppanelDirectorieson failure. - Tests: restored terminal|browser layout reclaims a portal host after a terminal split; restored SSH Cmd‑D split sets no local cwd.
Summary by CodeRabbit
-
Bug Fixes
- Terminal splits and new terminals now correctly handle remote startup commands by avoiding unintended working-directory inheritance.
- Panel directory updates are applied only when appropriate, reducing redundant updates.
- Cleanup now removes stale panel directory metadata when terminal panel creation fails.
- Improved browser portal handling during splits to prevent duplicate processing of browser panels.
-
Tests
- Added tests for persistent-SSH workspace restores, verifying terminal split behavior, directory handling, and browser portal claim consistency.
- Test helpers updated to support restored workspace directories.