Skip to content

fix(automations): let 'automations edit --base-branch=' clear the saved base branch - #52235

Merged
nwparker merged 2 commits into
stablyai:mainfrom
SeungWoonSong:fix/automations-edit-clear-base-branch
Nov 29, 2026
Merged

nwparker merged 2 commits into
stablyai:mainfrom
SeungWoonSong:fix/automations-edit-clear-base-branch

Conversation

@SeungWoonSong

@SeungWoonSong SeungWoonSong commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

If an automation was set to start each run from a particular branch, you can now clear that choice from the command line, and it goes back to the repository's default branch.

What Changed

  • Before: orca automations edit <id> --base-branch= exited 0 but kept the old branch, because the flag reader dropped empty strings. --base-branch ' ' saved three spaces as the branch name.
  • After: an empty or whitespace-only value on edit sends baseBranch: null, which clears the override. Branch values are trimmed on both create and edit, so ' main ' saves main. On create, a blank value leaves the field out, so the default applies. Leaving the flag off still keeps the saved value. A bare --base-branch with no value is still rejected with invalid_argument.
  • How: a new getBaseBranchFlag in src/cli/automations/automation-handler-flags.ts reuses the existing getOptionalStringFlagAllowingEmpty reader and maps blank values to null. The update RPC already accepts that through OptionalNullablePlainString. The help text for edit now shows how to reset.

Why

Scripts got a success exit code while the automation kept its old override or saved a ref that cannot work. Clearing with a blank value works the same way as the existing --precheck "" reset, and matches how the desktop automation editor already clears the base branch (it sends null). No new flag or contract change was needed.

Linked Issue

Fixes #52229

Visual Proof

N/A for screenshots: this changes CLI behavior only, with no UI change. Terminal transcripts from a disabled test automation (from the original PR, Linux headless server), each run starting with release saved:

Before
$ orca automations edit <id> --base-branch= --json      # exit 0
$ orca automations show <id> --json  ->  "baseBranch": "release"
$ orca automations edit <id> --base-branch '   ' --json # exit 0
$ orca automations show <id> --json  ->  "baseBranch": "   "
After
$ orca automations edit <id> --base-branch= --json      # exit 0
$ orca automations show <id> --json  ->  "baseBranch": null
$ orca automations edit <id> --base-branch '   ' --json # exit 0
$ orca automations show <id> --json  ->  "baseBranch": null

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Every added test fails without this change and avoids the test anti-patterns

  • automation-base-branch-round-trip.test.ts runs real argv parsing, the edit handler, AutomationUpdate schema validation after a JSON round-trip, and the real automation definition store. It covers empty (null), whitespace-only (null) and padded (main) values. On the old CLI, the empty and whitespace cases fail.

  • automation-handler-flags.test.ts checks that create sends undefined for a blank value and main for ' main '.

  • An extra probe on macOS checked: --base-branch=, "" and "\t \n" give null; --base-branch=origin/main is kept; " feature/x\t" becomes feature/x; leaving the flag off gives undefined; a bare flag and --base-branch --json both throw; null survives JSON plus schema validation on update; create never sends null.

  • On macOS, vitest run src/cli/automations/ plus the round-trip test passed (8 files, 52 tests). oxlint, oxfmt, anti-slop, native code-quality plugins, ast-grep and the changed-code quality gate are all clean on the touched files.

  • The original PR was also verified on Linux x86_64 against an isolated headless server.

Performance

None, because this only runs once per orca automations create/edit CLI call, to parse one flag. It adds no RPCs, storage writes, polling or subprocesses. A microbenchmark (bun, 200k iterations) measured, old vs new: typical main 33 vs 25 ns/call; flag omitted 13 vs 13 ns/call; adversarial 20k-character padded value 9 ns vs 6.5 µs (the cost of the trim, paid once per CLI process).

Risk

Level: Low

Scripts that passed an empty value as a placeholder will now clear the saved override. To keep it, they can leave the flag off. Branch names with leading or trailing whitespace are now trimmed (git refs cannot contain them anyway). The change uses the update RPC's existing nullable baseBranch field, so it needs no migration, and older runtimes and remote hosts already accept null. Reverting the commit restores the old CLI behavior. Base branches already cleared stay cleared.

Review

Reviewed the parsing for --base-branch=, --base-branch ' ' and bare --base-branch, and the nullable path from the update RPC through the runtime patch into the definition store. The string handling works the same on every platform. Help text notes that --base-branch= is the safer form on Windows PowerShell 5.1, which can drop "" arguments.

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

Original fix by @SeungWoonSong in #52235. Authorship is preserved on the landing commit, and the maintainer follow-ups (trimming, create coverage, help text) are squashed in with a Co-authored-by trailer.

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 (or CI will cover; local preferred)

@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge; no blocking issues were found.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

The PR lets automations edit --base-branch= clear the saved branch. It also trims branch values and documents how to reset them.

  • Automation edits can reset the saved base branch to the repository default.

