fix(desktop): include agent args when launching v2 presets#4112
Conversation
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughA new ChangesAgent Command Utility Integration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Greptile SummaryThis PR fixes v2 preset launches that were silently dropping the always-on
Confidence Score: 5/5Safe 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.
|
| 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
Reviews (1): Last reviewed commit: "fix(desktop): include agent args when la..." | Re-trigger Greptile
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
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.
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.
Summary
commandand dropping its always-onargs. Per the launch spec inpackages/shared/src/host-agent-presets.ts, a no-prompt launch should resolve to[command, ...args].claudeinstead ofclaude --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-onargswere missing.buildAgentLaunchCommandinrenderer/lib/agent-launch-command.tsand routes the three v2 call sites through it:useV2PresetExecution(live preset execution),V2PresetsSectionquick-add pills, andPresetEditorDialoglinked-agent preview.argv.tsfromV2AgentsSettings/utils/torenderer/lib/argv.tssince it now has consumers in distant trees; the new helper reusesjoinCommandArgsfrom there.Test plan
--verbose), open Settings → Terminal, click the Claude quick-add pill, confirm the preset's command isclaude --permission-mode acceptEdits --verbose(or whatever the configured argv is).<command> <args>not just<command>.[command, ...args].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).
buildAgentLaunchCommandto build command + args while excluding prompt args/transport.useV2PresetExecution, V2 quick-add pills, and Preset Editor preview to use the helper.argv.tstorenderer/lib/argvand updated imports.Written for commit ea77a16. Summary will update on new commits.
Summary by CodeRabbit