Skip to content

feat(desktop): add default preset support for new terminals - #637

Merged
Kitenite merged 1 commit into
mainfrom
default-presets
Jan 7, 2026
Merged

Kitenite merged 1 commit into
mainfrom
default-presets

Conversation

@Kitenite

@Kitenite Kitenite commented Jan 7, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add ability to mark a single terminal preset as default via a star toggle button in preset settings
  • Default preset automatically applies when creating new terminals via Cmd+T, split panes (Cmd+D, Cmd+Shift+D, Cmd+E), and the plus button

Changes

  • Add isDefault field to TerminalPreset schema
  • Add setDefaultPreset mutation and getDefaultPreset query to settings router
  • Create useTabsWithPresets hook that wraps store actions with default preset support
  • Update all terminal creation entry points to use the new hook

Summary by CodeRabbit

Release Notes

  • New Features
    • Set a default terminal preset that automatically applies when creating new tabs and panes.
    • Visual star icon indicator in presets menu displaying the active default preset.
    • Toggle default status directly from preset settings with dedicated UI controls.

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

@coderabbitai

coderabbitai Bot commented Jan 7, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR introduces default terminal preset functionality across the application. It adds TRPC endpoints to manage default presets, extends the TerminalPreset schema with an isDefault flag, creates UI controls for toggling defaults in preset settings, and implements a new useTabsWithPresets hook that automatically applies default presets when creating tabs and panes.

Changes

Cohort / File(s) Summary
Settings & Data Layer
apps/desktop/src/lib/trpc/routers/settings/index.ts, packages/local-db/src/schema/zod.ts
Added TRPC procedures setDefaultPreset() and getDefaultPreset() to manage default preset state. Extended TerminalPreset schema with optional isDefault?: boolean field for persistence.
Presets React Query Layer
apps/desktop/src/renderer/react-query/presets/index.ts
Introduced useSetDefaultPreset mutation hook and extended usePresets to expose defaultPreset and setDefaultPreset in return signature, invalidating related caches on successful mutation.
Preset UI Components
apps/desktop/src/renderer/screens/main/components/SettingsView/PresetsSettings/PresetRow/PresetRow.tsx, apps/desktop/src/renderer/screens/main/components/SettingsView/PresetsSettings/PresetsSettings.tsx
Added star icon toggle in PresetRow for marking/unmarking default presets via new onSetDefault prop. Updated PresetsSettings to handle default preset logic and propagate callback to PresetRow. Adjusted Actions column width from w-12 to w-20.
Tabs Store & Hook Implementation
apps/desktop/src/renderer/stores/tabs/store.ts, apps/desktop/src/renderer/stores/tabs/types.ts, apps/desktop/src/renderer/stores/tabs/useTabsWithPresets.ts
Extended splitPane methods (splitPaneVertical, splitPaneHorizontal, splitPaneAuto) with optional options?: AddTabOptions parameter. Created new useTabsWithPresets hook that wraps tab store actions to automatically inject default preset options (initial commands, working directory, tab naming) when no explicit options provided.
Tab Management UI Integration
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/GroupStrip/GroupStrip.tsx, apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/index.tsx, apps/desktop/src/renderer/screens/main/components/WorkspaceView/index.tsx, apps/desktop/src/renderer/screens/main/index.tsx
Replaced direct store access for addTab and split-pane methods with useTabsWithPresets hook. Added star icon visual indicator for default presets in dropdown items (GroupStrip). Updated hotkey handlers to use hook-provided functions.
Tabs Module Export
apps/desktop/src/renderer/stores/tabs/index.ts
Added re-export of useTabsWithPresets from ./useTabsWithPresets for public API consumption.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI as PresetRow Component
    participant Hook as useSetDefaultPreset
    participant TRPC as TRPC Client
    participant Server
    participant Cache as React Query Cache

    User->>UI: Click star toggle
    UI->>Hook: Call setDefaultPreset.mutate({id})
    Hook->>TRPC: Invoke setDefaultPreset mutation
    TRPC->>Server: Send mutation request
    Server->>Server: Update terminalPresets<br/>(set isDefault flags)
    Server-->>TRPC: Return {success: true}
    TRPC-->>Hook: Mutation succeeds
    Hook->>Cache: Invalidate getTerminalPresets
    Hook->>Cache: Invalidate getDefaultPreset
    Cache-->>UI: Cache updated, re-render
    UI-->>User: Star icon updates, UI reflects new default
Loading
sequenceDiagram
    participant User
    participant UI as Workspace UI
    participant Hook as useTabsWithPresets
    participant Presets as usePresets Hook
    participant Store as Tabs Store
    participant Tab as New Tab

    User->>UI: Trigger "Add Tab" hotkey
    UI->>Hook: Call addTab(workspaceId)
    Hook->>Presets: Query defaultPreset data
    Presets-->>Hook: Return default preset object
    Hook->>Hook: Compute options from preset<br/>(initialCommands, initialCwd)
    Hook->>Store: Call store.addTab with computed options
    Store->>Tab: Create tab with preset options
    Tab-->>Store: Tab created with preset settings
    Store-->>Hook: Return
    Hook-->>UI: New tab spawned with preset applied
    UI-->>User: Terminal opens with preset config
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 Default presets shine like stars so bright,
Tabs spawn swiftly with a single might,
Through hooks we bound, through stores we spring,
New terminals dressed in preset wings! ✨

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 30be7e2 and 57023ae.

📒 Files selected for processing (13)
  • apps/desktop/src/lib/trpc/routers/settings/index.ts
  • apps/desktop/src/renderer/react-query/presets/index.ts
  • apps/desktop/src/renderer/screens/main/components/SettingsView/PresetsSettings/PresetRow/PresetRow.tsx
  • apps/desktop/src/renderer/screens/main/components/SettingsView/PresetsSettings/PresetsSettings.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/GroupStrip/GroupStrip.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/index.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/index.tsx
  • apps/desktop/src/renderer/screens/main/index.tsx
  • apps/desktop/src/renderer/stores/tabs/index.ts
  • apps/desktop/src/renderer/stores/tabs/store.ts
  • apps/desktop/src/renderer/stores/tabs/types.ts
  • apps/desktop/src/renderer/stores/tabs/useTabsWithPresets.ts
  • packages/local-db/src/schema/zod.ts

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 Deployment

🔗 Preview Links

Service Status Link
Neon Database (Neon) ✅ View Branch
Fly.io Electric (Fly.io) ✅ View App
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

- Add isDefault field to TerminalPreset schema
- Add setDefaultPreset mutation and getDefaultPreset query
- Create useTabsWithPresets hook that applies default preset to new terminals
- Add star toggle button in preset settings to mark/unmark default
- Update all terminal creation entry points (Cmd+T, splits, plus button)

This branch was previously deployed

1 inactive deployment
preview — 57023aec Deployed Jan 7, 2026 by Kitenite via Deploy Docs #753
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