fix(terminal): number tabs by creation order, not visual position#956
fix(terminal): number tabs by creation order, not visual position#956chr1syy wants to merge 1 commit intoRunMaestro:rcfrom
Conversation
When a user clicks back to an AI tab and then opens a 2nd terminal, addTerminalTab inserts the new terminal directly after the active AI tab — visually to the LEFT of the existing terminal. The TabBar computed "Terminal N" labels from visual order, so the new tab became "Terminal 1" and the original was renamed to "Terminal 2". Pre-compute a terminalIndexById map sorted by createdAt and use it when resolving the display name. This matches the storage-order indexing already used in MainPanel and AppSessionModals. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughTerminal tabs in unified mode are now numbered by creation order rather than visual position in the tabs array. This is implemented via a memoized ChangesTerminal Tab Numbering by Creation Order
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested Labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 terminal tab mislabeling bug where opening a second terminal while an AI tab is active caused the new terminal to appear as "Terminal 1" and the existing one to be renamed "Terminal 2". The fix replaces a visual-order Confidence Score: 5/5Safe to merge — the change is narrowly scoped to terminal tab label computation with no side-effects on tab state or ordering. The fix is straightforward: one well-bounded useMemo replaces a single findIndex call, the createdAt field is a required non-nullable number on TerminalTab, and a targeted regression test validates the exact failure scenario. The only leftover is a now-harmless dead ternary guard at line 544. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["unifiedTabs prop changes"] --> B["allTabs = unifiedTabs ?? []"]
B --> C["useMemo: build terminalIndexById"]
C --> D["Filter allTabs for type === 'terminal'"]
D --> E["Sort filtered terminals by createdAt (ascending)"]
E --> F["Map: id → sorted index (0, 1, 2…)"]
F --> G["Render loop over allTabs"]
G -->|terminal tab| H["terminalIndex = terminalIndexById.get(id) ?? 0"]
H --> I["TerminalTabItem rendered as 'Terminal N+1'"]
G -->|ai/file/browser tab| J["Render other tab type"]
|
|
Thanks for the contribution, @chr1syy! Nice clean fix — the Approving as-is. One tiny non-blocking nit if you want to tidy up in a follow-up: the existing |
Summary
TabBar.tsxcomputed theTerminal Nindex from the visualunifiedTabsorder, butaddTerminalTabinserts the new terminal directly after the currently-active tab — placing it visually to the LEFT of the existing terminal when an AI tab is activefindIndexwith auseMemo-cachedterminalIndexByIdmap sorted bydata.createdAt, aligning TabBar with the storage-order indexing already used inMainPanel.tsxandAppSessionModals.tsxTest plan
TabBar.test.tsxrenders a unified tab list where the newer terminal sits before the older one in visual order, asserts older stays "Terminal 1" / newer becomes "Terminal 2"🤖 Generated with Claude Code
Summary by CodeRabbit