Repository navigation
Conversation
📝 WalkthroughWalkthrough
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description covers the required sections, explains the fix and rationale, links issue 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.
🧹 Nitpick comments (1)
src/renderer/src/components/tab-group/TabGroupPanel.close-file-entity-id.test.ts (1)
3-12: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueShorten the regression comment.
Keep the issue ID and the
entityIdcondition. The test name and assertions already define the failure and expected result.Suggested change
-// Regression for `#16205`: a document (editor) tab's X button / "Close" menu item / -// Cmd+W silently no-oped. TabGroupPanel wired onCloseFile straight to -// commands.closeItem, which only matches a unified tab by its own id -// (groupTabs.find(candidate => candidate.id === itemId)) — unlike every sibling -// close handler in this file (onClose, onCloseOthers, onCloseToRight, -// onCloseToLeft, onCloseBrowserTab), which all resolve the incoming id through -// resolveGroupTabFromVisibleId first, because callers can emit either the -// unified tab id or the file's entityId. This test drives onCloseFile with the -// file's entityId (the shape a file-explorer/palette close path emits) and -// asserts the tab actually closes. +// Regression for `#16205`: close a document tab when the caller emits its entityId.Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a6f49da2-bb62-42b5-8123-ed83aa987655
📒 Files selected for processing (2)
src/renderer/src/components/tab-group/TabGroupPanel.close-file-entity-id.test.tssrc/renderer/src/components/tab-group/TabGroupPanel.tsx
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
ELI5
Closing a Markdown/HTML document tab (its X button, the context-menu Close, or Cmd+W) could silently do nothing, so duplicate tabs piled up. This makes document tabs close reliably.
What Changed
In
TabGroupPanel.tsx, every close handler for the unified-tab strip resolves the incoming id throughresolveGroupTabFromVisibleId(model.groupTabs, visibleId), which matches either the unified tab's ownidor itsentityId(the tab bar emitsentityIdfor terminals/browsers but the unified id for editors).onCloseFile- the handler behind a document tab's X, the context-menu Close, and Cmd+W - was the one exception: it was bound directly tocommands.closeItem, a strictgroupTabs.find(t => t.id === itemId)with noentityIdfallback. When that path is fed the file'sentityId, the strict match fails and the callback silently returns (no error, no toast) - exactly the reported symptom.Fix: wrap
onCloseFilewith the sameresolveGroupTabFromVisibleIdresolution its sibling close handlers already use.Why
The close wiring had a single id-resolution asymmetry; aligning
onCloseFilewith its siblings removes the silent no-op and the duplicate-tab pileup, with no behavior change for the paths that already worked.Linked Issue
Fixes #16205
Visual Proof
N/A for static screenshots (the bug is a no-op). Repro: open a Markdown/HTML doc tab, trigger Close via the X / context menu / Cmd+W in a state where the file's
entityIdis emitted; before, the tab stays and re-opening stacks duplicates; after, it closes.Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
New
TabGroupPanel.close-file-entity-id.test.ts: mounts the realTabGroupPanelagainst a real Zustand store, opens a markdown file, drivesonCloseFilewith the file'sentityId. Fails before the fix, passes after.pnpm vitest runontab-bar+tab-group+ close-lifecycle dirs: 522/522 pass.pnpm typecheckexit 0.AI Disclosure
Implemented with Claude Code (Anthropic; Claude Sonnet). Root-cause analysis, the fix, and the tests were AI-generated and human-reviewed before opening.
Review
Agent skill upstream boundary
Notes
Investigated a possible link to #16225 (mirrored tab-id normalization) and found it separate: that is a terminal-surface-id prefix scheme; mirrored editor tabs use the host's raw tab id directly. This fix is local to the tab-close id-resolution contract.
Checklist
N/Awith reasonpnpm typecheck,pnpm testpass locally (CI covers build)Author