Repository navigation
feat (desktop): replace lock with pinned files via cursor pattern - #636
Conversation
📝 WalkthroughWalkthroughThis PR replaces a lock/unlock paradigm for file viewer panes with a VS Code/Cursor-style preview system. File viewer panes now default to preview mode (replaceable) and can be pinned to become permanent. Changes include renaming schema fields from Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Sidebar as Sidebar<br/>(FileList)
participant FileViewerPane
participant TabsStore
participant Toolbar as FileViewerToolbar
rect rgb(230, 245, 240)
Note over User,TabsStore: Preview Mode (Single-Click)
User->>Sidebar: Single-click file
Sidebar->>TabsStore: addFileViewerPane(file, isPinned: false)
TabsStore->>FileViewerPane: Create/reuse pane (isPinned: false)
FileViewerPane->>Toolbar: Render with pin button
Toolbar->>User: Show italicized tab + "preview" label
end
rect rgb(245, 240, 230)
Note over User,TabsStore: Pin via Double-Click
User->>Sidebar: Double-click file
Sidebar->>TabsStore: addFileViewerPane(file, isPinned: true)
TabsStore->>FileViewerPane: Set isPinned: true
FileViewerPane->>Toolbar: Remove pin button, normalize tab
end
rect rgb(240, 245, 230)
Note over User,TabsStore: Auto-Pin on Edit
User->>FileViewerPane: Edit content (isDirty: true)
FileViewerPane->>FileViewerPane: Trigger useEffect
FileViewerPane->>TabsStore: pinPane(paneId)
TabsStore->>FileViewerPane: Set isPinned: true
FileViewerPane->>Toolbar: Update to pinned state
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
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 |
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Add explicit guard clause instead of non-null assertion to satisfy linter. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In
@apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileItem/FileItem.tsx:
- Around line 11-14: The FileItem component exposes onClick and onDoubleClick
handlers but lacks keyboard-accessible way to trigger the pin (double-click)
action; update FileItem.tsx to invoke the onDoubleClick logic from keyboard
events and visible controls: add a keydown handler on the file container that
listens for a chosen shortcut (e.g., Ctrl/Cmd+Enter and/or Enter with modifier)
and calls the existing onDoubleClick prop when focused, or render a focusable
pin button that becomes visible on focus/hover and calls onDoubleClick when
activated; ensure the container has appropriate tabIndex and ARIA attributes so
keyboard users can reach it and the onDoubleClick flow (refer to the onClick and
onDoubleClick props in FileItem).
In @apps/desktop/src/renderer/stores/tabs/store.ts:
- Around line 405-408: The isSameFile comparison in the AddFileViewerPane logic
currently checks existingFileViewer.filePath, existingFileViewer.diffCategory,
and existingFileViewer.commitHash but omits oldPath; update the isSameFile
expression to also compare existingFileViewer.oldPath === options.oldPath (and
ensure AddFileViewerPaneOptions includes oldPath where used) so panes opened for
renamed/copied files aren’t incorrectly treated as the same.
🧹 Nitpick comments (2)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/index.tsx (1)
12-36: Consider reducing duplication between the two handlers.Both
handleFileOpenandhandleFileOpenPinnedhave identical logic except for theisPinnedflag value. While the current implementation is clear and explicit, you could reduce duplication.🔎 Optional refactor to reduce duplication
- // Single click - opens in preview mode (can be replaced by next single click) - const handleFileOpen = workspaceId - ? (file: ChangedFile, category: ChangeCategory, commitHash?: string) => { - addFileViewerPane(workspaceId, { - filePath: file.path, - diffCategory: category, - commitHash, - oldPath: file.oldPath, - isPinned: false, - }); - } - : undefined; - - // Double click - opens pinned (permanent, won't be replaced) - const handleFileOpenPinned = workspaceId - ? (file: ChangedFile, category: ChangeCategory, commitHash?: string) => { - addFileViewerPane(workspaceId, { - filePath: file.path, - diffCategory: category, - commitHash, - oldPath: file.oldPath, - isPinned: true, - }); - } - : undefined; + const createFileOpenHandler = (isPinned: boolean) => + workspaceId + ? (file: ChangedFile, category: ChangeCategory, commitHash?: string) => { + addFileViewerPane(workspaceId, { + filePath: file.path, + diffCategory: category, + commitHash, + oldPath: file.oldPath, + isPinned, + }); + } + : undefined; + + // Single click - opens in preview mode (can be replaced by next single click) + const handleFileOpen = createFileOpenHandler(false); + // Double click - opens pinned (permanent, won't be replaced) + const handleFileOpenPinned = createFileOpenHandler(true);That said, the current explicit approach is perfectly reasonable and may be more maintainable if the handlers diverge in the future.
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/components/FileViewerToolbar/FileViewerToolbar.tsx (1)
105-121: Consider addingaria-labelto the pin button for accessibility.The button relies solely on a tooltip for context. Screen reader users may benefit from an explicit label.
Suggested improvement
<button type="button" onClick={onPin} + aria-label="Pin (keep open)" className="rounded p-0.5 text-muted-foreground/60 transition-colors hover:text-muted-foreground" > <TbPinFilled className="size-3" /> </button>
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (15)
apps/desktop/src/lib/trpc/routers/ui-state/index.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/FileViewerPane.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/components/FileViewerToolbar/FileViewerToolbar.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CommitItem/CommitItem.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileItem/FileItem.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileList.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListGrouped.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListTree.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/index.tsxapps/desktop/src/renderer/stores/tabs/store.tsapps/desktop/src/renderer/stores/tabs/types.tsapps/desktop/src/renderer/stores/tabs/utils.tsapps/desktop/src/shared/tabs-types.tsplans/preview-mode-implementation.md
🧰 Additional context used
📓 Path-based instructions (6)
apps/desktop/**/*.{ts,tsx}
📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)
apps/desktop/**/*.{ts,tsx}: For Electron interprocess communication, ALWAYS use tRPC as defined insrc/lib/trpc
Use alias as defined intsconfig.jsonwhen possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary.
For tRPC subscriptions with trpc-electron, ALWAYS use the observable pattern from@trpc/server/observableinstead of async generators, as the library explicitly checksisObservable(result)and throws an error otherwise
Files:
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileItem/FileItem.tsxapps/desktop/src/renderer/stores/tabs/types.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListTree.tsxapps/desktop/src/renderer/stores/tabs/utils.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileList.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/index.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsxapps/desktop/src/renderer/stores/tabs/store.tsapps/desktop/src/shared/tabs-types.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/FileViewerPane.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/components/FileViewerToolbar/FileViewerToolbar.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CommitItem/CommitItem.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListGrouped.tsxapps/desktop/src/lib/trpc/routers/ui-state/index.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use object parameters for functions with 2+ parameters instead of positional arguments
Functions with 2+ parameters should accept a single params object with named properties for self-documentation and extensibility
Use prefixed console logging with context pattern: [domain/operation] message
Extract magic numbers and hardcoded values to named constants at module top
Use lookup objects/maps instead of repeated if (type === ...) conditionals
Avoid usinganytype - maintain type safety in TypeScript code
Never swallow errors silently - at minimum log them with context
Import from concrete files directly when possible - avoid barrel file abuse that creates circular dependencies
Avoid deep nesting (4+ levels) - use early returns, extract functions, and invert conditions
Use named properties in options objects instead of boolean parameters to avoid boolean blindness
Files:
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileItem/FileItem.tsxapps/desktop/src/renderer/stores/tabs/types.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListTree.tsxapps/desktop/src/renderer/stores/tabs/utils.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileList.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/index.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsxapps/desktop/src/renderer/stores/tabs/store.tsapps/desktop/src/shared/tabs-types.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/FileViewerPane.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/components/FileViewerToolbar/FileViewerToolbar.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CommitItem/CommitItem.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListGrouped.tsxapps/desktop/src/lib/trpc/routers/ui-state/index.ts
apps/desktop/src/renderer/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Never import Node.js modules (fs, path, os, net) in renderer process or shared code - they are externalized for browser compatibility
Files:
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileItem/FileItem.tsxapps/desktop/src/renderer/stores/tabs/types.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListTree.tsxapps/desktop/src/renderer/stores/tabs/utils.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileList.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/index.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsxapps/desktop/src/renderer/stores/tabs/store.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/FileViewerPane.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/components/FileViewerToolbar/FileViewerToolbar.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CommitItem/CommitItem.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListGrouped.tsx
**/*.tsx
📄 CodeRabbit inference engine (AGENTS.md)
One component per file - do not create multi-component files
Files:
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileItem/FileItem.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListTree.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileList.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/index.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/FileViewerPane.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/components/FileViewerToolbar/FileViewerToolbar.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CommitItem/CommitItem.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListGrouped.tsx
apps/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use Drizzle ORM for all database operations - never use raw SQL
Files:
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileItem/FileItem.tsxapps/desktop/src/renderer/stores/tabs/types.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListTree.tsxapps/desktop/src/renderer/stores/tabs/utils.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileList.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/index.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsxapps/desktop/src/renderer/stores/tabs/store.tsapps/desktop/src/shared/tabs-types.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/FileViewerPane.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/components/FileViewerToolbar/FileViewerToolbar.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CommitItem/CommitItem.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListGrouped.tsxapps/desktop/src/lib/trpc/routers/ui-state/index.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use Biome for formatting and linting - run at root level with
bun run lint:fixorbiome check --write
Files:
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileItem/FileItem.tsxapps/desktop/src/renderer/stores/tabs/types.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListTree.tsxapps/desktop/src/renderer/stores/tabs/utils.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileList.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/index.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsxapps/desktop/src/renderer/stores/tabs/store.tsapps/desktop/src/shared/tabs-types.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/FileViewerPane.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/components/FileViewerToolbar/FileViewerToolbar.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CommitItem/CommitItem.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListGrouped.tsxapps/desktop/src/lib/trpc/routers/ui-state/index.ts
🧠 Learnings (1)
📚 Learning: 2026-01-02T06:50:28.671Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-02T06:50:28.671Z
Learning: Applies to apps/*/src/components/{ui,ai-elements,react-flow}/*.tsx : Use kebab-case single files for shadcn/ui components (e.g., button.tsx, base-node.tsx) in src/components/ui/, src/components/ai-elements, and src/components/react-flow/
Applied to files:
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileItem/FileItem.tsx
🧬 Code graph analysis (8)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListTree.tsx (1)
apps/desktop/src/shared/changes-types.ts (1)
ChangedFile(22-28)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileList.tsx (1)
apps/desktop/src/shared/changes-types.ts (1)
ChangedFile(22-28)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsx (1)
apps/desktop/src/shared/changes-types.ts (2)
ChangedFile(22-28)ChangeCategory(15-19)
apps/desktop/src/renderer/stores/tabs/store.ts (1)
apps/desktop/src/renderer/stores/tabs/utils.ts (1)
extractPaneIdsFromLayout(54-65)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/FileViewerPane.tsx (1)
apps/desktop/src/renderer/stores/tabs/store.ts (1)
useTabsStore(73-878)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/components/FileViewerToolbar/FileViewerToolbar.tsx (5)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/hooks/index.ts (1)
SplitOrientation(2-2)apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/hooks/useSplitOrientation/index.ts (1)
SplitOrientation(2-2)apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/hooks/useSplitOrientation/useSplitOrientation.ts (1)
SplitOrientation(3-3)packages/ui/src/lib/utils.ts (1)
cn(4-6)packages/ui/src/components/ui/tooltip.tsx (3)
Tooltip(76-76)TooltipTrigger(76-76)TooltipContent(76-76)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CommitItem/CommitItem.tsx (1)
apps/desktop/src/shared/changes-types.ts (1)
ChangedFile(22-28)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListGrouped.tsx (1)
apps/desktop/src/shared/changes-types.ts (1)
ChangedFile(22-28)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Deploy Admin
- GitHub Check: Deploy Web
- GitHub Check: Deploy Marketing
- GitHub Check: Deploy Docs
- GitHub Check: Deploy API
- GitHub Check: Build
🔇 Additional comments (18)
apps/desktop/src/shared/tabs-types.ts (1)
89-90: LGTM! Clean rename fromisLockedtoisPinned.The rename clearly reflects the new preview/pin paradigm, and the comment accurately describes the behavior.
apps/desktop/src/renderer/stores/tabs/types.ts (1)
50-51: LGTM! Well-documented API additions.The
isPinnedoption andpinPanemethod provide clear, type-safe control over the preview/pin behavior.Also applies to: 92-93
apps/desktop/src/renderer/stores/tabs/utils.ts (1)
105-106: LGTM! Consistent implementation of preview-by-default behavior.The default
isPinned: falsecorrectly implements the preview mode as the initial state for new file viewer panes, matching the VS Code/Cursor pattern described in the plan.Also applies to: 139-139
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/FileViewerPane.tsx (2)
55-55: LGTM! Clean integration of pinning behavior.The derived
isPinnedstate andhandlePinhandler correctly wire up the preview/pin functionality to the toolbar.Also applies to: 62-62, 141-143, 256-256, 263-263
106-111: Effect usage is justified for centralizing auto-pin logic.While the coding guidelines suggest avoiding effects when possible, this effect appropriately consolidates the auto-pin business rule in one place. The alternative would scatter
pinPanecalls acrosshandleEditorChange(line 90) andhandleDiffChange(line 113), duplicating the conditional logic.The effect clearly expresses: "when a file becomes dirty and is not pinned, pin it automatically."
Based on coding guidelines: "Do not use effect unless absolutely necessary."
plans/preview-mode-implementation.md (1)
1-230: All implementation phases have been completed and are functioning correctly.The original review incorrectly claims that several core features from the preview mode implementation plan are missing. However, verification shows comprehensive implementation across all major phases:
✓ Phase 1–3 (Core Logic): Type renaming (
isPinned), store logic for reusing unpinned panes, and auto-pin on edit (FileViewerPane.tsx:108–111)✓ Phase 4 (Double-click): Double-click handlers fully wired in FileItem.tsx, FileListTree.tsx, and FileListGrouped.tsx, threaded through ChangesView to Sidebar handlers
✓ Phase 5 (Click Handlers): Sidebar.tsx implements separate
handleFileOpen(preview mode,isPinned: false) andhandleFileOpenPinned(pinned,isPinned: true) callbacks passed to ChangesView✓ Phase 6 (Visual Indicators): FileViewerToolbar applies italic styling when
!isPinned, displays "preview" label with tooltip "Click again or double-click to pin"✓ Phase 7 (UI Updates): FileViewerToolbar has
isPinnedprop; pin button only renders when!isPinned; tap button hidden when already pinned✓ Same-file-click-to-pin logic: Implemented in addFileViewerPane via
isSameFilecheck (lines 407–410 in store.ts) that auto-pins when clicking the same file againThe implementation follows the plan precisely and is production-ready. Testing checklist items should all pass.
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileItem/FileItem.tsx (1)
74-74: Implementation looks correct.The
onDoubleClickhandler is properly wired to the native button element, which natively supports double-click events.apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CommitItem/CommitItem.tsx (1)
18-21: Clean implementation of double-click prop threading.The
onFileDoubleClickprop is correctly threaded through the component hierarchy, following the same pattern as the existingonFileSelecthandler. The wrapper function properly binds the commit hash, and optional chaining ensures safe handling when the callback is not provided.Also applies to: 46-46, 55-57, 95-95
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListGrouped.tsx (1)
10-13: Consistent prop threading throughout the component hierarchy.The
onFileDoubleClickprop is properly threaded through all three levels (FileListGrouped → FolderGroupItem → FileItem), following the same pattern as existing optional handlers likeonStageandonUnstage. The conditional handling and JSDoc comments are consistent with the rest of the codebase.Also applies to: 63-63, 74-74, 98-100, 115-115, 131-131
apps/desktop/src/lib/trpc/routers/ui-state/index.ts (1)
21-21: Migration strategy already implemented — no action required.The
isLocked→isPinnedmigration is already handled inapps/desktop/src/renderer/stores/tabs/store.ts(lines 845–855) via version-based migration logic. When the store detectsversion < 3, it automatically migrates existing persisted panes by renamingisLockedtoisPinnedand defaults old panes toisPinned: true. No backward compatibility issues exist.Likely an incorrect or invalid review comment.
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileList.tsx (1)
11-14: LGTM!The
onFileDoubleClickprop is cleanly added with helpful JSDoc comments distinguishing single-click (preview) from double-click (pinned) behavior. The optional prop is properly typed and consistently threaded to bothFileListTreeandFileListGroupedcomponents.Also applies to: 30-30, 47-47, 63-63
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListTree.tsx (1)
146-148: LGTM!The conditional callback
onFileDoubleClick ? () => onFileDoubleClick(file) : undefinedcorrectly guards against undefined props, and the pattern is consistent with howonClickis handled. The prop is properly threaded through all recursiveTreeNodeComponentcalls.apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsx (2)
146-176: LGTM!The double-click handlers correctly mirror the single-click handlers, updating selection state before invoking the pinned-open callback. The parallel structure between
handleFileSelect/handleFileDoubleClickandhandleCommitFileSelect/handleCommitFileDoubleClickis clear and maintainable.
279-281: Consistent wiring across all file categories.The
onFileDoubleClickhandler is properly wired to all four file list contexts (against-base, commits, staged, unstaged), maintaining consistency with the single-click pattern.Also applies to: 301-301, 340-342, 386-388
apps/desktop/src/renderer/stores/tabs/store.ts (3)
384-428: Well-structured preview pane reuse logic.The logic correctly handles the three cases:
- Same file clicked → pin the preview pane
- Different file clicked → replace preview content
- No reusable pane → create new one
The guard clause at lines 399-402 properly satisfies the type checker while being defensive.
652-672: LGTM!The
pinPaneaction has proper guards:
- No-op for unknown panes
- No-op for non-file-viewer panes
- No-op if already pinned
This prevents state corruption and is consistent with other store actions.
845-856: Migration logic correctly handles legacyisLockedfield.The migration from version 2 to 3 properly:
- Converts
isLocked→isPinned- Defaults to
truefor old panes (since they were explicitly opened before the preview paradigm)- Cleans up the legacy field
This ensures backward compatibility for users upgrading.
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/components/FileViewerToolbar/FileViewerToolbar.tsx (1)
47-67: Good UX with preview indicator and helpful tooltip.The italic styling and "preview" label clearly communicate the pane's ephemeral state, and the tooltip "Click again or double-click to pin" provides actionable guidance for users.
| /** Single click - opens in preview mode */ | ||
| onClick: () => void; | ||
| /** Double click - opens pinned (permanent) */ | ||
| onDoubleClick?: () => void; |
There was a problem hiding this comment.
Consider keyboard accessibility for the double-click action.
While the double-click implementation is correct, it creates an accessibility gap: keyboard users cannot double-click to pin files. The pinned/permanent action is only available via mouse double-click.
Consider one of these solutions:
- Add a keyboard shortcut (e.g.,
Ctrl/Cmd + Enter) when a file is focused to trigger the pin action - Provide a context menu option accessible via keyboard (e.g., right-click menu or
Shift + F10) - Add a visible pin button that becomes available on focus/hover
This ensures all users can access the pinned-open functionality regardless of input method.
🤖 Prompt for AI Agents
In
@apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileItem/FileItem.tsx
around lines 11 - 14, The FileItem component exposes onClick and onDoubleClick
handlers but lacks keyboard-accessible way to trigger the pin (double-click)
action; update FileItem.tsx to invoke the onDoubleClick logic from keyboard
events and visible controls: add a keydown handler on the file container that
listens for a chosen shortcut (e.g., Ctrl/Cmd+Enter and/or Enter with modifier)
and calls the existing onDoubleClick prop when focused, or render a focusable
pin button that becomes visible on focus/hover and calls onDoubleClick when
activated; ensure the container has appropriate tabIndex and ARIA attributes so
keyboard users can reach it and the onDoubleClick flow (refer to the onClick and
onDoubleClick props in FileItem).
| const isSameFile = | ||
| existingFileViewer.filePath === options.filePath && | ||
| existingFileViewer.diffCategory === options.diffCategory && | ||
| existingFileViewer.commitHash === options.commitHash; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check the AddFileViewerPaneOptions type definition and oldPath usage
rg -n "AddFileViewerPaneOptions" --type=ts -A15 apps/desktop/src/renderer/stores/tabs/Repository: superset-sh/superset
Length of output: 5330
🏁 Script executed:
#!/bin/bash
# Check usage of oldPath in the tabs store and related files
rg -n "oldPath" --type=ts -B3 -A3 apps/desktop/src/renderer/stores/tabs/Repository: superset-sh/superset
Length of output: 2346
🏁 Script executed:
#!/bin/bash
# Look at the context around lines 405-408 to understand the isSameFile logic
sed -n '395,420p' apps/desktop/src/renderer/stores/tabs/store.tsRepository: superset-sh/superset
Length of output: 953
🏁 Script executed:
#!/bin/bash
# Check the ChangedFile interface definition
rg -n "interface ChangedFile|type ChangedFile" --type=ts -A10 apps/desktop/src/renderer/Repository: superset-sh/superset
Length of output: 46
🏁 Script executed:
#!/bin/bash
# Search for where addFileViewerPane is called to understand the oldPath scenario
rg -n "addFileViewerPane" --type=ts -B5 -A5 apps/desktop/src/renderer/Repository: superset-sh/superset
Length of output: 9189
🏁 Script executed:
#!/bin/bash
# Look for comments or documentation about oldPath
rg -n "oldPath|rename|copy" --type=ts -B2 -A2 apps/desktop/src/renderer/stores/tabs/types.tsRepository: superset-sh/superset
Length of output: 478
🏁 Script executed:
#!/bin/bash
# Check the FileViewerPane type definition to see how oldPath is used
rg -n "interface FileViewerPane|type FileViewerPane" --type=ts -A20 apps/desktop/src/renderer/stores/tabs/Repository: superset-sh/superset
Length of output: 46
Include oldPath in the same-file comparison.
The isSameFile check compares filePath, diffCategory, and commitHash, but omits oldPath from AddFileViewerPaneOptions. Since different code paths may provide oldPath inconsistently (e.g., Sidebar passes file.oldPath, but Terminal omits it), the comparison should include oldPath to accurately identify when the same file is being opened from different sources. This prevents incorrectly reusing a preview pane when the file's rename/copy status differs.
🤖 Prompt for AI Agents
In @apps/desktop/src/renderer/stores/tabs/store.ts around lines 405 - 408, The
isSameFile comparison in the AddFileViewerPane logic currently checks
existingFileViewer.filePath, existingFileViewer.diffCategory, and
existingFileViewer.commitHash but omits oldPath; update the isSameFile
expression to also compare existingFileViewer.oldPath === options.oldPath (and
ensure AddFileViewerPaneOptions includes oldPath where used) so panes opened for
renamed/copied files aren’t incorrectly treated as the same.
Description
Related Issues
Type of Change
Testing
Screenshots (if applicable)
Additional Notes
Summary by CodeRabbit
New Features
Style
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.