feat(desktop): add clear terminal option to right-click context menu#308
feat(desktop): add clear terminal option to right-click context menu#308
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
dcebabb to
dc4b33a
Compare
|
Warning Rate limit exceeded@Kitenite has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 23 minutes and 41 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThis pull request introduces a terminal clear feature by establishing a Zustand-backed callback system. A new store manages pane-to-callback mappings, the Terminal component registers its clear handler, TabPane retrieves and invokes callbacks, and a "Clear Terminal" context menu item with ⌘K shortcut is added to the UI. Changes
Sequence DiagramsequenceDiagram
participant User
participant ContextMenu as TabContentContextMenu
participant TabPane as TabPane
participant Store as TerminalCallbacksStore
participant Terminal as Terminal Component
User->>ContextMenu: Click "Clear Terminal"
ContextMenu->>TabPane: onClearTerminal()
TabPane->>Store: getClearCallback(paneId)
Store-->>TabPane: callback: () => void
TabPane->>callback: invoke()
callback->>Terminal: handleClear()
Terminal->>Terminal: xterm.clear()
Terminal->>Terminal: xterm.clearScrollback()
Terminal-->>User: Terminal cleared
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
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 |
Add "Clear Terminal" as a context menu option accessible via right-click, mirroring the existing CMD+K keyboard shortcut functionality. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
dc4b33a to
b260b97
Compare
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx (1)
85-90: Consider updating refs consistently with the established pattern.While these refs work correctly (Zustand store methods are stable), the pattern is inconsistent with other refs in this file. Lines 74-83 show that mutation refs are both initialized and updated:
const createOrAttachRef = useRef(createOrAttachMutation.mutate); // ... createOrAttachRef.current = createOrAttachMutation.mutate;For consistency, consider adding updates for these refs as well, even though it's not strictly necessary.
const registerClearCallbackRef = useRef( useTerminalCallbacksStore.getState().registerClearCallback, ); const unregisterClearCallbackRef = useRef( useTerminalCallbacksStore.getState().unregisterClearCallback, ); +registerClearCallbackRef.current = useTerminalCallbacksStore.getState().registerClearCallback; +unregisterClearCallbackRef.current = useTerminalCallbacksStore.getState().unregisterClearCallback;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabContentContextMenu.tsx(5 hunks)apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsx(3 hunks)apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx(4 hunks)apps/desktop/src/renderer/stores/tabs/terminal-callbacks.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
apps/desktop/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)
For Electron interprocess communication, ALWAYS use tRPC as defined in
src/lib/trpc
Files:
apps/desktop/src/renderer/stores/tabs/terminal-callbacks.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabContentContextMenu.tsx
apps/desktop/**/*.{ts,tsx}
📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)
apps/desktop/**/*.{ts,tsx}: Please use alias as defined intsconfig.jsonwhen possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary
Files:
apps/desktop/src/renderer/stores/tabs/terminal-callbacks.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabContentContextMenu.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Maintain type safety and avoid using
anyunless absolutely necessary in TypeScript code
Files:
apps/desktop/src/renderer/stores/tabs/terminal-callbacks.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabContentContextMenu.tsx
apps/desktop/src/renderer/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Never import Node.js modules in renderer process or shared code - only in src/main/
Files:
apps/desktop/src/renderer/stores/tabs/terminal-callbacks.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabContentContextMenu.tsx
**/components/**/[A-Z]*.tsx
📄 CodeRabbit inference engine (AGENTS.md)
Use one folder per component with structure ComponentName/ComponentName.tsx + index.ts barrel export
Files:
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabContentContextMenu.tsx
🧠 Learnings (2)
📚 Learning: 2025-12-08T23:32:32.232Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T23:32:32.232Z
Learning: Applies to apps/desktop/src/main/lib/terminal-*.ts : Use node-pty for terminal session management in the desktop app
Applied to files:
apps/desktop/src/renderer/stores/tabs/terminal-callbacks.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx
📚 Learning: 2025-12-08T23:32:32.232Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-08T23:32:32.232Z
Learning: Applies to apps/desktop/src/main/lib/*{workspace,worktree}-*.ts : Use git worktree-based workspace management in the desktop app through workspace-manager.ts and worktree-manager.ts
Applied to files:
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx
🧬 Code graph analysis (3)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsx (1)
apps/desktop/src/renderer/stores/tabs/terminal-callbacks.ts (1)
useTerminalCallbacksStore(10-34)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx (2)
apps/desktop/src/renderer/stores/tabs/terminal-callbacks.ts (1)
useTerminalCallbacksStore(10-34)apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/helpers.ts (1)
setupKeyboardHandler(181-244)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabContentContextMenu.tsx (1)
packages/ui/src/components/context-menu.tsx (2)
ContextMenuItem(244-244)ContextMenuShortcut(249-249)
🔇 Additional comments (5)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsx (1)
114-117: Implementation looks clean.The callback retrieval and optional chaining correctly handle the case where a callback might not be registered yet.
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx (1)
308-311: Callback lifecycle management is correct.The handleClear function is properly defined within the effect scope, registered with the store after initialization, and unregistered during cleanup. The integration with the existing keyboard handler maintains backward compatibility with ⌘K.
Also applies to: 319-319, 323-323, 351-351
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabContentContextMenu.tsx (2)
54-58: Clear Terminal menu item implementation is correct.The Eraser icon, ⌘K shortcut display, and positioning before the separator align well with the PR objectives and maintain consistency with the existing keyboard shortcut functionality.
84-84: Label change improves clarity.Changing "Close Pane" to "Close Terminal" makes the context menu more terminal-specific and intuitive for users.
apps/desktop/src/renderer/stores/tabs/terminal-callbacks.ts (1)
1-34: Well-designed Zustand store following best practices.The implementation correctly:
- Uses Map for efficient paneId-to-callback lookups
- Maintains immutability by cloning the Map on updates
- Returns undefined for missing callbacks, allowing safe optional chaining in consumers
- Follows the pattern established by the existing pane-refs store
This aligns with the coding guideline to prefer Zustand for state management.
Summary
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.