Skip to content

fix(desktop): repair terminal preset launches - #4926

Merged
Kitenite merged 5 commits into
ParadevAI:mainfrom
sshresthh:fix/terminal-preset-launches
May 27, 2026
Merged

Kitenite merged 5 commits into
ParadevAI:mainfrom
sshresthh:fix/terminal-preset-launches

Conversation

@sshresthh

@sshresthh sshresthh commented May 26, 2026 •

Copy link
Copy Markdown

Description

Fixes regressions in desktop terminal presets that were discussed with Kiet before opening this PR.

Scope:

  • Preserves the preset Directory/cwd when launching terminal commands.
  • Keeps sequential as a valid execution mode instead of normalizing it away.
  • Adds the grouped sequential launch option as All in current tab.
  • Runs grouped sequential presets in one terminal without split panes.
  • Runs applyOnNewTab presets when creating a new terminal tab, including the new-tab hotkey path.
  • Keeps preset terminal labels visible for reused/default terminals without renaming an already labeled terminal.

Related Issues

No GitHub issue. Discussed with Kiet in Slack; he confirmed this was a regression and said a PR would be welcome.

Type of Change

Bug fix.

Testing

  • bun test apps/desktop/src/renderer/stores/tabs/preset-launch.test.ts apps/desktop/src/lib/trpc/routers/settings/preset-execution-mode.test.ts apps/desktop/src/renderer/lib/terminal/launch-command.test.ts 'apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/components/TerminalSessionDropdown/TerminalSessionDropdown.utils.test.ts'
  • bun run typecheck --filter=@superset/desktop --filter=@superset/api --filter=@superset/auth
  • bun run lint

Demo

terminal-preset.mov

Reviewer Notes

  • This PR is scoped to terminal preset behavior only.

Open in Stage

Summary by cubic

Fixes terminal preset launches in desktop: preserves preset cwd, restores sequential execution, auto-applies presets on new tabs, and keeps preset/user titles visible when reusing terminals.

  • Bug Fixes
    • Respect preset Directory/cwd for all launches; sequential runs prepend cd when reusing a terminal.
    • Keep sequential as a valid mode and run grouped sequential presets in one terminal (no split panes); reuse the active terminal when available, else open one new tab.
    • Auto-run applyOnNewTab presets when creating a new terminal tab (UI and hotkey); project-targeted presets take priority over global.
    • Preserve preset labels on reused/default terminals and prefer explicit pane titles over runtime/session titles in the session dropdown.
    • Update UI to show “All in current tab” for sequential multi-command presets.

Written for commit 3b39797. Summary will update on new commits. Review in cubic

Summary by CodeRabbit

  • New Features

    • Added "Sequential" execution mode for terminal presets — run all preset commands in the current terminal tab.
  • Improvements

    • UI now shows more consistent terminal titles and improved preset mode labels.
    • Preset execution respects working directory and can inject focused commands into existing terminals.
    • Hotkey and "add terminal" flows now respect preset-driven tab creation.
  • Tests

    • Expanded test coverage for the new mode and title/command behaviors.

Review Change Stack

@capy-ai

capy-ai Bot commented May 26, 2026

Copy link
Copy Markdown

Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews.

@coderabbitai

coderabbitai Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 326747cd-5e69-4078-8dd1-7dda5f889c7f

📥 Commits

Reviewing files that changed from the base of the PR and between 093973b and 3b39797.

📒 Files selected for processing (6)
  • apps/desktop/src/renderer/routes/_authenticated/settings/terminal/components/TerminalSettings/components/PresetRow/PresetRow.tsx
  • apps/desktop/src/renderer/routes/_authenticated/settings/terminal/components/TerminalSettings/components/PresetRow/PresetRow.utils.test.ts
  • apps/desktop/src/renderer/routes/_authenticated/settings/terminal/components/TerminalSettings/components/PresetRow/PresetRow.utils.ts
  • apps/desktop/src/renderer/stores/tabs/preset-launch.test.ts
  • apps/desktop/src/renderer/stores/tabs/preset-launch.ts
  • apps/desktop/src/renderer/stores/tabs/useTabsWithPresets.ts
