Skip to content

feat(desktop): V2 preset execution mode parity with V1#3354

Merged
Kitenite merged 2 commits into
mainfrom
presets-v2-parity
Apr 11, 2026
Merged

feat(desktop): V2 preset execution mode parity with V1#3354
Kitenite merged 2 commits into
mainfrom
presets-v2-parity

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Apr 11, 2026

Summary

  • V2 presets now respect executionMode (split-pane, new-tab, new-tab-split-pane) instead of always creating a single tab with commands joined by &&
  • Each command gets its own terminal pane with initialCommand set, using the V2 store's addTab (balanced split tree) and addPane APIs
  • OPEN_PRESET_1-9 hotkeys are now functional in V2 workspaces
  • Extracted preset execution logic into a useV2PresetExecution hook shared by the preset bar and hotkeys

Test plan

  • Create a preset with 2+ commands and split-pane mode — click bar item, verify panes are added to the active tab
  • Create a preset with 2+ commands and new-tab mode — click bar item, verify separate tabs are created (one per command)
  • Create a preset with 2+ commands and new-tab-split-pane mode — click bar item, verify a new tab opens with split panes
  • Press Ctrl+1-9 to trigger presets via hotkeys
  • Verify single-command and empty-command presets still work
  • Verify preset pin/unpin, reorder, and create-from-template still work

Summary by cubic

V2 presets now respect their executionMode like V1, opening tabs/panes per command with clean layouts. Preset hotkeys 1–9 work in V2 workspaces.

  • New Features

    • Honor executionMode: split-pane, new-tab, and new-tab-split-pane.
    • Each command opens in its own pane with initialCommand (no "&&").
    • Balanced layouts via store addTab/addPane, with fallback to a new tab if no active tab.
    • OPEN_PRESET_1–9 hotkeys trigger the first nine matched presets.
  • Refactors

    • Added useV2PresetExecution hook and simplified V2PresetsBar; renamed callback to onExecutePreset and menu to “Run preset.”
    • Reused getPresetLaunchPlan for consistent launch behavior.
    • Removed unused workspaceId param and an unreachable branch in per-command tab creation; updated the plan doc wording to match data flow.

Written for commit e423c75. Summary will update on new commits.

Summary by CodeRabbit

  • New Features

    • Added hotkeys (1–9) to quickly run matched presets.
    • Preset execution now honors each preset’s execution mode (single tab, split/multi-pane, or one tab per command).
  • UI Updates

    • Action label changed from “Open in new tab” to “Run preset”.
  • Documentation

    • Added docs describing V2 preset execution mode parity and verification plan.

…preset hotkeys

V2 presets previously ignored executionMode, always creating a single tab
with commands joined by &&. Now split-pane, new-tab, and new-tab-split-pane
modes work correctly, each command gets its own pane with initialCommand,
and OPEN_PRESET_1-9 hotkeys are functional.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 73b497ee-9904-48a3-9181-e7afd4abc5c5

📥 Commits

Reviewing files that changed from the base of the PR and between 089ccfd and e423c75.

📒 Files selected for processing (3)
  • apps/desktop/plans/20260411-v2-preset-parity.md
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useV2PresetExecution/useV2PresetExecution.ts
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/page.tsx
✅ Files skipped from review due to trivial changes (1)
  • apps/desktop/plans/20260411-v2-preset-parity.md

📝 Walkthrough

Walkthrough

Introduces a centralized useV2PresetExecution hook that queries and filters V2 terminal presets and exposes matchedPresets and executePreset; refactors preset UI to consume the hook, wires preset hotkeys (OPEN_PRESET_1–9) to execute presets, and updates page wiring and docs.

Changes

Cohort / File(s) Summary
Planning & Documentation
apps/desktop/plans/20260411-v2-preset-parity.md
New plan doc describing V2 preset execution-mode parity, hook design, component wiring, verification checklist, and affected files.
Preset Execution Hook
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useV2PresetExecution/useV2PresetExecution.ts, apps/desktop/src/renderer/.../useV2PresetExecution/index.ts
Adds useV2PresetExecution hook: queries v2TerminalPresets, filters by projectId into matchedPresets, and returns executePreset which reads workspace store state and mutates it (add tabs/panes) according to preset executionMode and launch plan.
Preset Bar & Item
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/V2PresetsBar/V2PresetsBar.tsx, apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/V2PresetsBar/components/V2PresetBarItem/V2PresetBarItem.tsx
Removed in-component preset querying and tab-opening logic from V2PresetsBar; component now accepts matchedPresets and executePreset. V2PresetBarItem prop changed from onOpenInNewTab to onExecutePreset and context menu label updated to "Run preset".
Hotkeys & Page Wiring
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useWorkspaceHotkeys/useWorkspaceHotkeys.ts, apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/page.tsx
useWorkspaceHotkeys now accepts matchedPresets and executePreset and registers hotkeys OPEN_PRESET_1OPEN_PRESET_9 that call executePreset by index. page.tsx calls useV2PresetExecution({ store, projectId }) and forwards results to hotkeys and V2PresetsBar.

