Repository navigation
CMD+W to close tab - #92
Conversation
WalkthroughThis change introduces a terminal close feature accessible via Cmd+W keyboard shortcut. It extends the shortcuts system with a new closeTerminal handler, threads workspace and worktree context through the component hierarchy to Terminal, and implements tab deletion via IPC when the shortcut is invoked. Documentation is updated to reflect the new shortcut. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant System as Keyboard System
participant Terminal as Terminal Component
participant IPC as IPC Renderer
participant Main as Main Process
User->>System: Press Cmd+W
System->>Terminal: Trigger closeTerminal shortcut handler
Terminal->>Terminal: Check terminalId, workspaceId, worktreeId available
Terminal->>IPC: invoke("tab-delete", {workspaceId, worktreeId, tabId})
IPC->>Main: Forward tab-delete request
Main->>Main: Delete tab
Main-->>IPC: Success/Error response
IPC-->>Terminal: Handle response (log if error)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
AGENTS.md (1)
262-265: Clarify overlap between tab Cmd+W and terminal Cmd+W in docsYou now list
Cmd+Wboth for closing tabs and for closing the current terminal. If the behavior is effectively “close the active tab (including terminal tabs)”, consider clarifying the wording or adding a brief note so users don’t wonder if these are distinct actions.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
AGENTS.md(1 hunks)apps/desktop/src/renderer/lib/shortcuts.ts(3 hunks)apps/desktop/src/renderer/screens/main/components/MainContent/TabContent.tsx(1 hunks)apps/desktop/src/renderer/screens/main/components/MainContent/Terminal.tsx(3 hunks)
🔇 Additional comments (4)
apps/desktop/src/renderer/screens/main/components/MainContent/TabContent.tsx (1)
183-192: Terminal wiring for workspace/worktree IDs looks correct—confirm all call sitesPassing
workspaceIdandworktreeIdthrough toTerminalaligns with howTerminalTabContentalready uses them for CWD persistence and is consistent with the new close-terminal behavior.Please double‑check other
<Terminal>usages (if any outside this file) to ensure they either pass valid IDs or intentionally rely on the no‑op behavior when IDs are missing.apps/desktop/src/renderer/lib/shortcuts.ts (1)
26-29: New terminal close handler and Meta+W shortcut look good—check interaction with tab closeAdding
closeTerminaltoShortcutHandlersand wiring Meta+W increateTerminalShortcutsfollows the existing shortcut patterns and keeps the API tidy.Given that tab management already binds Meta+W to “Close current tab”, please confirm that when focus is inside the terminal:
- Only the intended close behavior runs once (no double tab‑delete), and
- Meta+W still closes terminal tabs even in any edge cases where
workspaceId/worktreeIdmight be missing.If needed, we can adjust event handling or fallback to tab‑level close to avoid swallowed keystrokes.
Also applies to: 182-208
apps/desktop/src/renderer/screens/main/components/MainContent/Terminal.tsx (2)
13-20: Props extension to carry workspace/worktree IDs into Terminal is straightforwardMaking
workspaceIdandworktreeIdoptional props onTerminaland threading them throughTerminalComponentmatches how they’re computed inTabContentand keeps the surface area small.Please confirm that
Terminalisn’t used in contexts where these IDs are required but not provided; in those cases, close behavior will depend on higher‑level tab shortcuts instead of the new terminal‑level handler.Also applies to: 75-82
185-212: closeTerminal shortcut IPC flow is reasonable—verify ID availability and lifecycleThe new
closeTerminalhandler correctly:
- Checks
terminalIdRef.current && workspaceId && worktreeId,- Calls
tab-deleteviaipcRenderer.invokewith{ workspaceId, worktreeId, tabId: terminalIdRef.current }, and- Logs failures without throwing.
This is a clean, localized way to close the backing tab from within the terminal.
Two edge cases worth validating in practice:
- For any terminal tab, ensure
workspaceIdandworktreeIdare always set so Meta+W actually closes it instead of becoming a no‑op that still consumes the shortcut.- If a terminal/tab can ever be moved between workspaces/worktrees without changing
terminalId, check that the captured IDs remain correct; if not, we may want to store them in refs and read from those insidecloseTerminal.
Changes Electron menu to use Cmd+Shift+W for closing windows (Arc-style), freeing up Cmd+W for renderer-side shortcuts to close tabs/terminals. **Changes:** - menu.ts: Replace default close with custom Cmd+Shift+W handler - Terminal.tsx: Enhance closeTerminal to dispatch workspace-changed event - Sidebar.tsx: Listen for workspace-changed events to refresh UI - AGENTS.md: Document new Window shortcuts section This prevents Cmd+W from closing the window and ensures it properly closes terminals without killing the shell process. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Refactored Cmd+W handling to work like VS Code - registers at window level so it works from anywhere (sidebar, terminal, etc). **Changes:** - MainScreen.tsx: Add global keyboard shortcuts listener - Handles Cmd+W at window level for all tabs - Dispatches workspace-changed event after tab deletion - Terminal.tsx: Simplified to only prevent Cmd+W from reaching shell - Removed IPC call handling (now done at window level) - Still prevents Cmd+W from being interpreted as Ctrl+W by shell - Kept Cmd+K for clear terminal This matches VS Code behavior where shortcuts work regardless of focus. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Since Cmd+W handling moved to window level (MainScreen), Terminal component no longer needs workspaceId/worktreeId props. **Changes:** - Terminal.tsx: Remove workspaceId and worktreeId from props interface - TabContent.tsx: Remove workspaceId and worktreeId from Terminal usage This follows the principle of using context providers instead of prop drilling for shared state. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Summary by CodeRabbit