Skip to content

feat (desktop): replace lock with pinned files via cursor pattern - #636

Merged
AviPeltz merged 3 commits into
mainfrom
replace-lock2
Jan 7, 2026
Merged

AviPeltz merged 3 commits into
mainfrom
replace-lock2

Conversation

@AviPeltz

@AviPeltz AviPeltz commented Jan 7, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Documentation
  • Refactor
  • Other (please describe):

Testing

Screenshots (if applicable)

Additional Notes

Summary by CodeRabbit

  • New Features

    • Preview mode for file viewing—single-click opens files that can be replaced by clicking another file
    • Double-click to open files in pinned mode (permanent)
    • Auto-pin files when edits are made
    • Visual distinction between preview and pinned panes
  • Style

    • Updated UI with pin button replacing lock button
    • Preview panes display italicized names and "preview" indicator
  • Refactor

    • Replaced lock/unlock mechanism with preview/pin system

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 7, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This 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 isLocked to isPinned, adding double-click handlers to open files pinned, introducing an auto-pin-on-edit effect, updating UI components with pin affordances, and migrating persisted state.

Changes

Cohort / File(s) Summary
Schema & Type Definitions
apps/desktop/src/lib/trpc/routers/ui-state/index.ts, apps/desktop/src/shared/tabs-types.ts, apps/desktop/src/renderer/stores/tabs/types.ts, apps/desktop/src/renderer/stores/tabs/utils.ts
Renamed isLocked: boolean → isPinned: boolean across schema, types, and utility functions. Updated CreateFileViewerPaneOptions and AddFileViewerPaneOptions to use isPinned with default value false for preview mode.
File Viewer Pane Components
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/FileViewerPane.tsx, ...FileViewerPane/components/FileViewerToolbar/FileViewerToolbar.tsx
Replaced isLocked / onToggleLock props with isPinned / onPin. Added handlePin function and auto-pin effect when pane is edited (isDirty). Updated toolbar UI to show pin button, italicized preview tab names, and "preview" label for unpinned panes. Removed lock icons.
Changes View & File List Hierarchy
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/index.tsx, ...Sidebar/ChangesView/ChangesView.tsx, ...ChangesView/components/CommitItem/CommitItem.tsx, ...components/FileItem/FileItem.tsx, ...components/FileList/FileList.tsx, ...FileList/FileListGrouped.tsx, ...FileList/FileListTree.tsx
Added optional onFileDoubleClick prop and handlers throughout file list hierarchy to wire double-click-to-pin behavior. ChangesView now accepts onFileOpenPinned callback alongside onFileOpen. Double-click handlers propagate through FileList, FileListTree, FileListGrouped, CommitItem, and FileItem.
Tab Store & State Management
apps/desktop/src/renderer/stores/tabs/store.ts
Introduced new pinPane(paneId) action to pin a file-viewer pane. Updated addFileViewerPane to reuse unpinned preview panes and derive isPinned from options. Added migration logic (version 2 → 3) to convert legacy isLocked → isPinned, defaulting to true for backward compatibility.
Documentation
plans/preview-mode-implementation.md
Implementation plan detailing preview vs. pinned pane behavior, user interactions (single-click preview, double-click pin, edit-to-pin), visual indicators, and migration strategy.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • #361 — Modifies the same sidebar components (ChangesView, FileList, FileItem) with overlapping prop changes; likely code-level conflicts.
  • #303 — Both PRs modify the same trpc ui-state router schema; this PR renames FileViewerState.isLocked → isPinned within the schema defined in PR #303.
  • #284 — Both PRs alter the TabsStore API and state management; this PR adds pinPane action and isPinned logic while #284 refactors store structure.

Suggested reviewers

  • Kitenite
  • saddlepaddle

Poem

🐰 Whiskers twitch with glee so bright,
Preview panes now dance in light,
Pin them down or let them float,
Double-click's the magic note,
Edit-to-pin, a carrot's dream! 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is essentially empty, containing only the template structure with no actual implementation details, related issues, testing steps, or additional context provided. Fill in the description section with details about the feature, reference any related issues, provide testing steps, and add implementation notes explaining the cursor-style preview/pinned pattern.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly summarizes the main change: replacing a lock mechanism with a pinned/preview file system pattern inspired by Cursor/VS Code.
✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jan 7, 2026 •

Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch
  • ✅ Electric Fly.io app

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>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 handleFileOpen and handleFileOpenPinned have identical logic except for the isPinned flag 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 adding aria-label to 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

📥 Commits

Reviewing files that changed from the base of the PR and between e0c81b1 and ba06a79.

📒 Files selected for processing (15)
  • apps/desktop/src/lib/trpc/routers/ui-state/index.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/FileViewerPane.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/components/FileViewerToolbar/FileViewerToolbar.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CommitItem/CommitItem.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileItem/FileItem.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileList.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListGrouped.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListTree.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/index.tsx
  • apps/desktop/src/renderer/stores/tabs/store.ts
  • apps/desktop/src/renderer/stores/tabs/types.ts
  • apps/desktop/src/renderer/stores/tabs/utils.ts
  • apps/desktop/src/shared/tabs-types.ts
  • plans/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 in src/lib/trpc
Use alias as defined in tsconfig.json when 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/observable instead of async generators, as the library explicitly checks isObservable(result) and throws an error otherwise

