Skip to content

fix(desktop): include agent args when launching v2 presets#4112

Merged
Kitenite merged 1 commit into
mainfrom
agent-presets-v2-update
May 5, 2026
Merged

fix(desktop): include agent args when launching v2 presets#4112
Kitenite merged 1 commit into
mainfrom
agent-presets-v2-update

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented May 5, 2026

Summary

  • V2 preset launches were using the agent's bare command and dropping its always-on args. Per the launch spec in packages/shared/src/host-agent-presets.ts, a no-prompt launch should resolve to [command, ...args].
  • Concrete fallout: clicking a v2 Claude preset launched claude instead of claude --permission-mode acceptEdits; same for codex's sandbox/reasoning flags, gemini's --approval-mode=auto_edit, copilot's --allow-tool=write. promptArgs (codex --, opencode --prompt, copilot -i) were correctly excluded already — only the always-on args were missing.
  • Adds buildAgentLaunchCommand in renderer/lib/agent-launch-command.ts and routes the three v2 call sites through it: useV2PresetExecution (live preset execution), V2PresetsSection quick-add pills, and PresetEditorDialog linked-agent preview.
  • Cleanup: hoisted argv.ts from V2AgentsSettings/utils/ to renderer/lib/argv.ts since it now has consumers in distant trees; the new helper reuses joinCommandArgs from there.

Test plan

  • Settings → Agents: edit Claude's command (e.g. add --verbose), open Settings → Terminal, click the Claude quick-add pill, confirm the preset's command is claude --permission-mode acceptEdits --verbose (or whatever the configured argv is).
  • Open a v2 workspace with a preset linked to an agent; click the preset; confirm the spawned terminal runs <command> <args> not just <command>.
  • Open the preset editor dialog for a linked-agent preset; confirm the live command preview shows [command, ...args].
  • Settings → Agents AgentDetail still loads, edits, and saves command/args (import path moved).

Summary by cubic

Fixes V2 preset launches so they include each agent’s always-on args. No-prompt launches now resolve to [command, ...args], restoring required flags (e.g., Claude permission-mode, Codex sandbox, Gemini approval, Copilot allow-tool).

  • Bug Fixes
    • Added buildAgentLaunchCommand to build command + args while excluding prompt args/transport.
    • Updated useV2PresetExecution, V2 quick-add pills, and Preset Editor preview to use the helper.
    • Hoisted argv.ts to renderer/lib/argv and updated imports.

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

Summary by CodeRabbit

  • Refactor
    • Improved agent launch command processing throughout the application by introducing centralized command building logic.
    • Updated workspace execution, agent settings, and terminal presets to use consistent command derivation, ensuring uniform behavior across different UI locations.