✅ Files skipped from review due to trivial changes (2)
  • apps/desktop/src/renderer/routes/_authenticated/settings/terminal/components/TerminalSettings/components/PresetRow/PresetRow.utils.test.ts
  • apps/desktop/src/renderer/routes/_authenticated/settings/terminal/components/TerminalSettings/components/PresetRow/PresetRow.utils.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/desktop/src/renderer/stores/tabs/preset-launch.test.ts
  • apps/desktop/src/renderer/stores/tabs/preset-launch.ts
  • apps/desktop/src/renderer/stores/tabs/useTabsWithPresets.ts

📝 Walkthrough

Walkthrough

This PR introduces "sequential" as a first-class terminal execution mode. The execution pipeline is refactored to preserve sequential mode through normalization, properly handle preset cwd via quoted cd commands, and support pane reuse when a suitable active terminal exists. New helpers centralize launch planning and pane naming logic, while the UI updated to reflect sequential mode labels. Integration through pane openers and hotkeys ensures presets control terminal-tab creation throughout the workspace.

Changes

Sequential Execution Mode Feature

Layer / File(s) Summary
Schema and execution-mode normalization
packages/local-db/src/schema/zod.ts, apps/desktop/test-setup.ts, apps/desktop/src/renderer/routes/_authenticated/providers/CollectionsProvider/dashboardSidebarLocal/schema.ts, apps/desktop/src/lib/trpc/routers/settings/preset-execution-mode.test.ts
EXECUTION_MODES and related schemas now include "sequential". normalizeExecutionMode preserves "sequential" and maps legacy "parallel" to "split-pane". Tests and mocked setup updated accordingly.
Terminal title & command utilities
apps/desktop/src/renderer/routes/.../TerminalSessionDropdown.utils.ts, .../TerminalSessionDropdown.tsx, .../TerminalSessionDropdown.utils.test.ts, apps/desktop/src/renderer/lib/terminal/launch-command.ts
Added getTerminalDisplayTitle (centralized title precedence) and exported normalizeTerminalCommand. Dropdowns now use the helper; tests cover fallback precedence.
Launch planning and pane naming helpers
apps/desktop/src/renderer/stores/tabs/preset-launch.ts, apps/desktop/src/renderer/stores/tabs/preset-launch.test.ts
PresetLaunchPlan gains "active-terminal". getPresetLaunchPlan accepts hasActiveTerminal and can return active-terminal for sequential active-tab runs. Added buildFocusedTerminalCommand (cwd-aware) and shouldApplyPresetPaneName with tests.
Core preset execution refactor
apps/desktop/src/renderer/routes/.../useV2PresetExecution.ts
Refactored to compute launchCommands (including sequential wrapping), sync-resolve agent commands, fetch workspace worktreePath, and route execution through getPresetLaunchPlan. Hook now returns newTabPresets.
Tab/pane execution and pane naming
apps/desktop/src/renderer/stores/tabs/useTabsWithPresets.ts
Use focused terminal commands when reusing active terminals; conditionally apply preset pane names using shouldApplyPresetPaneName + setPaneName; refactor new-tab/per-command creation and dependency arrays.
Pane opener, hotkeys, and page wiring
apps/desktop/src/renderer/routes/.../useWorkspacePaneOpeners.ts, .../useWorkspaceHotkeys.ts, .../page.tsx
useWorkspacePaneOpeners accepts newTabPresets & executePreset; addTerminalTab applies presets or falls back to blank tabs. Hotkeys now call addTerminalTab. Page threads newTabPresets/executePreset into openers/hotkeys.
Settings UI mode label updates
apps/desktop/src/renderer/.../PresetRow.utils.ts, PresetRow.tsx, PresetsSection.tsx, PresetEditorDialog.tsx, V2PresetsSection.tsx
Added getPresetModeLabel and tests; UI shows "sequential" option ("All in current tab") and treats sequential like split-pane for single-command presets where appropriate.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

"🐰 In tidy hops I bring a fix so neat,
Sequential runs now land in order, sweet.
CWDs preserved, pane names set just right,
Presets march onward — one command at a time tonight."

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main objective of the PR: fixing terminal preset launches. It's concise, clear, and directly reflects the core changes across the changeset.
Description check ✅ Passed The description comprehensively covers all required template sections: detailed explanation of fixes, related issues context, type of change clearly marked as bug fix, testing commands provided, and additional reviewer notes. All essential information is present and well-organized.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

@ghost

ghost commented May 26, 2026 •

