feat(desktop): add "Open in Editor" action for worktrees#2999
Conversation
Add an "Open in Editor" context menu item to worktrees in both the sidebar and the all-workspaces list view. Uses the existing openFileInEditor tRPC mutation which resolves the user's configured default editor (project-level, then global fallback).
📝 WalkthroughWalkthroughThese changes add an "Open in Editor" feature to workspace context menus in the desktop renderer. New context menu items with external link icons are introduced, connected to handlers that invoke an Electron RPC mutation to open workspace files in an editor, with error toast notifications. Changes
Sequence DiagramsequenceDiagram
participant User
participant ContextMenu as Context Menu UI
participant Handler as Handler<br/>(handleOpenInEditor)
participant RPC as RPC Mutation<br/>(openFileInEditor)
participant Editor as Editor/System
User->>ContextMenu: Click "Open in Editor"
ContextMenu->>Handler: onOpenInEditor()
Handler->>RPC: mutate({ path, projectId })
alt Success
RPC->>Editor: Open file in editor
Editor-->>User: Editor window opens
else Error
RPC-->>Handler: Error returned
Handler-->>User: Toast notification with error
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/desktop/src/renderer/screens/main/components/WorkspacesListView/WorkspaceRow/WorkspaceRow.tsx (1)
44-56: Consider disabling the menu item whenworktreePathis unavailable.The handler silently no-ops when
workspace.worktreePathis falsy, but the menu item remains enabled. For better UX, consider disabling the menu item when the path is unavailable, consistent with howcanDeletedisables the delete action.💡 Suggested improvement
<ContextMenuItem onSelect={handleOpenInEditor} + disabled={!workspace.worktreePath} > <LuExternalLink className="size-4 mr-2" strokeWidth={STROKE_WIDTH} /> Open in Editor </ContextMenuItem>Also applies to: 211-217
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/desktop/src/renderer/screens/main/components/WorkspacesListView/WorkspaceRow/WorkspaceRow.tsx` around lines 44 - 56, The "Open in editor" menu item should be disabled when workspace.worktreePath is falsy: update the menu rendering that currently calls handleOpenInEditor (which uses openFileInEditor.mutate) to add a disabled prop tied to !workspace.worktreePath (similar to how canDelete is used for delete). Locate the code around WorkspaceRow where handleOpenInEditor and openFileInEditor are defined and mirror that change for the other occurrence later in the file (the second "Open in editor" menu item), ensuring the UI disables the action when workspace.worktreePath is unavailable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@apps/desktop/src/renderer/screens/main/components/WorkspacesListView/WorkspaceRow/WorkspaceRow.tsx`:
- Around line 44-56: The "Open in editor" menu item should be disabled when
workspace.worktreePath is falsy: update the menu rendering that currently calls
handleOpenInEditor (which uses openFileInEditor.mutate) to add a disabled prop
tied to !workspace.worktreePath (similar to how canDelete is used for delete).
Locate the code around WorkspaceRow where handleOpenInEditor and
openFileInEditor are defined and mirror that change for the other occurrence
later in the file (the second "Open in editor" menu item), ensuring the UI
disables the action when workspace.worktreePath is unavailable.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4526ead9-f9f8-469e-8fd6-e481c560e6dc
📒 Files selected for processing (3)
apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceContextMenu.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsxapps/desktop/src/renderer/screens/main/components/WorkspacesListView/WorkspaceRow/WorkspaceRow.tsx
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Summary
WorkspaceContextMenu) and the all-workspaces list view (WorkspaceRow)openFileInEditortRPC mutation which resolves the user's configured default editor (project-level first, then global fallback)Test plan
shell.openPathSummary by cubic
Adds an "Open in Editor" action to worktree context menus so you can jump into your editor from the sidebar and All Workspaces view. Uses the configured default editor (project-level first, then global).
WorkspaceContextMenuandWorkspaceRowcontext menus; sits between "Open in Finder" and "Copy Path" in the sidebar.electronTrpc.external.openFileInEditorto open the worktree path; shows a toast on errors.Written for commit 547c928. Summary will update on new commits.
Summary by CodeRabbit
Release Notes