V2 preset paths were using the agent's bare `command` field, dropping
the always-on `args` (e.g. claude's `--permission-mode acceptEdits`,
codex's sandbox flags). Per the launch spec in `host-agent-presets.ts`,
no-prompt launches should resolve to `[command, ...args]`.

Adds `buildAgentLaunchCommand` in `renderer/lib/` and routes the three
v2 call sites through it (preset execution, quick-add pills, linked
preset editor). Hoists `argv.ts` out of `V2AgentsSettings/utils/` since
it now has consumers in distant trees.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 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: d976469d-13ae-45cd-8d42-a7050711f0b3

📥 Commits

Reviewing files that changed from the base of the PR and between 0db7cd4 and ea77a16.

📒 Files selected for processing (7)
  • apps/desktop/src/renderer/lib/agent-launch-command.ts
  • apps/desktop/src/renderer/lib/argv.test.ts
  • apps/desktop/src/renderer/lib/argv.ts
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useV2PresetExecution/useV2PresetExecution.ts
  • apps/desktop/src/renderer/routes/_authenticated/settings/agents/components/V2AgentsSettings/components/AgentDetail/AgentDetail.tsx
  • apps/desktop/src/renderer/routes/_authenticated/settings/terminal/components/TerminalSettings/components/PresetsSection/components/PresetEditorDialog/PresetEditorDialog.tsx
  • apps/desktop/src/renderer/routes/_authenticated/settings/terminal/components/TerminalSettings/components/V2PresetsSection/V2PresetsSection.tsx

📝 Walkthrough

Walkthrough

A new buildAgentLaunchCommand utility function is introduced to standardize how agent launch commands are constructed, replacing direct access to agent.command across multiple preset and agent configuration components.

Changes

Agent Command Utility Integration

Layer / File(s) Summary
Core Utility Definition
apps/desktop/src/renderer/lib/agent-launch-command.ts
New buildAgentLaunchCommand function wraps agent command and args into a shell command string via joinCommandArgs, omitting prompt-specific options.
Preset Execution Wiring
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useV2PresetExecution/useV2PresetExecution.ts
Preset-to-command mapping now derives commands using buildAgentLaunchCommand(agent) instead of direct agent.command access.
UI Component Integration
apps/desktop/src/renderer/routes/_authenticated/settings/terminal/components/TerminalSettings/components/PresetsSection/components/PresetEditorDialog/PresetEditorDialog.tsx, apps/desktop/src/renderer/routes/_authenticated/settings/terminal/components/TerminalSettings/components/V2PresetsSection/V2PresetsSection.tsx
Live command derivation for linked presets and QuickAddPresets pills updated to use buildAgentLaunchCommand instead of raw agent.command.
Import Path Rationalization
apps/desktop/src/renderer/routes/_authenticated/settings/agents/components/V2AgentsSettings/components/AgentDetail/AgentDetail.tsx
Import path for argv utilities changed from relative to absolute alias (renderer/lib/argv); no functional changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A command takes shape with a hop and a bind,
No prompt in sight, just args combined,
Four places now call the launch with care,
Standardized shells float through the air! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% 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 clearly summarizes the main fix: including agent args when launching v2 presets, which is the core purpose of this pull request.
Description check ✅ Passed The description includes all key template sections: a comprehensive Summary explaining the bug and fix, Related Issues context, Type of Change (bug fix), detailed Testing steps, and Additional Notes with the auto-generated summary.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent-presets-v2-update

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
Contributor

greptile-apps Bot commented May 5, 2026

Greptile Summary

This PR fixes v2 preset launches that were silently dropping the always-on args field from agent configs (e.g., claude launching without --permission-mode acceptEdits). It introduces buildAgentLaunchCommand in renderer/lib/agent-launch-command.ts to consistently build the full [command, ...args] string, and routes all three v2 call sites through it.

  • Bug fix: useV2PresetExecution, V2PresetsSection quick-add pills, and PresetEditorDialog linked-agent preview now all call buildAgentLaunchCommand(agent) instead of using agent.command alone — aligning actual terminal launch behavior with the spec in host-agent-presets.ts.
  • Refactor: argv.ts (and its test file) are hoisted from the deep V2AgentsSettings/utils/ tree to renderer/lib/ so the new helper and future consumers can share it without circular import concerns.

Confidence Score: 5/5

Safe to merge — the change is a targeted bug fix with no new logic beyond delegating to the existing, well-tested joinCommandArgs utility.

The fix is narrow: a one-line swap at each of the three affected call sites, unified through a thin, documented wrapper. The underlying joinCommandArgs has round-trip tests covering empty args, quoted paths with spaces, and known preset argv patterns. The live-lookup path in resolvePresetCommands correctly takes priority over stored commands for agent-linked presets, so existing rows in the database are unaffected in practice.

No files require special attention.

Important Files Changed

Filename Overview
apps/desktop/src/renderer/lib/agent-launch-command.ts New helper function that wraps joinCommandArgs to build the full no-prompt agent launch string (command + always-on args); clean and correctly scoped.
apps/desktop/src/renderer/lib/argv.ts File renamed/hoisted from V2AgentsSettings/utils/argv.ts to renderer/lib/argv.ts; no logic changes, purely a relocation to support broader consumers.
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useV2PresetExecution/useV2PresetExecution.ts agentCommandsById map now stores the full command+args string via buildAgentLaunchCommand; live lookup in resolvePresetCommands correctly takes priority over stored commands.
apps/desktop/src/renderer/routes/_authenticated/settings/terminal/components/TerminalSettings/components/V2PresetsSection/V2PresetsSection.tsx Quick-add pill creation now stores commands with full args via buildAgentLaunchCommand; deduplication and empty-command guard are preserved.
apps/desktop/src/renderer/routes/_authenticated/settings/terminal/components/TerminalSettings/components/PresetsSection/components/PresetEditorDialog/PresetEditorDialog.tsx Linked-agent command preview now uses buildAgentLaunchCommand to include args, matching actual launch behavior.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Agent Config\ncommand + args] --> B{Launch context}
    B -->|Quick-add pill\nV2PresetsSection| C[buildAgentLaunchCommand\ncommand + args]
    B -->|Live preset execution\nuseV2PresetExecution| D[buildAgentLaunchCommand\ncommand + args]
    B -->|Editor preview\nPresetEditorDialog| E[buildAgentLaunchCommand\ncommand + args]
    C --> F[Stored in DB\nas preset.commands]
    D --> G[Terminal spawn]
    E --> H[UI preview string]
    F --> I{resolvePresetCommands}
    I -->|agentId + live config found| D
    I -->|fallback| G
