Skip to content

Feature/automation agent args 11043 - #11873

Open
hdsheena wants to merge 6 commits into
stablyai:mainfrom
hdsheena:feature/automation-agent-args-11043
Open

hdsheena wants to merge 6 commits into
stablyai:mainfrom
hdsheena:feature/automation-agent-args-11043

Conversation

@hdsheena

@hdsheena hdsheena commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds per-automation agent args so a scheduled automation can pass extra CLI flags (e.g. --yolo) to its agent without changing the global default args for that agent or project — exactly the request in #11043 ("I want my automation to run as yolo, but i strictly DONT want this as default").

New agentArgs field on the automation model, settable from:

  • GUI — "Agent args" text input in the automation editor dialog (e.g. --yolo --verbose)
  • CLI — orca automations create/edit --agent-args "--yolo" and visible in orca automations show (agentArgs: <value> | none)

When unset, existing behavior is preserved: automations keep the global default args (e.g. claude's --dangerously-skip-permissions). Only a non-empty value overrides.

Screenshots

  • UI: new "Agent args" input in the automation editor dialog — screenshot to add
  • CLI: agentArgs: none / agentArgs: --yolo --verbose lines in automations show

Testing

  • pnpm lint — could not run in sandbox: oxlint crashes with a Rust allocator panic (reproduces on unmodified code; CI will run it)
  • pnpm typecheck — typecheck:node and typecheck:cli pass. typecheck:web was OOM-killed by the kernel in this 5 GB sandbox (reproduces on unmodified code — environment limit, not a code error)
  • pnpm test — 95 focused tests pass across 8 automation suites (launch, dispatch hook, CLI format, run identity, headless workspace create, runtime automations, schedule picker, service)
  • pnpm build — not run in sandbox
  • Added high-quality regression tests (4 new):
    • launch-agent-background-session.test.ts — per-automation args override the global default (claude '--yolo' '--verbose' 'run the automation' + launchConfig), and null/empty fall back to the global defaults
    • useAutomationDispatchEvents.test.ts — automation.agentArgs is forwarded to the background session launch
    • cli/format.test.ts — automations show prints agentArgs: none / agentArgs: --yolo --verbose

AI Review Report

AI review checked: the defaults-fallback contract, the full create→persist→dispatch→launch pipeline, RPC/Zod round-trip, i18n key registration, GUI draft wiring, CLI flag parsing, and multi-flag tokenization/quoting.

Flagged & fixed: the initial launch fallback treated a stored null agentArgs (legacy/empty automations) as an explicit empty override, silently dropping global defaults (e.g. --dangerously-skip-permissions). Fixed so only a non-empty string overrides; null/''/unset all fall back to the global defaults, preserving behavior for existing automations. Covered by the new tests.

Cross-platform (macOS/Linux/Windows) confirmed: no keyboard shortcuts, shortcut labels, or file paths were touched, and no Electron menu/platform APIs. The new string flows through the existing shared startup-plan builder (tokenizeStartupCommand + quoteStartupArg), the same shell-quoting used for prompts on every platform — including WSL (wsl.exe shell override) and SSH/remote launches, which route through the identical background-session spawn path with no platform-specific branches added.

Security Audit

  • Input handling: agentArgs is a free-text string; the RPC layer validates it as a nullable string via the existing OptionalNullablePlainString Zod schema (same helper as baseBranch). No max length is enforced — consistent with existing free-text fields; a bound could be added later if untrusted users can author automations.
  • Command execution: the value is tokenized and shell-quoted by the existing startup-plan builder before embedding in the agent launch command — same trust model as the existing prompt field. No raw shell interpolation; multi-flag input (--yolo --verbose) is split into individually quoted tokens.
  • Path handling / auth / secrets: none touched; no new IPC surface (only new params on existing automation.create/automation.update).
  • Follow-up: none required for this change.

Notes

  • CLI parity: new --agent-args flag on automations create/edit; automations show includes the field; edit without the flag leaves the stored value unchanged.
  • i18n: 3 new keys registered in en.json; verify-localization-extraction and verify-localization-catalog both pass.

@hdsheena
hdsheena requested a review from brennanb2025 as a code owner August 1, 2026 02:40
@greptile-apps

greptile-apps Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

Greptile Summary

Adds a per-automation agentArgs field that lets a scheduled automation pass extra CLI flags (e.g. --yolo) to its agent launch without touching the global default args. The field flows end-to-end: GUI text input → draft → automation.create/update RPC → persistence → dispatch → launchAgentBackgroundSession, with a correct three-way null/empty/whitespace guard that falls back to the global defaults for legacy automations.

  • Type layer (automations-types.ts): agentArgs: string | null on Automation, optional on create/update inputs; Zod OptionalNullablePlainString validates the RPC boundary.
  • Launch layer (launch-agent-background-session.ts, useAutomationDispatchEvents.ts): non-empty agentArgs overrides resolveTuiAgentLaunchArgs; a session-reuse path is short-circuited when agentArgs is set so the override is actually honoured.
  • CLI (handlers/automations.ts, specs/automations.ts): --agent-args flag added to AUTOMATION_STATE_FLAGS; create/edit handlers propagate it; show prints agentArgs: none or the value; four new regression tests cover the dispatch and launch paths.

Confidence Score: 5/5

Safe to merge — the new field is optional everywhere, legacy automations without agentArgs fall back to global defaults through a well-guarded code path, and the session-reuse bypass correctly forces a fresh launch when an override is present.

The change is additive and narrowly scoped: a new nullable string field propagated through the existing create→persist→dispatch→launch pipeline. The null/empty fallback logic is covered by regression tests, the Zod validator reuses an established helper, and all four draft initializers in the GUI account for the field. The previous reviewer's flag-duplication concern does not exist in the current HEAD (the flag appears in AUTOMATION_STATE_FLAGS exactly once).

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
src/shared/automations-types.ts Adds `agentArgs: string
src/renderer/src/lib/launch-agent-background-session.ts Core logic: uses a three-way guard (!== undefined && !== null && trim().length > 0) before preferring args.agentArgs over resolveTuiAgentLaunchArgs; handles null, undefined, and whitespace-only strings correctly to preserve global defaults for legacy automations.
src/renderer/src/hooks/useAutomationDispatchEvents.ts Forces a fresh session when agentArgs is non-empty (so the override is actually honoured), and threads agentArgs through to launchAgentBackgroundSession; the ?.trim() guard handles null/undefined for legacy automations correctly.
src/main/persistence.ts Stores agentArgs: input.agentArgs ?? null on create; update relies on ...updates spread which preserves the existing value when the key is absent (serialized through IPC/JSON, so undefined keys are dropped). No migration needed for the JSON persistence layer.
src/cli/specs/automations.ts Adds 'agent-args' to AUTOMATION_STATE_FLAGS only; both create and edit already spread the whole array, so there is no duplication in allowedFlags. The previous-reviewer concern about a duplicate entry does not apply to the current HEAD.
src/cli/handlers/automations.ts getOptionalAgentArgsFlag correctly distinguishes flag-absent (→ undefined, preserves existing value on edit) from flag-present-but-empty (→ null, clears stored value) and flag-with-value (→ trimmed string).
src/main/runtime/rpc/methods/automations.ts Adds agentArgs: OptionalNullablePlainString to both AutomationCreate and AutomationUpdateFields Zod schemas, reusing the same validator already used for baseBranch.
src/renderer/src/components/automations/AutomationEditorDialogFooter.tsx Adds the "Agent args" Input field wired to draft.agentArgs with proper i18n keys, placeholder, and aria-label.
src/renderer/src/components/automations/AutomationsPage.tsx All four draft initializers add agentArgs; two new-automation paths use '', the edit-existing path uses latest.agentArgs ?? '' to handle legacy nulls, and the Hermes template path uses ''. On save both create and update paths use `draft.agentArgs.trim()
src/renderer/src/lib/launch-agent-background-session.test.ts New tests verify per-automation args produce the expected shell command and launchConfig, and that null/''/whitespace-only all fall back to the global --dangerously-skip-permissions default.
src/renderer/src/hooks/useAutomationDispatchEvents.test.ts New tests confirm agentArgs is forwarded to the background session launch and that a reusable session is bypassed when agentArgs is non-empty.

Sequence Diagram

sequenceDiagram
    participant UI as AutomationEditorDialog
    participant Page as AutomationsPage
    participant RPC as automation.create/update RPC
    participant Store as persistence.ts (Store)
    participant Dispatch as useAutomationDispatchEvents
    participant Launch as launchAgentBackgroundSession

    UI->>Page: "onDraftChange({ agentArgs: "--yolo" })"
    Page->>RPC: "{ agentArgs: draft.agentArgs.trim() || null }"
    RPC->>RPC: OptionalNullablePlainString validates
    RPC->>Store: createAutomation / updateAutomation
    Store->>Store: agentArgs: input.agentArgs ?? null

    Note over Dispatch: Automation run dispatched
    Dispatch->>Dispatch: "reuseSession && !agentArgs?.trim() => skip session reuse if agentArgs set"
    Dispatch->>Launch: "{ agentArgs: automation.agentArgs }"
    Launch->>Launch: agentArgs truthy? use agentArgs else resolveTuiAgentLaunchArgs
    Launch->>Launch: buildAgentStartupPlan(agentArgs)
    Launch-->>Dispatch: session launched
Loading

Reviews (2): Last reviewed commit: "fix(automations): address PR review feed..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Automations now support nullable per-automation agent arguments across shared types, RPC schemas, persistence, CLI commands, and the renderer editor. CLI and UI inputs trim blank values to null. Automation displays include configured arguments. Background, terminal, and headless launches forward non-empty arguments, use configured defaults for blank values, and bypass reusable sessions when custom arguments are configured. Tests cover parsing, persistence, rendering, draft handling, and launch behavior.

Merge Risk: ⚪ Minimal · up to 70c9f

The PR adds per-automation agent arguments while preserving existing defaults. The remaining concern is limited to using the shared input styling in the editor, which is a localized consistency follow-up and does not present an actionable merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change and testing, but required visual proof is still marked for addition and the linked issue is not formatted in the required section. Add the required before-and-after UI proof, format the linked issue as Fixes #11043``, and complete applicable checklist items.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding agent arguments to automations, with the related issue number included.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
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.

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/renderer/src/hooks/useAutomationDispatchEvents.ts (1)

519-525: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Do not ignore agentArgs when a reusable session is selected.

When automation.reuseSession finds a reusable session, execution returns before launchAgentBackgroundSession runs. The current automation.agentArgs is then not applied. An automation changed from empty arguments to --yolo can continue using a session created with the old arguments.

Include normalized agentArgs in reusable-session compatibility, or start a fresh session when the configured arguments differ. Add a regression test for the reuse path.

This follows the PR objective that non-empty values override global defaults.

🧹 Nitpick comments (2)
src/cli/specs/automations.ts (1)

54-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the duplicate agent-args entries.

AUTOMATION_STATE_FLAGS already contains 'agent-args'. The explicit entries add the same flag twice to both allowedFlags arrays. Remove the explicit entries, or deduplicate the list before generating help and validation metadata.

Proposed fix
       ...AUTOMATION_SCHEDULE_FLAGS,
-      'agent-args',
       ...AUTOMATION_STATE_FLAGS

Apply the same change to the automations edit specification.

Also applies to: 87-88

src/renderer/src/lib/launch-agent-background-session.test.ts (1)

624-646: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover whitespace-only overrides.

The implementation uses trim().length > 0, so whitespace-only values are part of the fallback contract. This test covers null and '' only. Add a launch with agentArgs: ' ' and assert that the global default remains in the spawned command.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 85bba80e-a48c-475b-b6a1-eb238c49fdb9

📥 Commits

Reviewing files that changed from the base of the PR and between 402e492 and 7bade8ecf8861c201b22c835be30383764da4dda.

📒 Files selected for processing (20)
  • src/cli/format.test.ts
  • src/cli/handlers/automations.ts
  • src/cli/specs/automations.ts
  • src/cli/workspace-format.ts
  • src/main/automations/headless-workspace-create.test.ts
  • src/main/persistence.ts
  • src/main/runtime/orca-runtime-automations.test.ts
  • src/main/runtime/rpc/methods/automations.ts
  • src/renderer/src/components/automations/AutomationEditorDialog.tsx
  • src/renderer/src/components/automations/AutomationEditorDialogFooter.tsx
  • src/renderer/src/components/automations/AutomationSchedulePicker.test.ts
  • src/renderer/src/components/automations/AutomationsPage.tsx
  • src/renderer/src/hooks/useAutomationDispatchEvents.test.ts
  • src/renderer/src/hooks/useAutomationDispatchEvents.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/lib/agent-background-session-contract.ts
  • src/renderer/src/lib/launch-agent-background-session.test.ts
  • src/renderer/src/lib/launch-agent-background-session.ts
  • src/shared/automation-run-identity.test.ts
  • src/shared/automations-types.ts

Comment thread src/cli/workspace-format.ts Resolved
@WaltherMuurmans

Copy link
Copy Markdown

Review of #11873 — built and measured against pr11873 (HEAD 92cd0f2)

Context for why we looked: we run six scheduled automations that each need to launch
claude with --dangerously-skip-permissions --disable-slash-commands --agent <name>,
set up from the CLI. This PR is exactly the feature we've been waiting for, so we
checked out the branch, installed it, ran the suites, and probed the paths we depend on.

Two blockers on the CLI path, plus three smaller notes. Everything below was verified
in this branch; where we measured rather than read, the measurement is included.

What we verified works

  • argv fidelity is exact. planAgentCliArgsSuffix tokenizes quote-aware and then
    re-quotes per token (src/shared/tui-agent-startup-shell.ts:114-130), which is the
    right order. Measured against buildAgentStartupPlan (agent claude, platform linux):

    in:  --dangerously-skip-permissions --disable-slash-commands --agent beheer-doctor
    out: claude '--dangerously-skip-permissions' '--disable-slash-commands' '--agent' 'beheer-doctor' '<prompt>'
    
    in:  --model 'claude opus' --append-system-prompt="a b" --agent beheer-doctor
    out: claude '--model' 'claude opus' '--append-system-prompt=a b' '--agent' 'beheer-doctor' '<prompt>'
    

    Spaces, the --flag=value form and quotes all survive intact.

  • The three-way fallback guard is right, and it is on exactly one line
    (src/renderer/src/lib/launch-agent-background-session.ts:57-60): undefined, null
    and whitespace-only all fall back to the global defaults; only a non-empty value
    overrides. That is what [Feature] automation cannot set params on agents #11043 asked for.

  • PR suites are green: 76 tests across launch-agent-background-session,
    useAutomationDispatchEvents, cli/format, automation-run-identity,
    headless-workspace-create, AutomationSchedulePicker. (orca-runtime-automations
    did not load here — we installed with --ignore-scripts, so native node-pty was not
    built. That is our environment, not your PR.)

1. Blocker — the runtime drops agentArgs, so the whole CLI/RPC path is a no-op

OrcaRuntimeService.createAutomation builds an explicit field list for the store
and agentArgs is not in it (src/main/runtime/orca-runtime.ts:3549-3567).
updateAutomation has fourteen hasRuntimeAutomationUpdateValue branches
(:3575-3617) — name, prompt, precheck, agentId, runContext, sourceContext,
baseBranch, setupDecision, reuseSession, timezone, rrule, dtstart, enabled,
missedRunGraceMinutes — and none for agentArgs. This branch does not touch
orca-runtime.ts at all (git show --stat over the three commits: zero hits).

So the chain is: CLI sends it (src/cli/handlers/automations.ts:470, :496) → RPC
schema accepts it (src/main/runtime/rpc/methods/automations.ts:120, :142) → runtime
silently discards it → Store.createAutomation writes agentArgs: input.agentArgs ?? null
(src/main/persistence.ts:4894). Net effect: orca automations create --agent-args "…"
stores null and reports success.

TypeScript can't catch it: agentArgs is optional on the create input
(src/shared/automations-types.ts:168) and the update input is a Partial<Pick<…>>.

This is asymmetric by transport, not by feature. The local GUI writes straight to the
store over Electron IPC (src/main/ipc/automations.ts:56), so the new editor field
works. Everything over RPC — the entire CLI, and the GUI against a remote host — loses
the value.

Worth noting why the green suites don't contradict this: every link in the chain is
covered separately, and the missing link sits between them. A single test that goes
CLI flag → RPC → runtime → store and asserts the stored value would have caught it, and
would keep catching it.

2. Blocker — the documented invocation form doesn't parse

parseArgs turns a flag into boolean true as soon as the next token starts with --
(src/cli/args.ts:119-124), and agent-args is not in BOOLEAN_FLAGS. The comment
right above says it explicitly (:96-99): --flag=value is the only unambiguous form
for a value that itself starts with --.

That is precisely what --agent-args always carries. Measured by calling parseArgs
directly:

['automations','create','--agent-args','--dangerously-skip-permissions --disable-slash-commands --agent beheer-doctor']
  -> agent-args = true
  -> plus a bogus flag "dangerously-skip-permissions --disable-slash-commands --agent beheer-doctor"

['automations','create','--agent-args','--yolo']        # the example at src/cli/specs/automations.ts:70
  -> agent-args = true
  -> plus a bogus flag "yolo"

['automations','create','--agent-args=--dangerously-skip-permissions --disable-slash-commands --agent beheer-doctor']
  -> agent-args = "--dangerously-skip-permissions --disable-slash-commands --agent beheer-doctor"   ✅

The first two then fail in validateCommandAndFlags with Unknown flag …
(src/cli/args.ts:303-308). So the example in the spec notes does not work as written,
and since passing flags is the purpose of this option, this affects most real
invocations. Either document the = form (and fix the example), or special-case this
flag in the parser. We've switched our own tooling to --agent-args=<value> and it
parses correctly.

3. The headless/serve dispatcher never forwards agentArgs

When there is no live renderer and a headless dispatcher is configured (serve mode,
src/main/index.ts:2355), dispatch goes through requestHeadlessDispatch. Neither
branch carries the value:

  • new_per_run: buildHeadlessAutomationWorktreeCreateArgs returns createdWithAgent,
    startupAgent, startupPrompt and no agentArgs
    (src/main/automations/headless-workspace-create.ts:35-46).
  • existing workspace: launchAgentTerminal is called with { agent, prompt, title }
    only (src/main/index.ts:2389-2396).

Both end in buildStartupForAgent, which hardcodes
agentArgs: resolveTuiAgentLaunchArgs(agent, settings.agentDefaultArgs)
(src/main/runtime/orca-runtime.ts:20205). Serve-mode runs therefore silently use the
global defaults — the exact thing #11043 wants to avoid. The PR's only change here is a
fixture line agentArgs: null (src/main/automations/headless-workspace-create.test.ts:25)
with no assertion on forwarding, and the toMatchObject at :68-91 wouldn't catch a
regression either.

4. One of the new assertions can't fail

src/renderer/src/hooks/useAutomationDispatchEvents.test.ts:712 asserts
expect(mockSubmitPromptToAgentTab).not.toHaveBeenCalled(). The module mock only
provides submitPromptToAgentTab (:129), but the hook imports and calls
submitPromptToAgentPty (src/renderer/src/hooks/useAutomationDispatchEvents.ts:6, :450).
Repo-wide, submitPromptToAgentTab has zero call sites — only its definition at
src/renderer/src/lib/agent-paste-draft.ts:170 and this mock.

The real protection in that test is
expect(mockFindReusableAutomationSession).not.toHaveBeenCalled() (:708), which does
fail if the guard is reverted. Suggest dropping line 712, or mocking
submitPromptToAgentPty and asserting on that instead. (The stale mock predates this
PR; only the assertion is new.)

5. Minor — legacy records have no agentArgs key, which makes capability detection unreliable

Stored automations are read back unchanged
(src/main/persistence.ts:3505: automations: Array.isArray(parsed.automations) ? parsed.automations : []),
with no per-field backfill, and agentArgs is only written on create/update. So an
automation created before the upgrade simply has no agentArgs key.

The code handles that correctly everywhere (?. / explicit undefined checks), so this
is not a bug. But it does mean a consumer cannot use automations list --json to detect
whether this build supports the field — on our machine all existing automations predate
it. Emitting agentArgs: null for legacy records would make the field's presence a
reliable capability signal.


Happy to re-test any of this against a follow-up commit — we have the branch built
locally. Findings 1 and 2 are the ones that block CLI-driven use; 3–5 are smaller.

@AmethystLiang
AmethystLiang requested a review from OrcaWin August 7, 2026 16:48
@hdsheena
hdsheena force-pushed the feature/automation-agent-args-11043 branch from 92cd0f2 to 9acecc5 Compare August 8, 2026 20:33
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
src/main/runtime/orca-runtime.ts (1)

21226-21232: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider an options object for buildStartupForAgent's growing parameter list.

buildStartupForAgent now takes 5 positional parameters, with launchPreferences and agentArgs both optional and adjacent. Both current call sites pass arguments in the correct order, but a future caller can silently swap launchPreferences and agentArgs (both accept undefined) without a type error, since neither parameter's type discriminates from the other's undefined case.

Convert the trailing optional parameters to a single options object to make call sites self-documenting and remove the ordering risk.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a52972b3-1c3c-46bc-8ea4-126f6241a6b4

📥 Commits

Reviewing files that changed from the base of the PR and between 04f7123 and 9acecc56e0f4d5c34c466320c14076ef81a4e5a8.

📒 Files selected for processing (28)
  • src/cli/args.test.ts
  • src/cli/args.ts
  • src/cli/format.test.ts
  • src/cli/handlers/automations.ts
  • src/cli/specs/automations.ts
  • src/cli/workspace-format.ts
  • src/main/automations/headless-workspace-create.test.ts
  • src/main/automations/headless-workspace-create.ts
  • src/main/index.ts
  • src/main/persistence.ts
  • src/main/runtime/orca-runtime-automations.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/automations.ts
  • src/renderer/src/components/automations/AutomationEditorDialog.tsx
  • src/renderer/src/components/automations/AutomationEditorDialogFooter.tsx
  • src/renderer/src/components/automations/AutomationSchedulePicker.test.ts
  • src/renderer/src/components/automations/AutomationsPage.tsx
  • src/renderer/src/components/automations/automation-host-client.test.ts
  • src/renderer/src/components/automations/automation-run-view-state.test.ts
  • src/renderer/src/components/automations/automation-target-availability.test.ts
  • src/renderer/src/hooks/useAutomationDispatchEvents.test.ts
  • src/renderer/src/hooks/useAutomationDispatchEvents.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/lib/agent-background-session-contract.ts
  • src/renderer/src/lib/launch-agent-background-session.test.ts
  • src/renderer/src/lib/launch-agent-background-session.ts
  • src/shared/automation-run-identity.test.ts
  • src/shared/automations-types.ts
🚧 Files skipped from review as they are similar to previous changes (18)
  • src/main/runtime/orca-runtime-automations.test.ts
  • src/renderer/src/components/automations/AutomationSchedulePicker.test.ts
  • src/renderer/src/components/automations/AutomationEditorDialog.tsx
  • src/shared/automation-run-identity.test.ts
  • src/renderer/src/lib/launch-agent-background-session.test.ts
  • src/cli/format.test.ts
  • src/cli/handlers/automations.ts
  • src/main/runtime/rpc/methods/automations.ts
  • src/cli/workspace-format.ts
  • src/renderer/src/lib/launch-agent-background-session.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/hooks/useAutomationDispatchEvents.test.ts
  • src/renderer/src/hooks/useAutomationDispatchEvents.ts
  • src/cli/specs/automations.ts
  • src/renderer/src/components/automations/AutomationEditorDialogFooter.tsx
  • src/renderer/src/components/automations/AutomationsPage.tsx
  • src/renderer/src/lib/agent-background-session-contract.ts
  • src/shared/automations-types.ts

@hdsheena

hdsheena commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review and testing! I've rebased the branch on the latest main and addressed all findings:

1. Blocker — the runtime drops agentArgs on the RPC path

  • Resolution: Modified createAutomation and updateAutomation in src/main/runtime/orca-runtime.ts to map agentArgs correctly. createAutomation now forwards agentArgs: input.agentArgs to the store, and updateAutomation checks and applies updates.agentArgs using the hasRuntimeAutomationUpdateValue helper.

2. Blocker — the documented invocation form doesn't parse

  • Resolution: Special-cased the agent-args flag in the CLI argument parser parseArgs (src/cli/args.ts) so that it consumes the next token as its value even if it starts with -- (e.g. --agent-args --dangerously-skip-permissions).
  • Tests: Added a regression test accepts a space-separated flag value starting with -- for --agent-args in src/cli/args.test.ts to verify it parses correctly.

3. The headless/serve dispatcher never forwards agentArgs

  • Resolution: Threaded the configuration end-to-end for serve-mode runs:
    • Modified buildHeadlessAutomationWorktreeCreateArgs (src/main/automations/headless-workspace-create.ts) to return agentArgs: automation.agentArgs ?? undefined.
    • Added optional agentArgs?: string | null arguments to createManagedWorktree, launchAgentTerminal, and buildStartupForAgent in src/main/runtime/orca-runtime.ts.
    • Inside buildStartupForAgent, applied the same three-way guard to use custom agentArgs over default settings args if present.
    • Inside src/main/index.ts, passed automation.agentArgs into the launchAgentTerminal call for existing workspaces.
    • Added a regression test threads agentArgs through if non-empty in src/main/automations/headless-workspace-create.test.ts.

4. One of the new assertions can't fail

  • Resolution: Replaced the mock of the unused submitPromptToAgentTab function with submitPromptToAgentPty inside src/renderer/src/hooks/useAutomationDispatchEvents.test.ts (mocking it from @/lib/agent-paste-draft). Updated the assertion to check expect(mockSubmitPromptToAgentPty).not.toHaveBeenCalled().

5. Minor — legacy records have no agentArgs key

  • Resolution: Added a backfill inside the load() method in src/main/persistence.ts to map any loaded automation record without an agentArgs key to null on startup, setting this.loadNeedsSave = true so the persistence file heals.

6. Bonus — Test Type Safety

  • Resolution: Fixed TypeScript errors in automation-host-client.test.ts, automation-run-view-state.test.ts, and automation-target-availability.test.ts where spreading overrides into mocked Automation instances broke due to missing properties. Spreads are now typed cleanly.

@nwparker nwparker removed the P2 label Aug 19, 2026
hdsheena and others added 6 commits August 23, 2026 17:24
…r scheduled runs

Adds agentArgs to the Automation model, CLI create/edit --agent-args flag, and a GUI field in the automation editor. Params flow through RPC validation, persistence, and the dispatch pipeline so scheduled runs can pass extra agent CLI flags without changing global defaults. Also surfaces agentArgs in automations show output and registers new i18n keys.
…args are unset

The launch fallback treated a stored null agentArgs as an explicit empty override, silently dropping global defaults (e.g. claude --dangerously-skip-permissions) for legacy and empty-field automations. Only a non-empty string now overrides; null/empty falls back to the global defaults. Adds tests covering the override and fallback paths, the dispatch forwarding, and the automations show output.
Removes duplicate --agent-args entries from the create/edit CLI specs (it now appears once, via AUTOMATION_STATE_FLAGS). Treats blank/whitespace agentArgs as unset in automations show output. Skips session reuse when a non-empty agentArgs is configured, since the live session launch flags cannot be verified, and launches fresh instead. Adds a regression test for the reuse path and a whitespace-only fallback case.
Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
@hdsheena
hdsheena force-pushed the feature/automation-agent-args-11043 branch from 9acecc5 to 70c9f5a Compare August 24, 2026 02:19
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a9c0716d-fc8d-42f4-926a-0a2b81d014a0

📥 Commits

Reviewing files that changed from the base of the PR and between 55258f3 and 70c9f5a.

📒 Files selected for processing (32)
  • src/cli/args.test.ts
  • src/cli/args.ts
  • src/cli/format.test.ts
  • src/cli/handlers/automations.ts
  • src/cli/specs/automations.ts
  • src/cli/workspace-format.ts
  • src/main/automations/headless-workspace-create.test.ts
  • src/main/automations/headless-workspace-create.ts
  • src/main/index.ts
  • src/main/persistence/scheduling-automations/automation-definition-operations.ts
  • src/main/runtime/orca-runtime-automations.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/automations.ts
  • src/renderer/src/components/automations/AutomationEditorDialog.tsx
  • src/renderer/src/components/automations/AutomationEditorSettingsSidebar.tsx
  • src/renderer/src/components/automations/AutomationListLocalRows.test.tsx
  • src/renderer/src/components/automations/AutomationSchedulePicker.render.test.tsx
  • src/renderer/src/components/automations/AutomationSchedulePicker.test.ts
  • src/renderer/src/components/automations/AutomationsPage.tsx
  • src/renderer/src/components/automations/automation-host-client.test.ts
  • src/renderer/src/components/automations/automation-list-last-run.test.ts
  • src/renderer/src/components/automations/automation-list-view.test.ts
  • src/renderer/src/components/automations/automation-run-view-state.test.ts
  • src/renderer/src/components/automations/automation-target-availability.test.ts
  • src/renderer/src/hooks/useAutomationDispatchEvents.test.ts
  • src/renderer/src/hooks/useAutomationDispatchEvents.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/lib/agent-background-session-contract.ts
  • src/renderer/src/lib/launch-agent-background-session.test.ts
  • src/renderer/src/lib/launch-agent-background-session.ts
  • src/shared/automation-run-identity.test.ts
  • src/shared/automations-types.ts
🚧 Files skipped from review as they are similar to previous changes (26)
  • src/renderer/src/components/automations/AutomationEditorDialog.tsx
  • src/cli/handlers/automations.ts
  • src/main/automations/headless-workspace-create.test.ts
  • src/shared/automation-run-identity.test.ts
  • src/cli/args.test.ts
  • src/cli/args.ts
  • src/main/runtime/rpc/methods/automations.ts
  • src/main/index.ts
  • src/renderer/src/components/automations/automation-run-view-state.test.ts
  • src/main/runtime/orca-runtime-automations.test.ts
  • src/renderer/src/components/automations/AutomationSchedulePicker.test.ts
  • src/renderer/src/components/automations/automation-host-client.test.ts
  • src/cli/workspace-format.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/lib/agent-background-session-contract.ts
  • src/renderer/src/lib/launch-agent-background-session.test.ts
  • src/renderer/src/lib/launch-agent-background-session.ts
  • src/renderer/src/hooks/useAutomationDispatchEvents.ts
  • src/renderer/src/components/automations/automation-target-availability.test.ts
  • src/main/automations/headless-workspace-create.ts
  • src/cli/format.test.ts
  • src/cli/specs/automations.ts
  • src/renderer/src/components/automations/AutomationsPage.tsx
  • src/main/runtime/orca-runtime.ts
  • src/shared/automations-types.ts
  • src/renderer/src/hooks/useAutomationDispatchEvents.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment on lines +112 to +125
<input
value={draft.agentArgs}
onChange={(event) =>
onDraftChange((current) => ({ ...current, agentArgs: event.target.value }))
}
placeholder={translate(
'auto.components.automations.AutomationEditorDialog.7d5e8b3f01',
'e.g. --yolo'
)}
aria-label={translate(
'auto.components.automations.AutomationEditorDialog.2c4a9f6e01',
'Extra agent launch arguments'
)}
className="h-9 w-full min-w-0 rounded-md border border-input bg-input/30 px-3 text-sm shadow-xs outline-none focus-visible:border-ring dark:bg-input/30"

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use the shared shadcn input primitive.

This renderer UI change uses a native <input>. Use the existing input primitive from src/renderer/src/components/ui/ so the field follows the shared styling and behavior.

As per coding guidelines, renderer UI must use shadcn primitives from src/renderer/src/components/ui/.

Source: Coding guidelines

This branch has not been deployed

No deployments
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.

5 participants