Copy link
Copy Markdown

@greptile-apps

greptile-apps Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR repairs several regressions in desktop terminal preset launching: sequential is restored as a valid execution mode (was incorrectly normalised to split-pane), grouped sequential presets now run in one terminal without splitting panes, applyOnNewTab presets fire on both the "new tab" button and the keyboard shortcut, preset cwd is preserved for sequential commands via an explicit cd … && prefix, and already-labelled terminals are no longer renamed by subsequent preset runs.

  • Schema & normalisation (zod.ts, schema.ts, preset-execution-mode.test.ts): sequential added to EXECUTION_MODES and passes through normalizeExecutionMode unchanged; parallel still maps to split-pane.
  • Launch planner (preset-launch.ts): new active-terminal plan type routes sequential presets to the focused terminal pane; falls back to new-tab-single when none is active.
  • V2 execution (useV2PresetExecution.ts): sequential preset writes the combined command + cd prefix to the active terminal via writeInput; selectAutoApplyPresets filters newTabPresets with project-targeted priority; workspaceQuery supplies worktreePath for absolute-path resolution.
  • V1 execution (useTabsWithPresets.ts): mirrors the sequential path with buildFocusedTerminalCommand and shouldLabelPaneForPreset.
  • New-tab hotkey (useWorkspaceHotkeys.ts, useWorkspacePaneOpeners.ts): NEW_GROUP now delegates to addTerminalTab which runs applyOnNewTab presets instead of creating a blank terminal.

Confidence Score: 4/5

The changes are well-scoped bug fixes with matching tests; the only notable gap is that openPresetInCurrentTerminal still skips the cwd when writing to the terminal, which is inconsistent with the new sequential path that does apply it.

All core sequential paths (active-terminal, new-tab-single, hotkey, applyOnNewTab) are covered by new tests. The openPresetInCurrentTerminal function still silently drops preset.cwd when writing commands to the terminal, diverging from the behaviour added for executePreset's active-terminal case. The rest of the changes — schema, normalisation, label logic, and the V2 worktree-path resolution — look correct.

useTabsWithPresets.ts (openPresetInCurrentTerminal) and PresetRow.tsx (single-command sequential label) are worth a second look.

Important Files Changed

Filename Overview
apps/desktop/src/renderer/stores/tabs/preset-launch.ts Adds active-terminal plan type and shouldApplyPresetPaneName helper; sequential mode early-returns before the shared shouldUseActiveTab path, which is correct.
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useV2PresetExecution/useV2PresetExecution.ts Largest change: adds sequential execution, worktree-aware cwd, writeInput, and newTabPresets; writeInput (useMutation result) in the useCallback dep array may cause unnecessary callback recreation on mutation state changes.
apps/desktop/src/renderer/stores/tabs/useTabsWithPresets.ts Adds sequential path, buildFocusedTerminalCommand with cwd+cd, and preset pane labeling; openPresetInCurrentTerminal still writes raw commands without applying cwd, diverging from the new behavior in executePreset's active-terminal case.
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useWorkspacePaneOpeners/useWorkspacePaneOpeners.ts Adds addTerminalTab that runs applyOnNewTab presets on new tab creation; former blank-tab logic preserved as addBlankTerminalTab fallback.
packages/local-db/src/schema/zod.ts Adds sequential to EXECUTION_MODES and normalizeExecutionMode; parallel still maps to split-pane, correct.
apps/desktop/src/renderer/routes/_authenticated/settings/terminal/components/TerminalSettings/components/PresetRow/PresetRow.tsx Adds sequential display label ("All in current tab" / "Split pane"); the single-command sequential branch showing "Split pane" is unreachable from current callers but semantically inconsistent.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Trigger preset] --> B{target?}
    B -- new-tab forced\napplyOnNewTab / hotkey --> C[getPresetLaunchPlan\nmode=sequential\ntarget=new-tab]
    B -- active-tab\ndefault for sequential --> D{hasActiveTerminal?}
    D -- yes --> E[getPresetLaunchPlan\nreturns active-terminal]
    D -- no --> F[getPresetLaunchPlan\nreturns new-tab-single]
    C --> F
    E --> G[writeInput.mutateAsync\ncd cwd && combined-cmd\nto active terminal]
    G --> H{titleOverride set?}
    H -- no --> I[setPaneTitleOverride\npreset.name]
    H -- yes --> J[leave label unchanged]
    F --> K[launcher.create\ncommand + cwd\nnew terminal]
    K --> L[state.addTab\nnew tab with pane]