Files:

  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileItem/FileItem.tsx
  • apps/desktop/src/renderer/stores/tabs/types.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListTree.tsx
  • apps/desktop/src/renderer/stores/tabs/utils.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileList.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/index.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsx
  • apps/desktop/src/renderer/stores/tabs/store.ts
  • apps/desktop/src/shared/tabs-types.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/FileViewerPane.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/components/FileViewerToolbar/FileViewerToolbar.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CommitItem/CommitItem.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListGrouped.tsx
  • apps/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 using any type - 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.tsx
  • apps/desktop/src/renderer/stores/tabs/types.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListTree.tsx
  • apps/desktop/src/renderer/stores/tabs/utils.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileList.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/index.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsx
  • apps/desktop/src/renderer/stores/tabs/store.ts
  • apps/desktop/src/shared/tabs-types.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/FileViewerPane.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/components/FileViewerToolbar/FileViewerToolbar.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CommitItem/CommitItem.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListGrouped.tsx
  • apps/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.tsx
  • apps/desktop/src/renderer/stores/tabs/types.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListTree.tsx
  • apps/desktop/src/renderer/stores/tabs/utils.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileList.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/index.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsx
  • apps/desktop/src/renderer/stores/tabs/store.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/FileViewerPane.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/components/FileViewerToolbar/FileViewerToolbar.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CommitItem/CommitItem.tsx
  • apps/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.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListTree.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileList.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/index.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/FileViewerPane.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/components/FileViewerToolbar/FileViewerToolbar.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CommitItem/CommitItem.tsx
  • apps/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.tsx
  • apps/desktop/src/renderer/stores/tabs/types.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListTree.tsx
  • apps/desktop/src/renderer/stores/tabs/utils.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileList.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/index.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsx
  • apps/desktop/src/renderer/stores/tabs/store.ts
  • apps/desktop/src/shared/tabs-types.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/FileViewerPane.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/components/FileViewerToolbar/FileViewerToolbar.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CommitItem/CommitItem.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListGrouped.tsx
  • apps/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:fix or biome check --write

Files:

  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileItem/FileItem.tsx
  • apps/desktop/src/renderer/stores/tabs/types.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListTree.tsx
  • apps/desktop/src/renderer/stores/tabs/utils.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileList.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/index.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/ChangesView.tsx
  • apps/desktop/src/renderer/stores/tabs/store.ts
  • apps/desktop/src/shared/tabs-types.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/FileViewerPane.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/FileViewerPane/components/FileViewerToolbar/FileViewerToolbar.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/CommitItem/CommitItem.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/ChangesView/components/FileList/FileListGrouped.tsx
  • apps/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 from isLocked to isPinned.

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 isPinned option and pinPane method 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: false correctly 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 isPinned state and handlePin handler 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 pinPane calls across handleEditorChange (line 90) and handleDiffChange (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) and handleFileOpenPinned (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 isPinned prop; pin button only renders when !isPinned; tap button hidden when already pinned

✓ Same-file-click-to-pin logic: Implemented in addFileViewerPane via isSameFile check (lines 407–410 in store.ts) that auto-pins when clicking the same file again

The 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 onDoubleClick handler 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 onFileDoubleClick prop is correctly threaded through the component hierarchy, following the same pattern as the existing onFileSelect handler. 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 onFileDoubleClick prop is properly threaded through all three levels (FileListGrouped → FolderGroupItem → FileItem), following the same pattern as existing optional handlers like onStage and onUnstage. 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 → isPinned migration is already handled in apps/desktop/src/renderer/stores/tabs/store.ts (lines 845–855) via version-based migration logic. When the store detects version < 3, it automatically migrates existing persisted panes by renaming isLocked to isPinned and defaults old panes to isPinned: 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 onFileDoubleClick prop 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 both FileListTree and FileListGrouped components.

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) : undefined correctly guards against undefined props, and the pattern is consistent with how onClick is handled. The prop is properly threaded through all recursive TreeNodeComponent calls.

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/handleFileDoubleClick and handleCommitFileSelect/handleCommitFileDoubleClick is clear and maintainable.


279-281: Consistent wiring across all file categories.

The onFileDoubleClick handler 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:

  1. Same file clicked → pin the preview pane
  2. Different file clicked → replace preview content
  3. 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 pinPane action 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 legacy isLocked field.

The migration from version 2 to 3 properly:

  1. Converts isLocked → isPinned
  2. Defaults to true for old panes (since they were explicitly opened before the preview paradigm)
  3. 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.

Comment on lines +11 to +14
/** Single click - opens in preview mode */
onClick: () => void;
/** Double click - opens pinned (permanent) */
onDoubleClick?: () => void;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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:

  1. Add a keyboard shortcut (e.g., Ctrl/Cmd + Enter) when a file is focused to trigger the pin action
  2. Provide a context menu option accessible via keyboard (e.g., right-click menu or Shift + F10)
  3. 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).

Comment on lines +405 to +408
const isSameFile =
existingFileViewer.filePath === options.filePath &&
existingFileViewer.diffCategory === options.diffCategory &&
existingFileViewer.commitHash === options.commitHash;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 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.ts

Repository: 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.ts

Repository: 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.

@AviPeltz
AviPeltz merged commit 30be7e2 into main Jan 7, 2026
13 checks passed
@Kitenite
Kitenite deleted the replace-lock2 branch January 7, 2026 01:30

This branch was previously deployed

1 inactive deployment
preview — ba06a79c Deployed Jan 7, 2026 by AviPeltz via Deploy Web #750
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant