Repository navigation
Fix Cmd+N crash from stale workspace creation snapshots - #2133
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughRefactored workspace-creation snapshotting by replacing a full tab array with lightweight Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Greptile SummaryThis PR fixes a Cmd+N crash ( Key changes:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User as User (Cmd+N)
participant TM as TabManager
participant Snap as WorkspaceCreationSnapshot
participant Live as Live tabs[]
User->>TM: addWorkspace()
TM->>Snap: workspaceCreationSnapshot()<br/>(copies IDs, isPinned, workingDir, config)
Note over Snap: No live Workspace refs retained
TM->>TM: didCaptureWorkspaceCreationSnapshot()
Note over TM,Live: Post-snapshot window:<br/>workspace may be closed/reordered here
TM->>Live: newTabInsertIndex(snapshot, liveTabs: tabs)
Note over Live: pinnedCount, selectedIndex<br/>computed from current live tabs
Note over Snap: selectedTabId, selectedTabWasPinned<br/>read from snapshot (pre-creation intent)
TM->>TM: makeWorkspaceForCreation(...)
TM->>Live: var updatedTabs = tabs (live)
TM->>Live: updatedTabs.insert(newWorkspace, at: insertIndex)
TM->>TM: tabs = updatedTabs
Note over Live: Stale closed workspaces<br/>never reintroduced ✓
Reviews (1): Last reviewed commit: "Fix Cmd+N crash from stale workspace cre..." | Re-trigger Greptile |
| #if DEBUG | ||
| maybeMutateSelectionDuringWorkspaceCreationForDev(snapshot: snapshot) | ||
| #endif | ||
| let nextTabCount = snapshot.tabs.count + 1 |
There was a problem hiding this comment.
Stale tab count used for title and Sentry breadcrumb
nextTabCount is derived from snapshot.tabs.count, which reflects the tab count at snapshot capture time. In the exact race this PR is fixing — where a workspace is closed between snapshot and insertion — nextTabCount will be one higher than the actual live count, resulting in a workspace titled "Terminal N" while only N-1 tabs exist. The Sentry breadcrumb on the next line also reports the inflated count.
Since insertion now operates on tabs (live), the title and breadcrumb could use the live count at that point for accuracy:
| let nextTabCount = snapshot.tabs.count + 1 | |
| let nextTabCount = tabs.count + 1 |
This is cosmetic-only, but it would prevent misleading Sentry breadcrumbs in the post-snapshot-close race.
…-crash-regression Fix Cmd+N crash from stale workspace creation snapshots
Summary
WorkspaceCreationSnapshotfrom retaining liveWorkspaceobjects and other teardown-sensitive statetabsarray so post-snapshot closes/reorders are preserved instead of resurrecting stale workspacesContext
The
#2017fix stabilizedtabs/selectedTabIdreads during workspace creation, butWorkspaceCreationSnapshotstill retained liveWorkspacereferences andaddWorkspacerebuilttabsfrom the snapshotted array. That left a stale-object path open: if a workspace was closed or torn down after snapshot capture but before insertion, Cmd+N could reintroduce dead workspace objects and eventually trip the PAC failure reported in#2131.This change snapshots only value state needed for placement/config inheritance and computes insertion against the live workspace list while preserving the pre-creation selection intent.
Closes #2131
Validation
./scripts/reload.sh --tag issue2131-cmdn-crash --launchSummary by cubic
Fixes a Cmd+N crash by snapshotting only value state and inserting the new workspace into the live
tabsarray so closed/reordered tabs aren’t resurrected. Closes #2131.Workspacereferences withWorkspaceCreationTabSnapshot(id,isPinned).selectedTabId,selectedTabWasPinned,preferredWorkingDirectory, andinheritedTerminalConfig.tabs; insert into the live array to preserve post-snapshot closes/reorders and selection intent..afterCurrentwhen the selected tab closes after snapshot (fallback based on pin state).didCaptureWorkspaceCreationSnapshot()test seam and regression tests to ensure closed tabs aren’t reinserted and selection remains correct.Written for commit 17e8bb1. Summary will update on new commits.
Summary by CodeRabbit
Refactor
Tests