Repository navigation
Restart the last terminal when quit is cancelled - #9492
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe change restores a fresh terminal when closing the last terminal window is cancelled after a child exit. It propagates a cancellation callback through close handling, validates terminal state before recovery, supports default-shell respawn, and adds regression coverage. ChangesTerminal child-exit recovery
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant TabManager
participant MainWindowController
participant AppDelegate
participant Workspace
TabManager->>AppDelegate: Pass recovery callback to window-close flow
AppDelegate->>MainWindowController: Store cancellation callback
MainWindowController->>AppDelegate: Provide callback during close
AppDelegate->>TabManager: Invoke callback when close is cancelled
TabManager->>Workspace: Respawn validated terminal surface
Workspace-->>TabManager: Return replacement surface
Possibly related PRs
Suggested reviewers: Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error)
✅ Passed checks (24 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmuxTests/TabManagerUnitTests.swift`:
- Around line 823-826: In the test setup around replayFile, add deferred cleanup
immediately after creating the temporary replay file so the file is removed
regardless of setup or assertion failures. Keep the existing write and
ownedSessionScrollbackReplayFileURL assignment unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: fb51c448-43f3-4b0d-8e2a-cd86c60f8a1b
📒 Files selected for processing (4)
Sources/AppDelegate.swiftSources/TabManager.swiftSources/Workspace.swiftcmuxTests/TabManagerUnitTests.swift
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmuxTests/TabManagerUnitTests.swift`:
- Around line 820-825: Update the test around
lastTerminalChildExitRecoveryAction to exercise cancellation through
closeMainWindowContainingTabId, takePendingCloseCancellationAction(), and
handleQuitShortcutWarning(onCancel:) instead of invoking the recovery closure
directly. Trigger the cancelled close transaction through those production
boundaries, then assert that the replacement terminal state is restored
correctly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 7ec1e891-a07e-48df-8fcb-63dbf0f1c9c4
📒 Files selected for processing (4)
Sources/App/MainWindowController.swiftSources/AppDelegate.swiftSources/TabManager.swiftcmuxTests/TabManagerUnitTests.swift
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmuxTests/LastTerminalChildExitRecoveryTests.swift`:
- Around line 26-31: Add a behavior-level regression test alongside the existing
test that invokes the real close flow through closeMainWindowContainingTabId,
including window.performClose(nil) and cancellation of quit confirmation. After
close handling completes, assert the replacement surface, restored focus, and
history-free state; retain the existing direct recovery-closure unit test.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 013199d6-ac3d-485f-8559-346de2d4dbaf
📒 Files selected for processing (3)
Sources/AppDelegate.swiftcmux.xcodeproj/project.pbxprojcmuxTests/LastTerminalChildExitRecoveryTests.swift
Summary
Testing
CloseWorkspaceCmdDUITests/testCtrlDOnOnlyTerminalCancelRespawnsThenQuitExitsAppRunning Background: https://github.com/manaflow-ai/cmux/actions/runs/30882992643 and https://github.com/manaflow-ai/cmux/actions/runs/30884258994cxdq9: Ctrl+D showed the quit sheet; Cancel removed seeded scrollback and old shell environment; a second Ctrl+D plus Quit removed the process and socketChecklist