Sequence Diagram

sequenceDiagram
    participant User as User
    participant Hotkey as Hotkey Handler
    participant PresetBar as V2PresetsBar
    participant Hook as useV2PresetExecution
    participant Store as Workspace Store

    User->>Hotkey: Press OPEN_PRESET_1
    Hotkey->>Hook: openPresetByIndex(0) / executePreset(preset)
    Hook->>Store: Read state (activeTabId, etc.)
    Hook->>Store: Resolve target from preset.executionMode
    Hook->>Store: Create tab(s) and/or pane(s) per plan
    Store-->>Hook: Updated workspace state
    Hook-->>Hotkey: Completion

    User->>PresetBar: Click "Run preset"
    PresetBar->>Hook: executePreset(preset)
    Hook->>Store: Same execution flow as hotkey
    Store-->>PresetBar: Panes/tabs rendered
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 Nine hops, presets in line, I tap a key with glee,
Commands split, tabs take shape, the workspace sings to me.
A hook to guide the dance, a bar to pick the tune—
Preset parity at last beneath the morning moon. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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): V2 preset execution mode parity with V1' clearly and concisely summarizes the main change: implementing V2 preset execution modes to match V1 behavior.
Description check ✅ Passed The description includes a clear summary of changes, test plan with checkboxes, related context, and follows the repository template structure with well-organized sections.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch presets-v2-parity

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.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 11, 2026

Greptile Summary

This PR brings V2 workspace preset execution to parity with V1 by wiring up executionMode (split-pane, new-tab, new-tab-split-pane) and activating the previously no-op OPEN_PRESET_1–9 hotkeys.

Key changes:

  • New useV2PresetExecution hook centralises preset querying (previously duplicated inline in V2PresetsBar) and maps all five getPresetLaunchPlan outcomes to the correct V2 store calls (addTab / addPane), giving each command its own pane instead of joining them with &&.
  • V2PresetsBar is simplified to a pure rendering component receiving matchedPresets and executePreset as props.
  • useWorkspaceHotkeys registers OPEN_PRESET_1–9 handlers using the established useHotkey ref pattern — no stale-closure risk.
  • page.tsx wires everything together at the WorkspaceContent level.

Minor issues found (all P2/style, none affect runtime):

  • workspaceId is declared in UseV2PresetExecutionArgs but never destructured or used inside the hook.
  • The if (!activeTabId) fallback branches inside active-tab-single and active-tab-multi-pane are unreachable.
  • The if (preset.commands.length === 0) guard inside new-tab-per-command is also unreachable.

Confidence Score: 5/5

Safe to merge — the logic is correct, well-structured, and reuses the proven V1 launch-plan utility; all findings are non-blocking cleanup suggestions.

All five launch plans are correctly mapped to V2 store calls, the useHotkey ref pattern avoids stale closures, and edge cases (0 commands, no active tab) are handled. The three P2 comments flag dead code and an unused interface parameter — none affect runtime behaviour.

useV2PresetExecution.ts — three small dead-code/unused-param items worth cleaning up.

Important Files Changed

