Repository navigation
fix(automations): keep a saved precheck timeout when automations edit omits it - #51741
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
…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]>
4d8728c to
5828c72
Compare
automations edit omits it
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-timeoutreplaced the saved timeout with60, with no message.--precheck-timeouton its own was refused with--precheck-timeout requires --precheck.After:
--precheck Conly{C, 120}{C, 120}, timeout kept--precheck C2only{C, 120}{C2, 120}, timeout kept--precheck-timeout 300only{C, 120}{C, 300}, command kept{C, 120}prechecknot sent)--precheck ""{C, 120}--precheck Conly{C, 60}, default as on create--precheck-timeout 300only--precheck-timeout 601Mechanism:
automations editbuiltupdates.precheckwith the create helper, which fills the default whenever--precheckis present and cannot see the saved value. The precheck flag logic now lives insrc/cli/automations/automation-precheck-flag.tsas two steps:readPrecheckFlagsparses 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 onceresolveAutomationMutationStatehas read the automation.create,watch-prand bot create callgetPrecheckFlag, which isresolvePrecheck(readPrecheckFlags(flags), null), so they behave exactly as before. The CLI help forautomations editand 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
--setupon edit already uses (an omitted flag keeps the saved choice), so--prechecknow 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
600keeps the command, timeout-only601is rejected before any runtime call) againstmainand against this branch. Onmain, 6 of 16 fail. On this branch, all pass.src/cli/automations/automation-edit-precheck.test.tsdrives the realautomations edithandler through the real argument parser with a stub runtime client.mainare 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 currentmain.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/createinvocation 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-timeoutalone 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 sameAutomationPrecheckshape{ command, timeoutSeconds }as before, and omittingprecheckfromupdatesalready 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
Agent skill upstream boundary
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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (targeted checks run locally; CI covers the full suites)