Repository navigation
Avoid crash when creating a new workspace - #2023
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughRefactored TabManager.newTabInsertIndex to compute pinned count, selected index, and selected-is-pinned in a single pass over a snapshot of tabs; added a unit test verifying workspace insertion with placementOverride: .afterCurrent. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 crash that could occur when creating a new workspace with the
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[newTabInsertIndex called] --> B[Get placement & tabs]
B --> C[Single-pass loop over tabs]
C --> D{tab.isPinned?}
D -- Yes --> E[pinnedCount += 1]
D -- No --> F[no-op]
E --> G{selectedIndex == nil\n& tab.id == selectedTabId?}
F --> G
G -- Yes --> H[selectedIndex = index\nselectedIsPinned = tab.isPinned]
G -- No --> I[continue]
H --> I
I --> C
C -- done --> J[insertionIndex placement]
J --> K{placement}
K -- .top --> L[return pinnedCount]
K -- .end --> M[return totalCount]
K -- .afterCurrent --> N{selectedIndex set?}
N -- No --> O[return totalCount]
N -- Yes --> P{selectedIsPinned?}
P -- Yes --> Q[return pinnedCount]
P -- No --> R["return min(selectedIndex+1, totalCount)"]
Reviews (1): Last reviewed commit: "Avoid crash in workspace insert index" | Re-trigger Greptile |
…kspace-insert-index-crash Avoid crash when creating a new workspace
Summary
TabManager.newTabInsertIndex(snapshot:placementOverride:)to compute pinned count and selected state in one pass without the crash-prone optional/index lookup pathTesting
xcodebuild build-for-testing -project /Users/lawrence/fun/cmuxterm-hq/worktrees/task-fix-add-workspace-insert-index-crash/GhosttyTabs.xcodeproj -scheme cmux-unit -destination 'platform=macOS' -only-testing:cmuxTests/WorkspaceCreationPlacementTests/testAddWorkspaceAfterCurrentOverrideAppendsAfterLastSelectedWorkspace -derivedDataPath /tmp/cmux-task-fix-add-workspace-insert-index-crash-tests(passed)CMUX_SOCKET_PATH=/tmp/cmux-debug-fix-insert-index-crash.sock /tmp/cmux-cli new-workspace ...with repeated tagged-socket workspace creation andlist-workspaceschecks (no crash, tagged app stayed responsive)xcodebuild test -project /Users/lawrence/fun/cmuxterm-hq/worktrees/task-fix-add-workspace-insert-index-crash/GhosttyTabs.xcodeproj -scheme cmux-unit -destination 'platform=macOS' -only-testing:cmuxTests/WorkspaceCreationPlacementTests/testAddWorkspaceAfterCurrentOverrideAppendsAfterLastSelectedWorkspace -derivedDataPath /tmp/cmux-task-fix-add-workspace-insert-index-crash-tests(runner crashed before establishing connection, unrelated AppKit/test-host failure)Issues
Summary by cubic
Prevent a crash when creating a new workspace with 'after current' placement when the selected workspace is last. Simplifies insert-index logic to append safely and preserve tab order.
TabManager.newTabInsertIndex, removing optional/index lookup crash.testAddWorkspaceAfterCurrentOverrideAppendsAfterLastSelectedWorkspaceto assert order is preserved and the new workspace is appended last.Written for commit 4f5a317. Summary will update on new commits.
Summary by CodeRabbit
Performance Improvements
Tests