Skip to content

fix(automations): keep a saved precheck timeout when automations edit omits it - #51741

Merged
nwparker merged 1 commit into
stablyai:mainfrom
2SinceJuly:fix/51720-precheck-timeout-preserved
Nov 28, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
2SinceJuly:fix/51720-precheck-timeout-preserved

Conversation

@2SinceJuly

@2SinceJuly 2SinceJuly commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

An automation can run a check command before each scheduled run, and that check has a time limit. Editing the automation, even just retyping the same check command, quietly reset that limit to the 60 second default. There was also no way to change only the limit. Now an edit that leaves a precheck flag out keeps what was saved, and the limit can be changed on its own.

What Changed

Before: orca automations edit <id> --precheck "<cmd>" without --precheck-timeout replaced the saved timeout with 60, with no message. --precheck-timeout on its own was refused with --precheck-timeout requires --precheck.

After:

edit flags saved before what is stored
--precheck C only {C, 120} {C, 120}, timeout kept
--precheck C2 only {C, 120} {C2, 120}, timeout kept
--precheck-timeout 300 only {C, 120} {C, 300}, command kept
neither flag {C, 120} untouched (precheck not sent)
--precheck "" {C, 120} precheck removed
--precheck C only none saved {C, 60}, default as on create
--precheck-timeout 300 only none saved refused: nothing to retime
--precheck-timeout 601 any refused before any runtime call

Mechanism: automations edit built updates.precheck with the create helper, which fills the default whenever --precheck is present and cannot see the saved value. The precheck flag logic now lives in src/cli/automations/automation-precheck-flag.ts as two steps:

  • readPrecheckFlags parses and validates the flags. It runs before the automation is read, so a malformed or over-limit flag still fails without a runtime call.
  • resolvePrecheck(flags, savedPrecheck) merges them with the saved precheck once resolveAutomationMutationState has read the automation.

create, watch-pr and bot create call getPrecheckFlag, which is resolvePrecheck(readPrecheckFlags(flags), null), so they behave exactly as before. The CLI help for automations edit and the bundled orca-cli automations reference now describe the edit behaviour.

Why

The bug is silent data loss: a timeout set on purpose gets replaced by a default with no warning. Warning the user would not fix the second half of the report, that the timeout could not be changed on its own. Resolving against the saved record follows the same rule --setup on edit already uses (an omitted flag keeps the saved choice), so --precheck now matches the flag beside it.

Linked Issue

Fixes #51720

Visual Proof

N/A. This changes CLI flag handling only and has no UI or interaction change. The stored value shows in orca automations show <id> --json, and the table above is the before/after.

Testing

  • I manually tested these changes locally: ran the new handler tests plus an extra probe suite (new command keeps the saved timeout, timeout-only 600 keeps the command, timeout-only 601 is rejected before any runtime call) against main and against this branch. On main, 6 of 16 fail. On this branch, all pass.
  • Automated tests added/updated: src/cli/automations/automation-edit-precheck.test.ts drives the real automations edit handler through the real argument parser with a stub runtime client.
  • Every added test fails without this change. The tests that keep passing on main are guards (create default, --precheck "" removal, no runtime call on a bad flag).

Commands:

  • pnpm vitest run src/cli/automations/: 6 files, 44 tests pass on the landing commit, rebased on current main.
  • Touched files pass oxlint (default, anti-slop and code-quality native configs), ast-grep, oxfmt and the changed-code quality gate.

Platforms: macOS. The change is platform-independent argument parsing and reads no path, shell or host.

Performance

None, because this only runs once per orca automations edit / create invocation in the CLI process, never on an app hot path. It adds no runtime calls: edit already read the automation for the owner fence, and the precheck is resolved from that same read. Microbenchmark of flag resolution: create 36.5 ns/op, edit 43.0 ns/op with a 10-char command, and 34.9 / 38.2 ns/op with a 100,000-char command.

Risk

Level: Low

The riskiest part is that --precheck-timeout alone used to be an error and now writes an update when the automation has a saved precheck. Retiming is the obvious meaning of that command, and with no saved precheck it is still refused. Mixed-version hosts are fine: the CLI sends the same AutomationPrecheck shape { command, timeoutSeconds } as before, and omitting precheck from updates already meant "keep" on every host. To back it out, revert this commit. Automations edited while the fix was live keep whatever timeout they were given.

Review

  • Correctness: each behaviour in the table has a handler-level test.
  • Backwards compatibility: create, watch-pr and bot create keep the exact old precheck semantics.
  • Security: no new trusted input. The timeout still goes through the positive-integer parse and the 600 s ceiling, and is only stored, never used to build a command.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

No impact on security, cross-platform behaviour, SSH/remote, mobile or performance.

Original fix by @2SinceJuly in #51741. Their authorship is kept on the landing commit. Maintainer follow-ups: validate the precheck flags before reading the automation, share one resolver between create and edit, and document the edit behaviour in the CLI help and the skill guide.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (targeted checks run locally; CI covers the full suites)

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The CLI now parses precheck flags separately from other automation flags. During edits, omitted flags preserve the saved precheck, a timeout-only flag retimes the saved command, and an empty command clears the precheck. The change adds tests for these behaviors and invalid flags, and updates CLI documentation.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 5828c