Loading

Reviews (1): Last reviewed commit: "fix(desktop): include agent args when la..." | Re-trigger Greptile

@Kitenite Kitenite merged commit 41d3941 into main May 5, 2026
10 checks passed
@Kitenite Kitenite deleted the agent-presets-v2-update branch May 5, 2026 22:33
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

saddlepaddle pushed a commit that referenced this pull request May 6, 2026
V2 preset paths were using the agent's bare `command` field, dropping
the always-on `args` (e.g. claude's `--permission-mode acceptEdits`,
codex's sandbox flags). Per the launch spec in `host-agent-presets.ts`,
no-prompt launches should resolve to `[command, ...args]`.

Adds `buildAgentLaunchCommand` in `renderer/lib/` and routes the three
v2 call sites through it (preset execution, quick-add pills, linked
preset editor). Hoists `argv.ts` out of `V2AgentsSettings/utils/` since
it now has consumers in distant trees.
MocA-Love added a commit to MocA-Love/superset that referenced this pull request May 21, 2026
superset-sh#4101 import agents as v2 terminal presets with live link:
- useV2PresetExecution.ts: drop upstream useV2AgentConfigs + useWorkspace
  import. useWorkspace arrives with superset-sh#4067 (cycle 44a WorkspaceProvider);
  fork keeps its workspaceId/projectId props until then.
- V2AgentsSettings.tsx: adopt upstream initialAgentPresetId prop and
  useV2AgentConfigs re-import (fork retains the hook elsewhere).
- PresetEditorDialog.tsx / V2PresetsSection.tsx: adopt upstream Switch /
  Link / ExternalLink additions for live-link UX.
- useMigrateV1PresetsToV2/: re-delete fork-removed hook; drop import
  from V2PresetsSection.tsx (call sites were stub-only).
- PresetEditorDialog.tsx: dedupe Switch import (one survived from each
  side of the merge).

superset-sh#4107 v2 preset commands in new tabs (skipped): introduces
useV2TerminalLauncher hook that takes a launcher prop through
useV2PresetExecution / useDefaultContextMenuActions / useDefaultPaneActions
/ useWorkspacePaneOpeners. This pattern is tightly coupled to superset-sh#4067's
WorkspaceProvider (workspaceId/projectId stop being passed down by page.tsx
and instead come from useWorkspace()). Deferred to cycle 44a so the
launcher and provider land together.

superset-sh#4112 include agent args (skipped): depends on superset-sh#4107.

superset-sh#4057 / superset-sh#4083 fix-compat:
- RunInWorkspacePopoverV2.tsx / OpenInWorkspaceV2.tsx: drop iconUrl from
  project map and ProjectThumbnail props; pass githubOwner={null} until
  cycle 41 (superset-sh#3823 v2 project icon settings) lands.

Phase 4 cycle 39 net: 3 cherry-picks landed (superset-sh#4057, superset-sh#4083, superset-sh#4101);
2 deferred to cycle 44a (superset-sh#4107, superset-sh#4112). useV2PresetExecution preserves
fork's workspaceId/projectId calling convention.
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