Loading

Comments Outside Diff (1)

  1. apps/desktop/src/renderer/stores/tabs/useTabsWithPresets.ts, line 466-480 (link)

    P2 cwd not applied in openPresetInCurrentTerminal

    This PR adds buildFocusedTerminalCommand (prepending cd <cwd> &&) to the active-terminal path in executePreset, fixing cwd preservation for sequential auto-launch. However, openPresetInCurrentTerminal — the explicit "run in current terminal" user action — still passes preset.commands directly to writeCommandsInPane without a cd prefix. A user with a preset that has a cwd set will find the directory silently ignored when they trigger this action, even after this PR.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: apps/desktop/src/renderer/stores/tabs/useTabsWithPresets.ts
    Line: 466-480
    
    Comment:
    **cwd not applied in `openPresetInCurrentTerminal`**
    
    This PR adds `buildFocusedTerminalCommand` (prepending `cd <cwd> &&`) to the `active-terminal` path in `executePreset`, fixing cwd preservation for sequential auto-launch. However, `openPresetInCurrentTerminal` — the explicit "run in current terminal" user action — still passes `preset.commands` directly to `writeCommandsInPane` without a `cd` prefix. A user with a preset that has a `cwd` set will find the directory silently ignored when they trigger this action, even after this PR.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
apps/desktop/src/renderer/stores/tabs/useTabsWithPresets.ts:466-480
**cwd not applied in `openPresetInCurrentTerminal`**

This PR adds `buildFocusedTerminalCommand` (prepending `cd <cwd> &&`) to the `active-terminal` path in `executePreset`, fixing cwd preservation for sequential auto-launch. However, `openPresetInCurrentTerminal` — the explicit "run in current terminal" user action — still passes `preset.commands` directly to `writeCommandsInPane` without a `cd` prefix. A user with a preset that has a `cwd` set will find the directory silently ignored when they trigger this action, even after this PR.

### Issue 2 of 2
apps/desktop/src/renderer/routes/_authenticated/settings/terminal/components/TerminalSettings/components/PresetRow/PresetRow.tsx:111-114
**Misleading label for single-command sequential preset**

When `modeValue === "sequential"` and `commands.length === 1`, the label resolves to `"Split pane"`, which is semantically wrong — sequential mode writes to the active terminal and never splits panes. The branch is unreachable today because both `PresetsSection` and `V2PresetsSection` normalise single-command sequential to `"split-pane"` before passing `modeValue`, but a future caller would display the wrong label. Consider using `"Current tab"` here instead.

Reviews (1): Last reviewed commit: "fix(desktop): preserve preset terminal l..." | Re-trigger Greptile

Comment on lines +111 to +114
: modeValue === "sequential"
? commands.length > 1
? "All in current tab"
: "Split pane"

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.

P2 Misleading label for single-command sequential preset

When modeValue === "sequential" and commands.length === 1, the label resolves to "Split pane", which is semantically wrong — sequential mode writes to the active terminal and never splits panes. The branch is unreachable today because both PresetsSection and V2PresetsSection normalise single-command sequential to "split-pane" before passing modeValue, but a future caller would display the wrong label. Consider using "Current tab" here instead.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/renderer/routes/_authenticated/settings/terminal/components/TerminalSettings/components/PresetRow/PresetRow.tsx
Line: 111-114

Comment:
**Misleading label for single-command sequential preset**

When `modeValue === "sequential"` and `commands.length === 1`, the label resolves to `"Split pane"`, which is semantically wrong — sequential mode writes to the active terminal and never splits panes. The branch is unreachable today because both `PresetsSection` and `V2PresetsSection` normalise single-command sequential to `"split-pane"` before passing `modeValue`, but a future caller would display the wrong label. Consider using `"Current tab"` here instead.

How can I resolve this? If you propose a fix, please make it concise.

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 19 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@Kitenite
Kitenite merged commit 4958881 into ParadevAI:main May 27, 2026
15 of 17 checks passed

This branch had an error being deployed

1 failed deployment
preview — 3b397975 Deployed May 27, 2026 by sshresthh via Deploy Database (Neon) #5780
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.

2 participants