This change makes automations edit keep the saved precheck timeout unless a new one is given, and allows changing only the timeout. It is limited to CLI flag handling and has test coverage, so it carries no meaningful merge risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed Issue #51720 requires two behaviours on automations edit: (1) a --precheck edit without --precheck-timeout keeps the saved timeout, and (2) --precheck-timeout alone updates the saved timeout. …
Out of Scope Changes check Passed The automations.ts diff from merge base to head touches only the precheck edit path. The update payload change ({...updates, precheck?, bot?}) keeps the previous behaviour for bot and other fields…
Title check Passed The title names the main change: a saved precheck timeout is kept when automations edit omits it. It matches the code changes, which resolve precheck flags against the saved value. It uses the conve…
Description check Passed The description follows the template. It covers ELI5, what changed (a before/after table and mechanism), why, a linked issue (Fixes #51720), N/A visual proof with reason, testing, a performance line, …
Full details: Linked Issues check

Explanation

Issue #51720 requires two behaviours on automations edit: (1) a --precheck edit without --precheck-timeout keeps the saved timeout, and (2) --precheck-timeout alone updates the saved timeout. At head, resolvePrecheck in src/cli/automations/automation-precheck-flag.ts covers both. When command is undefined and a timeout is given, it returns {command: savedPrecheck.command, timeoutSeconds}, and it refuses only when no precheck is saved. When --precheck C is given without a timeout, it uses savedPrecheck?.timeoutSeconds before the 60 s default. In automations.ts, resolvePrecheck(precheckFlags, current.precheck) runs after the current automation is read, and precheck enters updates only when defined, so an omitted flag leaves the stored value unchanged. getPrecheckFlag still uses resolvePrecheck(..., null), so create and watch-pr keep the 60 s default. The author reports regression tests in automation-edit-precheck.test.ts and a red-state check; I did not open that test file, so test coverage rests on the author's report.

Full details: Out of Scope Changes check

Explanation

The automations.ts diff from merge base to head touches only the precheck edit path. The update payload change ({...updates, precheck?, bot?}) keeps the previous behaviour for bot and other fields. The move of precheck helpers to automation-precheck-flag.ts is a refactor, and automation-handler-flags.ts re-exports them, so importers resolve. The automation-bot-create.ts import change follows from that move. The src/cli/specs/automations.ts, skill-guides/orca-cli/references/automations.md, and bundled-skill-guides.ts edits document the edited precheck behaviour, which supports the fix. No unrelated behaviour change appears in the reviewed code.

Full details: Title check

Explanation

The title names the main change: a saved precheck timeout is kept when automations edit omits it. It matches the code changes, which resolve precheck flags against the saved value. It uses the conventional fix(scope) form and is specific enough for a reviewer scanning history.

Full details: Description check

Explanation

The description follows the template. It covers ELI5, what changed (a before/after table and mechanism), why, a linked issue (Fixes #51720), N/A visual proof with reason, testing, a performance line, risk with level and back-out steps, AI disclosure left blank, the upstream boundary checkbox, and the checklist. Remaining gaps are small: the AI Disclosure section is empty, the Review and Notes sections are informal, and the final lint/typecheck/test/build checkbox is unchecked with a stated reason. The author's testing notes also differ from the objectives on the test count (44 tests vs 42), which is minor.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 39b7da7c-345f-4a78-8cd4-8f7a82f8875c
Commits

Reviewing files that changed from the base of the PR and between 4d8728c and 5828c72.

Files selected for processing: 7

  • skill-guides/orca-cli/references/automations.md
  • src/cli/automations/automation-bot-create.ts
  • src/cli/automations/automation-edit-precheck.test.ts
  • src/cli/automations/automation-handler-flags.ts
  • src/cli/automations/automation-precheck-flag.ts
  • src/cli/automations/automations.ts
  • src/cli/skills/bundled-skill-guides.ts
Files with no reviewable changes: 1

  • src/cli/automations/automation-handler-flags.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

…t` omits it

`automations edit --precheck <cmd>` reused the create helper, which filled
the 60 s default whenever `--precheck` was passed without
`--precheck-timeout`, silently replacing a saved timeout. `--precheck-timeout`
alone was refused, so the limit could not be changed on its own.

Parse the precheck flags before the automation read (so a malformed flag
still fails without a runtime call), then resolve them against the saved
precheck: an omitted flag keeps the stored value, `--precheck-timeout` alone
retimes the saved command, and it is still refused when nothing is saved.
Create and watch-pr build their precheck from the same resolver with no
saved value, so their behaviour is unchanged.

Fixes stablyai#51720

Co-authored-by: Neil <[email protected]>
@nwparker
nwparker force-pushed the fix/51720-precheck-timeout-preserved branch from 4d8728c to 5828c72 Compare November 28, 2026 10:59
@nwparker nwparker changed the title fix(automations): keep a saved precheck timeout when an edit omits it fix(automations): keep a saved precheck timeout when automations edit omits it Nov 28, 2026
@nwparker
nwparker merged commit 6e775f8 into stablyai:main Nov 28, 2026
59 of 60 checks passed
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.

[Bug]: orca automations edit --precheck resets the saved precheck timeout to 60 s unless --precheck-timeout is passed again

2 participants