Skip to content

fix(desktop): run preset commands after initialization script - #848

Closed
chasemcdo wants to merge 2 commits into
ParadevAI:mainfrom
chasemcdo:fix-command-doesnt-run-if-init-script
Closed

chasemcdo wants to merge 2 commits into
ParadevAI:mainfrom
chasemcdo:fix-command-doesnt-run-if-init-script

Conversation

@chasemcdo

@chasemcdo chasemcdo commented Jan 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

When opening a workspace with a setup script configured, preset commands were not running after the initialization script completed. This was because useOpenWorktree bypassed the preset system entirely by using the raw addTab from the store instead of useTabsWithPresets.

This fix merges setup commands with preset commands so both run in sequence:

  1. Initialization script commands run first
  2. Preset commands run immediately after

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Documentation
  • Refactor
  • Other (please describe):

Testing

  1. Configure a workspace with a setup script in .superset/config.json
  2. Set a default preset with commands (e.g., echo "preset ran")
  3. Open the workspace (first terminal boot)
  4. Verify:
    • Setup script commands run first
    • Preset commands run immediately after
  5. Open a second terminal (split) - verify preset commands still run
  6. Open a workspace WITHOUT setup script - verify preset commands still run

Screenshots (if applicable)

N/A

Additional Notes

Resolves #834

The root cause was two-fold:

  1. useOpenWorktree used useTabsStore.addTab directly, bypassing useTabsWithPresets
  2. Even if it had used useTabsWithPresets, the logic was OR-based (options OR preset), not AND-based

The fix imports useTabsWithPresets, merges the command arrays ([...setupCommands, ...presetCommands]), and passes the combined commands explicitly to prevent double-application of presets.

Summary by CodeRabbit

  • New Features

    • Workspace terminals now apply preset configurations when opened.
    • Configuration prompt guides setup of workspaces without initial commands.
  • Bug Fixes

    • Corrected terminal working directory initialization for workspace presets.

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

When opening a workspace, preset commands were not running after the
initialization script because useOpenWorktree bypassed the preset system.
This merges setup commands with preset commands so both run in sequence
(setup first, then preset).
The initialCwd from the default preset was being computed but not
passed to createOrAttach, so custom working directories in presets
were not being applied to terminal sessions.
@coderabbitai

coderabbitai Bot commented Jan 20, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The PR modifies workspace opening logic to consume preset data via a new hook instead of direct store access. It merges initial commands from workspace setup with preset commands, sources the working directory from presets, adjusts tab titling based on command presence, and conditions toast notifications on available initialization commands.

Changes

Cohort / File(s) Summary
Workspace Opening with Preset Integration
apps/desktop/src/renderer/react-query/workspaces/useOpenWorktree.ts
Replaces useTabsStore with useTabsWithPresets to obtain both addTab and defaultPreset. Merges setup commands with preset commands into a single initialCommands array; sources initialCwd from defaultPreset.cwd. Adjusts tab title to "Workspace Setup" if setup commands exist, otherwise uses preset name or defaults to "Terminal". Introduces conditional toast behavior: shows config prompt only when initialCommands is empty. Propagates merged commands and cwd through tab creation and mutation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 Presets and setup commands dance together now,
Merged in harmony through the preset's vow,
Working directories bloom from preset's ground,
Toast appears gently when no commands are found,
Workspace opens brighter, with logic so sound! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: fixing preset commands to run after initialization script in the desktop application.
Description check ✅ Passed The description is comprehensive, covering the bug explanation, solution approach, detailed testing steps, and root cause analysis matching the template structure.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

@chasemcdo
chasemcdo marked this pull request as draft January 20, 2026 14:00
@chasemcdo chasemcdo closed this Jan 20, 2026
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.

[terminal presets] if you have a setup script configured terminal presets don't run

1 participant