Filename Overview
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useV2PresetExecution/useV2PresetExecution.ts New hook encapsulating preset query + execution logic; correctly maps all 5 launch plans to V2 store calls, but has an unused workspaceId param and two dead code defensive guards in the active-tab-* cases.
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useV2PresetExecution/index.ts Barrel export for the new hook — straightforward.
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/V2PresetsBar/V2PresetsBar.tsx Simplified to accept pre-computed matchedPresets and executePreset props; removes inline query and openPresetInNewTab — clean refactor with no issues.
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/V2PresetsBar/components/V2PresetBarItem/V2PresetBarItem.tsx Renames onOpenInNewTabonExecutePreset and updates the context-menu label; purely mechanical, no issues.
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useWorkspaceHotkeys/useWorkspaceHotkeys.ts Adds OPEN_PRESET_1–9 handlers via openPresetByIndex; uses the existing useHotkey ref-based pattern correctly, no stale closure risk.
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/page.tsx Wires useV2PresetExecution results to both V2PresetsBar and useWorkspaceHotkeys; clean integration with no issues.
apps/desktop/plans/20260411-v2-preset-parity.md Design doc for the feature; matches the implementation faithfully.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User: click bar item or press Ctrl+1-9] --> B[executePreset]
    B --> C{resolveTarget executionMode}
    C -->|split-pane| D[target = active-tab]
    C -->|new-tab / new-tab-split-pane| E[target = new-tab]
    D --> F[getPresetLaunchPlan]
    E --> F
    F -->|new-tab-single| G[addTab 1 pane]
    F -->|new-tab-multi-pane| H[addTab N panes]
    F -->|new-tab-per-command| I[addTab x N, one per command]
    F -->|active-tab-single| J[addPane to activeTab]
    F -->|active-tab-multi-pane| K[addPane x N to activeTab]
    J -->|no activeTab fallback| G
    K -->|no activeTab fallback| H
Loading

Reviews (1): Last reviewed commit: "feat(desktop): respect executionMode in ..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/desktop/plans/20260411-v2-preset-parity.md`:
- Around line 69-71: The note incorrectly states that V2PresetsBar calls
useV2PresetExecution; update the wording to reflect that page.tsx invokes
useV2PresetExecution and then passes the resulting matchedPresets and
executePreset down as props to V2PresetsBar (and that executePreset is forwarded
to V2PresetBarItem as onExecutePreset). Mention the actual data flow: page.tsx
-> useV2PresetExecution -> { matchedPresets, executePreset } -> V2PresetsBar
props -> V2PresetBarItem onExecutePreset.

In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/`$workspaceId/hooks/useWorkspaceHotkeys/useWorkspaceHotkeys.ts:
- Around line 247-263: The hotkey handler openPresetByIndex currently looks up
presets from matchedPresets causing Ctrl+1..9 to target unpinned items; change
openPresetByIndex to read from the pinned preset list (e.g.,
pinnedPresets[index]) and update its dependency array to include pinnedPresets
(instead of or in addition to matchedPresets and executePreset), and keep the
same guard (if (preset) executePreset(preset)); also ensure the useHotkey
bindings (OPEN_PRESET_1..9) remain unchanged but now call the updated
openPresetByIndex so hotkeys map to the visible pinned preset bar.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9d4eea64-bdd0-494c-9196-b0c91136df87

📥 Commits

Reviewing files that changed from the base of the PR and between 2c67364 and 089ccfd.

📒 Files selected for processing (7)
  • apps/desktop/plans/20260411-v2-preset-parity.md
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/V2PresetsBar/V2PresetsBar.tsx
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/V2PresetsBar/components/V2PresetBarItem/V2PresetBarItem.tsx
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useV2PresetExecution/index.ts
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useV2PresetExecution/useV2PresetExecution.ts
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useWorkspaceHotkeys/useWorkspaceHotkeys.ts
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/page.tsx

Comment thread apps/desktop/plans/20260411-v2-preset-parity.md
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 7 files

…ad code branch

- Remove unused `workspaceId` from `UseV2PresetExecutionArgs` and call site
- Remove unreachable `commands.length === 0` guard in `new-tab-per-command` case
- Fix plan doc wording to match actual data flow
@Kitenite Kitenite merged commit c8f8dff into main Apr 11, 2026
7 checks passed
@github-actions
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! 🎉

MocA-Love pushed a commit to MocA-Love/superset that referenced this pull request Apr 13, 2026
)

* feat(desktop): respect executionMode in V2 preset execution and wire preset hotkeys

V2 presets previously ignored executionMode, always creating a single tab
with commands joined by &&. Now split-pane, new-tab, and new-tab-split-pane
modes work correctly, each command gets its own pane with initialCommand,
and OPEN_PRESET_1-9 hotkeys are functional.

* fix(desktop): address PR review — remove unused workspaceId param, dead code branch

- Remove unused `workspaceId` from `UseV2PresetExecutionArgs` and call site
- Remove unreachable `commands.length === 0` guard in `new-tab-per-command` case
- Fix plan doc wording to match actual data flow
@Kitenite Kitenite deleted the presets-v2-parity branch April 13, 2026 16:35
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