Reviews (4) · Last reviewed commit: "test(automations): move the base-branch ..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The CLI now parses --base-branch as absent, blank, or nonblank. Create commands map absent or blank values to undefined. Edit commands pass blank values as null and trim nonblank values. The CLI notes explain how to restore the repository default. Tests cover create arguments and the schema-validated edit payload.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to d4534

Passing an empty or whitespace-only base branch when editing an automation now clears the saved override, and omitting the flag still keeps it. The change is small, covered by tests, and no merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix and the behavior change: an empty value for 'automations edit --base-branch=' clears the saved base branch. It matches the code changes (getBaseBranchFlag maps blank values to …
Description check Passed The description follows the repository template closely. It has ELI5, What Changed (before/after and mechanism), Why, Linked Issue (Fixes #52229), Visual Proof (N/A with reason and CLI transcripts), T…
Linked Issues check Passed Issue #52229 requires three behaviors for automations edit: an explicitly blank --base-branch clears the override so show reports baseBranch: null; a whitespace-only value must not be saved as…
Out of Scope Changes check Passed The changed files connect to the --base-branch reset in #52229. automation-handler-flags.ts adds getBaseBranchFlag, which implements the blank-to-null mapping and trimming. automations.ts us…
Full details: Title check

Explanation

The title names the fix and the behavior change: an empty value for 'automations edit --base-branch=' clears the saved base branch. It matches the code changes (getBaseBranchFlag maps blank values to null, which clears the override on edit) and the linked issue. It is specific and within the 72-character guideline's spirit, though at 83 characters it is slightly long.

Full details: Description check

Explanation

The description follows the repository template closely. It has ELI5, What Changed (before/after and mechanism), Why, Linked Issue (Fixes #52229), Visual Proof (N/A with reason and CLI transcripts), Testing with checkboxes and specific tests, Performance with a concrete justification, Risk with level and rollback, AI Disclosure left blank (permitted for maintainers), Review, Agent skill boundary, Notes, and Checklist. The content is specific and technically detailed, so it is complete.

Full details: Linked Issues check

Explanation

Issue #52229 requires three behaviors for automations edit: an explicitly blank --base-branch clears the override so show reports baseBranch: null; a whitespace-only value must not be saved as-is; and omitting the flag keeps the saved branch. At the reviewed head, getBaseBranchFlag in src/cli/automations/automation-handler-flags.ts returns undefined when the flag is absent (getOptionalStringFlagAllowingEmpty returns undefined) and value.trim() || null otherwise. So --base-branch= and --base-branch ' ' both map to null, and padded values are trimmed. In src/cli/automations/automations.ts, the edit handler passes baseBranch: getBaseBranchFlag(flags) into automation.update. An absent flag gives undefined, which the update omits. The create handler uses getBaseBranchFlag(flags) ?? undefined, so a blank create value (null) becomes undefined and the default applies. This matches the issue's expected behavior and the create behavior it cites. Limits of this review: the whole-PR text diff was unavailable, so the incremental changes were checked only through current file contents. The round-trip test and the update RPC's nullable path were not read in this review. The reset result relies on the head source plus the PR's reported test and manual verification.

Full details: Out of Scope Changes check

Explanation

The changed files connect to the --base-branch reset in #52229. automation-handler-flags.ts adds getBaseBranchFlag, which implements the blank-to-null mapping and trimming. automations.ts uses it for the edit and create parameters. src/cli/specs/automations.ts adds help text that documents the reset syntax for the same flag. automation-handler-flags.test.ts and automation-base-branch-round-trip.test.ts cover the create and edit behavior for this flag. The raw summaries list no unrelated files or behavior changes. The trimming applies to the same flag on create and edit, which the PR describes and which is in scope for the linked issue's create-versus-edit comparison. Limits: the whole-PR text diff was unavailable, so this conclusion relies on the head file reads and the file summaries.

  • 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: 127b868b-1963-46d5-9f03-1fbd5ac7b24f
Commits

Reviewing files that changed from the base of the PR and between 26f4023 and d45340e.

Files selected for processing: 1

  • src/cli/automations/automation-base-branch-round-trip.test.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.

`orca automations edit --base-branch=` (or a whitespace-only value) now
clears the saved base branch so new-per-run automations fall back to the
repository default. Previously the empty value was dropped and whitespace
was saved as a branch name. Values are trimmed on create and edit, and
edit help documents the reset syntax.

Fixes stablyai#52229

Co-authored-by: Neil <[email protected]>
@nwparker
nwparker force-pushed the fix/automations-edit-clear-base-branch branch from a1aee02 to 26f4023 Compare November 29, 2026 04:29
@nwparker nwparker changed the title fix(automations): allow clearing the CLI base branch override fix(automations): let 'automations edit --base-branch=' clear the saved base branch Nov 29, 2026
The main typecheck project can't see CLI files, so a src/main test importing
them failed TS6307. The test now asserts the edit RPC's parsed updates instead
of importing main persistence code.
@nwparker
nwparker merged commit 6148927 into stablyai:main Nov 29, 2026
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]: Cannot clear an automation's base branch from the CLI

2 participants