feat(desktop): cmd-click file paths opens in external editor#2903
Conversation
Cmd/ctrl-click on files in the file tree, search results, and changes view now opens in the configured external editor. Double-click no longer opens externally, freeing it for future pinning behavior.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughModifier-key clicks now immediately open files in the editor; normal single-clicks trigger activation (FileItem uses a 300ms delayed single-click/timer with cancellation); double-clicks still open in editor. Additionally, a terminal workspaceRun test suite was removed. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 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.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/components/FileItem/FileItem.tsx">
<violation number="1" location="apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/components/FileItem/FileItem.tsx:116">
P2: Clear any pending click timeout before handling cmd/ctrl-click; otherwise a queued single-click action can still run after opening in the external editor.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/components/FileTreeItem/FileTreeItem.tsx (1)
81-84: Keep modifier keyboard activation consistent with modifier clicks.After Lines 81-82 start routing Cmd/Ctrl-click to
onOpenInEditor(entry),Cmd/Ctrl+Enterat Line 102 still goes throughonActivate(entry, true). That leaves the same shortcut doing different things depending on input method, and the same mismatch exists inFileSearchResultItem.tsxat Line 104.Also applies to: 92-103
🤖 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/WorkspaceView/RightSidebar/FilesView/components/FileTreeItem/FileTreeItem.tsx` around lines 81 - 84, The keyboard handler currently calls onActivate(entry, true) for Enter with modifiers while mouse Cmd/Ctrl-click calls onOpenInEditor(entry), so make modifier+Enter behave the same as modifier+click: update the Enter key handling in FileTreeItem (where Enter triggers onActivate(entry, true)) to check e.metaKey || e.ctrlKey and call onOpenInEditor(entry) instead; apply the same change in FileSearchResultItem (the Enter handler around Line 104) so both components route Cmd/Ctrl+Enter to onOpenInEditor(entry) for consistent behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/components/FileItem/FileItem.tsx`:
- Around line 116-119: The modifier-path currently calls openInEditor()
immediately on click causing it to fire twice on Cmd/Ctrl-double-click; instead
defer the modifier action and reuse the existing single-click debounce so
double-click can cancel it. Concretely, in the click handler (the branch that
checks e.metaKey || e.ctrlKey) replace the immediate openInEditor() with
scheduling the openInEditor call via the same timeout/ref used for plain clicks
(e.g., the click timeout ref used by handleDoubleClick) and ensure
handleDoubleClick clears that timeout and then invokes openInEditor once for the
confirmed double-click case; apply the same change pattern used in
FileTreeItem.tsx and FileSearchResultItem.tsx so modifier-clicks are
disambiguated from double-clicks.
---
Nitpick comments:
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/components/FileTreeItem/FileTreeItem.tsx`:
- Around line 81-84: The keyboard handler currently calls onActivate(entry,
true) for Enter with modifiers while mouse Cmd/Ctrl-click calls
onOpenInEditor(entry), so make modifier+Enter behave the same as modifier+click:
update the Enter key handling in FileTreeItem (where Enter triggers
onActivate(entry, true)) to check e.metaKey || e.ctrlKey and call
onOpenInEditor(entry) instead; apply the same change in FileSearchResultItem
(the Enter handler around Line 104) so both components route Cmd/Ctrl+Enter to
onOpenInEditor(entry) for consistent behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5590ba1d-4cd6-4fef-8528-4e899ebcd810
📒 Files selected for processing (3)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/components/FileItem/FileItem.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/components/FileSearchResultItem/FileSearchResultItem.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/components/FileTreeItem/FileTreeItem.tsx
| if (e.metaKey || e.ctrlKey) { | ||
| openInEditor(); | ||
| return; | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
In the DOM event model, when a user double-clicks an element, are two clickevents fired before thedblclickevent, and would an immediateclick handler run twice?
💡 Result:
Yes, in the DOM event model, when a user double-clicks an element, two click events are fired before the dblclick event fires. An immediate click event handler will run twice—once for each individual click in the double-click sequence.
Citations:
- 1: https://developer.mozilla.org/en-US/docs/Web/API/Element/dblclick_event
- 2: https://stackoverflow.com/questions/880608/prevent-click-event-from-firing-when-dblclick-event-fires
- 3: https://stackoverflow.com/questions/77943982/how-to-improve-javascript-click-dblclick-event-handling
- 4: https://api.jquery.com/dblclick/
- 5: https://www.quirksmode.org/dom/events/click.html
Cmd/Ctrl-double-click opens the editor twice.
When a user Cmd/Ctrl+double-clicks, the modifier branch (Lines 116–119) fires immediately on both click events before the dblclick event fires, invoking openInEditor() twice. The handleDoubleClick handler (Lines 134–142) only clears the deferred plain-click timeout, not the immediate modifier path. This same pattern exists in FileTreeItem.tsx (Line 82) and FileSearchResultItem.tsx (Line 89). Disambiguate single vs. double-click before firing the external-editor action in the modifier branch.
🤖 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/WorkspaceView/RightSidebar/ChangesView/components/FileItem/FileItem.tsx`
around lines 116 - 119, The modifier-path currently calls openInEditor()
immediately on click causing it to fire twice on Cmd/Ctrl-double-click; instead
defer the modifier action and reuse the existing single-click debounce so
double-click can cancel it. Concretely, in the click handler (the branch that
checks e.metaKey || e.ctrlKey) replace the immediate openInEditor() with
scheduling the openInEditor call via the same timeout/ref used for plain clicks
(e.g., the click timeout ref used by handleDoubleClick) and ensure
handleDoubleClick clears that timeout and then invokes openInEditor once for the
confirmed double-click case; apply the same change pattern used in
FileTreeItem.tsx and FileSearchResultItem.tsx so modifier-clicks are
disambiguated from double-clicks.
There was a problem hiding this comment.
3 issues found across 3 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/components/FileSearchResultItem/FileSearchResultItem.tsx">
<violation number="1">
P1: Double-click still opens the external editor; this reintroduces the old behavior instead of reserving double-click for future pinning.</violation>
</file>
<file name="apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/components/FileItem/FileItem.tsx">
<violation number="1">
P2: Double-click still opens the external editor, which contradicts the intended interaction change (only cmd/ctrl-click should open externally).</violation>
</file>
<file name="apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/components/FileTreeItem/FileTreeItem.tsx">
<violation number="1">
P2: Double-click still opens the external editor here, which contradicts the intended behavior that double-click should no longer open externally.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| @@ -85,7 +85,11 @@ export function FileSearchResultItem({ | |||
|
|
|||
There was a problem hiding this comment.
P1: Double-click still opens the external editor; this reintroduces the old behavior instead of reserving double-click for future pinning.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/components/FileSearchResultItem/FileSearchResultItem.tsx, line 97:
<comment>Double-click still opens the external editor; this reintroduces the old behavior instead of reserving double-click for future pinning.</comment>
<file context>
@@ -94,7 +94,7 @@ export function FileSearchResultItem({
const handleDoubleClick = () => {
- // Reserved for future pinning behavior
+ onOpenInEditor(entry);
};
</file context>
| @@ -111,17 +111,25 @@ export function FileItem({ | |||
|
|
|||
There was a problem hiding this comment.
P2: Double-click still opens the external editor, which contradicts the intended interaction change (only cmd/ctrl-click should open externally).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/components/FileItem/FileItem.tsx, line 144:
<comment>Double-click still opens the external editor, which contradicts the intended interaction change (only cmd/ctrl-click should open externally).</comment>
<file context>
@@ -131,15 +131,20 @@ export function FileItem({
+ clickTimeoutRef.current = null;
+ }
+
+ openInEditor();
+ },
+ [openInEditor],
</file context>
| @@ -78,8 +78,10 @@ export function FileTreeItem({ | |||
| } else { | |||
There was a problem hiding this comment.
P2: Double-click still opens the external editor here, which contradicts the intended behavior that double-click should no longer open externally.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/components/FileTreeItem/FileTreeItem.tsx, line 90:
<comment>Double-click still opens the external editor here, which contradicts the intended behavior that double-click should no longer open externally.</comment>
<file context>
@@ -87,6 +87,7 @@ export function FileTreeItem({
const handleDoubleClick = (e: React.MouseEvent) => {
e.stopPropagation();
+ onOpenInEditor(entry);
};
</file context>
There was a problem hiding this comment.
♻️ Duplicate comments (2)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/components/FileSearchResultItem/FileSearchResultItem.tsx (1)
88-92:⚠️ Potential issue | 🟠 MajorModifier-click + double-click flow still causes repeated external opens and keeps deprecated dblclick behavior.
Line [88] opens in editor immediately for Cmd/Ctrl-click, and Line [97] still opens on double-click. This can fire multiple external-editor launches on Cmd/Ctrl-double-click, and it conflicts with the PR objective that double-click should no longer open in the external editor.
Also applies to: 96-98
🤖 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/WorkspaceView/RightSidebar/FilesView/components/FileSearchResultItem/FileSearchResultItem.tsx` around lines 88 - 92, The click/double-click handlers in FileSearchResultItem are causing modifier+double-click to open the external editor twice and still allow double-click to open the editor; update the handlers so only a plain click activates (call onActivate(entry)) and modifier-click (e.metaKey || e.ctrlKey) on a single click calls onOpenInEditor(entry), but ensure the double-click handler no longer calls onOpenInEditor—either remove the dblclick invocation or have it check event.detail and skip calling onOpenInEditor when detail > 1; modify the click handler logic around the existing if (e.metaKey || e.ctrlKey) { onOpenInEditor(entry); } else { onActivate(entry); } and remove/adjust any onDoubleClick behavior so double-click does not open the external editor.apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/components/FileItem/FileItem.tsx (1)
114-119:⚠️ Potential issue | 🟠 MajorUnresolved multi-open regression on Cmd/Ctrl-double-click in
FileItem.Line [116] triggers immediate external open, and Line [144] opens again on dblclick. This can invoke multiple external opens for one Cmd/Ctrl-double-click, and dblclick is still wired to open editor despite the PR objective.
Suggested direction
const handleClick = useCallback( (e: React.MouseEvent) => { - if (e.metaKey || e.ctrlKey) { - openInEditor(); - return; - } + const openExternally = e.metaKey || e.ctrlKey; if (clickTimeoutRef.current) { clearTimeout(clickTimeoutRef.current); clickTimeoutRef.current = null; } clickTimeoutRef.current = setTimeout(() => { clickTimeoutRef.current = null; - onClick(); + if (openExternally) { + openInEditor(); + return; + } + onClick(); }, 300); }, [onClick, openInEditor], ); const handleDoubleClick = useCallback( (e: React.MouseEvent) => { e.preventDefault(); e.stopPropagation(); if (clickTimeoutRef.current) { clearTimeout(clickTimeoutRef.current); clickTimeoutRef.current = null; } - openInEditor(); + // Intentionally no external-open on double-click. + // Reserved for future pinning behavior. }, - [openInEditor], + [], );Also applies to: 134-145
🤖 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/WorkspaceView/RightSidebar/ChangesView/components/FileItem/FileItem.tsx` around lines 114 - 119, The click handler (handleClick) calls openInEditor when e.metaKey || e.ctrlKey but the double-click handler (onDoubleClick / the dblclick handler) also opens the editor, causing double opens on Cmd/Ctrl-double-click; modify the double-click handler to check for modifier keys and return early if e.metaKey || e.ctrlKey (i.e., do not call openInEditor on dblclick when modifiers are pressed), or alternatively set/consume a short-lived flag in handleClick when opening via modifier and have the dblclick handler ignore the event if that flag is set; update the handlers referencing openInEditor and the dblclick logic so a single Cmd/Ctrl-double-click only triggers one external open.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/components/FileItem/FileItem.tsx`:
- Around line 114-119: The click handler (handleClick) calls openInEditor when
e.metaKey || e.ctrlKey but the double-click handler (onDoubleClick / the
dblclick handler) also opens the editor, causing double opens on
Cmd/Ctrl-double-click; modify the double-click handler to check for modifier
keys and return early if e.metaKey || e.ctrlKey (i.e., do not call openInEditor
on dblclick when modifiers are pressed), or alternatively set/consume a
short-lived flag in handleClick when opening via modifier and have the dblclick
handler ignore the event if that flag is set; update the handlers referencing
openInEditor and the dblclick logic so a single Cmd/Ctrl-double-click only
triggers one external open.
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/components/FileSearchResultItem/FileSearchResultItem.tsx`:
- Around line 88-92: The click/double-click handlers in FileSearchResultItem are
causing modifier+double-click to open the external editor twice and still allow
double-click to open the editor; update the handlers so only a plain click
activates (call onActivate(entry)) and modifier-click (e.metaKey || e.ctrlKey)
on a single click calls onOpenInEditor(entry), but ensure the double-click
handler no longer calls onOpenInEditor—either remove the dblclick invocation or
have it check event.detail and skip calling onOpenInEditor when detail > 1;
modify the click handler logic around the existing if (e.metaKey || e.ctrlKey) {
onOpenInEditor(entry); } else { onActivate(entry); } and remove/adjust any
onDoubleClick behavior so double-click does not open the external editor.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 61e7b40f-645c-490f-9a18-0842682603f9
📒 Files selected for processing (3)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/ChangesView/components/FileItem/FileItem.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/components/FileSearchResultItem/FileSearchResultItem.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/components/FileTreeItem/FileTreeItem.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/FilesView/components/FileTreeItem/FileTreeItem.tsx
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Summary
Test plan
Summary by cubic
Cmd/ctrl-click on files now opens them in the configured external editor across the file tree, search results, and changes views. Double-click still opens in the external editor; single-click still opens in the viewer.
workspaceRuntests with drifted mocks (apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/hooks/workspaceRun.test.ts).Written for commit 45c3396. Summary will update on new commits.
Summary by CodeRabbit