feat(desktop): add file open mode setting (split pane vs new tab)#1369
Conversation
Add a new behavior setting that lets users choose how files open when no preview pane exists to reuse. Options are "Split pane" (default, existing behavior) and "New tab" (opens file in a dedicated tab).
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughAdds a persisted file open mode setting (split-pane | new-tab), TRPC get/set procedures, UI control in Behavior settings, a renderer hook, propagation to file-opening components, a tabs store branch to create a new tab when requested, and a DB migration/schema update. Changes
Sequence DiagramsequenceDiagram
participant User as User
participant UI as BehaviorSettings UI
participant Hook as useFileOpenMode Hook
participant TRPC as Settings TRPC
participant DB as Database
participant FileUI as File-opening Components
participant Store as Tabs Store
User->>UI: Change file open mode
UI->>TRPC: setFileOpenMode(mode)
TRPC->>DB: UPDATE settings.file_open_mode
DB-->>TRPC: OK
TRPC-->>UI: success
User->>FileUI: Open file
FileUI->>Hook: useFileOpenMode()
Hook->>TRPC: getFileOpenMode()
TRPC->>DB: SELECT file_open_mode
DB-->>TRPC: mode
TRPC-->>Hook: mode or default
Hook-->>FileUI: mode
FileUI->>Store: addFileViewerPane({ openInNewTab: mode === "new-tab", ... })
alt openInNewTab true
Store->>Store: create new tab and pane, set active
Store-->>FileUI: pane id (new tab)
else
Store->>Store: reuse/create pane in current tab (split)
Store-->>FileUI: pane id (split)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
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 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 |
🚀 Preview Deployment🔗 Preview Links
Preview updates automatically with new commits |
Summary
Changes
Schema & Types (
packages/local-db)FILE_OPEN_MODESconst andFileOpenModetype inzod.tsfileOpenModecolumn to thesettingstable inschema.tsBackend (
apps/desktop)DEFAULT_FILE_OPEN_MODEconstant ("split-pane")getFileOpenModequery andsetFileOpenModemutation to the settings tRPC routerStore (
apps/desktop/src/renderer/stores/tabs)openInNewTab?: booleantoAddFileViewerPaneOptionsaddFileViewerPane, whenopenInNewTabis true and no preview pane exists, creates a new tab with the file viewer instead of splittingHook & Call Sites
useFileOpenModehook that reads the setting via tRPCFilesView,RightSidebar,SidebarControl,useFileLinkClickSettings UI
Test Plan
Summary by CodeRabbit