Skip to content

feat(desktop): add file open mode setting (split pane vs new tab)#1369

Merged
Kitenite merged 3 commits into
mainfrom
kitenite/open-file-setting
Feb 10, 2026
Merged

feat(desktop): add file open mode setting (split pane vs new tab)#1369
Kitenite merged 3 commits into
mainfrom
kitenite/open-file-setting

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Feb 10, 2026

Summary

  • Adds a new "File open mode" behavior setting with two options: Split pane (default, current behavior) and New tab
  • When set to "New tab", clicking a file in the file tree, changes view, or terminal link opens it in a new tab instead of splitting the current tab
  • Preview pane reuse still works in both modes — the setting only affects the fallback when no reusable pane exists

Changes

Schema & Types (packages/local-db)

  • Added FILE_OPEN_MODES const and FileOpenMode type in zod.ts
  • Added nullable fileOpenMode column to the settings table in schema.ts

Backend (apps/desktop)

  • Added DEFAULT_FILE_OPEN_MODE constant ("split-pane")
  • Added getFileOpenMode query and setFileOpenMode mutation to the settings tRPC router

Store (apps/desktop/src/renderer/stores/tabs)

  • Added openInNewTab?: boolean to AddFileViewerPaneOptions
  • In addFileViewerPane, when openInNewTab is true and no preview pane exists, creates a new tab with the file viewer instead of splitting

Hook & Call Sites

  • Created useFileOpenMode hook that reads the setting via tRPC
  • Updated all 4 call sites: FilesView, RightSidebar, SidebarControl, useFileLinkClick

Settings UI

  • Added "File open mode" dropdown to Settings > Behavior
  • Added search entry for discoverability

Test Plan

  • Open Settings > Behavior — verify "File open mode" dropdown appears with "Split pane" selected by default
  • With "Split pane" mode: click a file in the file tree — should split the current tab (existing behavior)
  • Switch to "New tab" mode: click a file — should open in a new tab
  • Verify preview pane reuse still works in both modes (clicking different files reuses the preview pane)
  • Test from changes view with both modes
  • Test terminal file link clicks with both modes

Summary by CodeRabbit

  • New Features
    • Added a "File Open Mode" setting in Behavior settings allowing users to choose how files open: "split-pane" (default) or "new-tab".
    • The choice is applied across the app (sidebar, file lists, file links, and terminal file opens), causing files to open in a new tab when "new-tab" is selected.
    • UI includes a labeled selector with helper text and optimistic updates for a responsive experience.

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).
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 10, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary
Database schema & types
packages/local-db/src/schema/zod.ts, packages/local-db/src/schema/schema.ts, packages/local-db/drizzle/0020_add_file_open_mode_setting.sql, packages/local-db/drizzle/meta/*
Adds FILE_OPEN_MODES and FileOpenMode type; adds file_open_mode / fileOpenMode column to settings table and migration + snapshot/journal updates.
Settings API & constants
apps/desktop/src/lib/trpc/routers/settings/index.ts, apps/desktop/src/shared/constants.ts
Adds getFileOpenMode query and setFileOpenMode mutation to settings TRPC router; imports FILE_OPEN_MODES and adds DEFAULT_FILE_OPEN_MODE.
Renderer hook & export
apps/desktop/src/renderer/hooks/useFileOpenMode/useFileOpenMode.ts, apps/desktop/src/renderer/hooks/useFileOpenMode/index.ts
New useFileOpenMode hook that queries TRPC for the mode (defaults to "split-pane"); index re-exports the hook.
Behavior settings UI & search
apps/desktop/src/renderer/routes/_authenticated/settings/behavior/components/BehaviorSettings/BehaviorSettings.tsx, .../settings-search/settings-search.ts
Adds File open mode select to Behavior settings with TRPC query/mutation (optimistic update, rollback) and registers the new setting in search/index.
File opening surfaces
apps/desktop/src/renderer/screens/main/components/SidebarControl/SidebarControl.tsx, .../TabsContent/Terminal/hooks/useFileLinkClick.ts, .../RightSidebar/FilesView/FilesView.tsx, .../RightSidebar/index.tsx
Each component consumes useFileOpenMode and passes openInNewTab: fileOpenMode === "new-tab" when creating file viewer panes; updated dependency arrays.
Tabs store & types
apps/desktop/src/renderer/stores/tabs/types.ts, apps/desktop/src/renderer/stores/tabs/store.ts
Adds optional openInNewTab to AddFileViewerPaneOptions; implements branch in addFileViewerPane to create a new tab + pane when openInNewTab is truthy.
Small constant
apps/desktop/src/shared/constants.ts
Adds DEFAULT_FILE_OPEN_MODE = "split-pane".

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • #524: Adds get/set procedures to the same settings TRPC router — similar pattern for new setting handlers.
  • #660: Changes AddFileViewerPaneOptions and pane creation logic in tabs store — overlaps with the new openInNewTab branch.
  • #693: Modifies SidebarControl file-opening behavior — directly related to changes that propagate the open mode preference.

Poem

🐰 I hopped through code and found a mode,
Split panes or new tabs on the road.
I save your choice with a cheerful thump,
Files open where you like — jump, jump, jump! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(desktop): add file open mode setting (split pane vs new tab)' clearly and specifically describes the main change—adding a new file open mode setting with two options.
Description check ✅ Passed The PR description is comprehensive and well-structured, covering summary, changes, and test plan. However, it doesn't explicitly reference related issues and lacks the formal 'Related Issues' section from the template.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch kitenite/open-file-setting

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
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 10, 2026

🚀 Preview Deployment

🔗 Preview Links

Service Status Link
Neon Database (Neon) View Branch
Fly.io Electric (Fly.io) View App
Fly.io Streams (Fly.io) Failed to deploy
Vercel API (Vercel) Open Preview
Vercel Web (Vercel) Open Preview
Vercel Marketing (Vercel) Open Preview
Vercel Admin (Vercel) Open Preview
Vercel Docs (Vercel) Open Preview

Preview updates automatically with new commits

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