Skip to content

add branch name suggestions - #1578

Closed
KayleeWilliams wants to merge 2 commits into
stablyai:mainfrom
KayleeWilliams:branch-name-suggestions
Closed

KayleeWilliams wants to merge 2 commits into
stablyai:mainfrom
KayleeWilliams:branch-name-suggestions

Conversation

@KayleeWilliams

@KayleeWilliams KayleeWilliams commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds an experimental, opt-in branch name suggestion flow for Orca-created local worktrees. When a supported agent reports done and the branch has commits, Orca asks that same agent for a cleaner branch slug and shows it in the workspace card for the user to apply or dismiss.

Screenshots

CleanShot 2026-05-07 at 21 41 24@2x CleanShot 2026-05-07 at 21 56 49@2x

Testing

  • pnpm lint

  • pnpm typecheck

  • pnpm test

  • pnpm build

  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

    AI Review Report

Reviewed the branch suggestion lifecycle, eligibility gates, apply/dismiss IPC path, renderer metadata propagation, settings copy, and sidebar UI.

Main risks checked:

  • Suggestions only run when the experimental
    setting is enabled.
  • Existing worktrees are not retroactively
    eligible.
  • SSH worktrees are skipped for v1.
  • Unsupported agents are ignored.
  • Branches with upstreams or same-name remote
    branches are skipped.
  • Branch changes between suggestion and apply are
    detected.
  • Apply revalidates the suggested branch before
    running git branch -m.
  • Renderer receives persisted branchNameSuggestion
    metadata through worktree merging.
  • The UI remains user-confirmed: no silent branch
    rename.

Review also checked cross-platform concerns for
macOS, Linux, and Windows:

  • Git/process calls use argv arrays, not shell
    strings.
  • File/path handling uses Node path utilities
    where needed.
  • No platform-specific keyboard shortcut behavior
    was introduced.
  • SSH repos are explicitly skipped instead of
    running local CLIs against remote code.

Changes made during review:

  • Added quiet main-process diagnostics for
    skipped/failed suggestion attempts.
  • Fixed settings/search copy to match actual
    behavior.
  • Ensured apply can update the default display
    name without overwriting custom titles.

Security Audit

Reviewed command execution, IPC, path handling, and input validation risks.

Security notes:

  • Agent CLIs are spawned with argv arrays and
    shell: false.
  • Agent stdin is bounded/truncated, stdout/stderr
    are capped, and execution is timeboxed.
  • Agent output is treated as an untrusted branch
    slug: sanitized, prefix-preserved, validated
    with git check-ref-format --branch, and checked
    for local/remote conflicts.
  • IPC apply/dismiss actions re-read persisted
    state and revalidate before mutating git state.
  • SSH worktrees are skipped for v1 to avoid
    running local agents against remote code.
  • No secrets or dependency changes were
    introduced.

Follow-up: consider a future debug surface for
failed suggestions if this graduates from
experimental.

Notes

This is intentionally opt-in and requires restart because managed hook installation happens at startup.

The Edit Worktree Details modal still edits display metadata only. Full git branch rename should remain a separate branch-management action because it needs conflict checks, upstream/remote handling, and SSH-specific behavior.

Risk: medium
Historic risk metadata backfill based on the existing risk:medium label.

@nwparker

Copy link
Copy Markdown
Contributor

Have not forgotten 🫡

@nwparker nwparker assigned brennanb2025 and unassigned nwparker May 10, 2026
@nwparker
nwparker requested review from brennanb2025 and removed request for nwparker May 10, 2026 18:22
@nwparker

Copy link
Copy Markdown
Contributor

PR #1487 is related

@brennanb2025

Copy link
Copy Markdown
Contributor

Thanks for putting this together! I’m taking a bit of caution before merging this because branch renames have some sharp edges in multi-agent workspaces.

The overall shape seems reasonable: suggest a name from actual committed work, then require the user to explicitly apply it. I want to tighten a few guardrails first around running agents that may still have the old branch name in context, pushed branches / existing PRs, stale remote refs, and re-checking safety at Apply time if the branch state changed after the suggestion was generated.

I’ll take a pass at tightening those up tomorrow!

Thanks again!

@nwparker
nwparker force-pushed the branch-name-suggestions branch from c175e5a to abcb044 Compare May 29, 2026 12:05
@nwparker

Copy link
Copy Markdown
Contributor

Coordinator evidence update for PR #1578 (no merge performed):

Status: needs-ci. I rebased the branch on current main and pushed abcb044e238a7d0c63735d21afd465aa4fd50610 with --force-with-lease.

What changed during takeover:

  • Kept branch-name suggestions opt-in and local-only.
  • Added/verified SSH and unsupported-agent skips.
  • Hardened agent output handling with byte caps, slug sanitization, git check-ref-format, upstream/remote/same-branch conflict checks, and stale-branch revalidation before apply.
  • Added paired-web preload stubs so remote/browser clients do not rename branches.
  • Covered the workspace-card apply/dismiss affordance and settings/search path.

Evidence:

  • pnpm exec vitest run --config config/vitest.config.ts src/main/branch-name-suggestions.test.ts src/main/ipc/worktrees.test.ts src/main/ipc/worktree-logic.test.ts src/main/git/worktree.test.ts src/shared/constants.test.ts src/renderer/src/components/settings/ExperimentalPane.test.tsx src/renderer/src/components/sidebar/WorktreeCard.quick-actions.test.tsx src/renderer/src/web/web-preload-api.test.ts src/main/codex-accounts/service.test.ts src/main/codex-accounts/runtime-home-service.test.ts passed: 10 files, 296 tests.
  • pnpm typecheck passed.
  • pnpm lint passed with 0 warnings / 0 errors.
  • git diff --check origin/main..HEAD passed.
  • git merge-tree --write-tree --name-only origin/main HEAD passed (ac50a956719e94b3742559906d5183d0cdf9297f3).
  • GitHub currently reports MERGEABLE / UNSTABLE with no checks reported on the branch.

Residual risk: no full Electron screenshot was captured; UI proof is component-level plus runtime/IPC tests because a real proof would require driving a managed-agent completion hook.

@nwparker

Copy link
Copy Markdown
Contributor

Merge-forwarded this branch onto current origin/main and pushed commit f87066f2042e623176511ea1899759d1040688b6.

Reproduction / resolution:

  • Reproduced the GitHub conflict locally with git merge origin/main.
  • Conflicts were in src/renderer/src/components/settings/ExperimentalPane.tsx and src/renderer/src/components/settings/experimental-search.ts.
  • Resolved by keeping both additive Experimental settings: this PR's Branch name suggestions setting/search entry plus main's Smart New Tab menu setting/search entry.

Evidence after the merge-forward:

  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/settings/ExperimentalPane.test.tsx src/main/branch-name-suggestions.test.ts src/main/agent-hooks/first-work-branch-rename.test.ts src/shared/branch-name-from-work.test.ts src/shared/constants.test.ts src/renderer/src/store/slices/worktrees.test.ts src/renderer/src/web/web-preload-api.test.ts src/main/text-generation/commit-message-text-generation.test.ts -> 8 files / 181 tests passed.
  • pnpm run typecheck:web passed.
  • pnpm run typecheck:node passed.
  • pnpm exec oxlint src/renderer/src/components/settings/ExperimentalPane.tsx src/renderer/src/components/settings/ExperimentalPane.test.tsx src/renderer/src/components/settings/BranchNameSuggestionsSetting.tsx src/renderer/src/components/settings/experimental-search.ts src/main/branch-name-suggestions.ts src/main/branch-name-suggestions.test.ts src/main/branch-name-suggestion-agent.ts src/main/agent-hooks/first-work-branch-rename.ts src/main/agent-hooks/first-work-branch-rename.test.ts src/shared/branch-name-from-work.ts src/shared/branch-name-from-work.test.ts src/shared/constants.ts src/shared/constants.test.ts src/renderer/src/store/slices/worktrees.ts src/renderer/src/store/slices/worktrees.test.ts src/renderer/src/web/web-preload-api.ts src/renderer/src/web/web-preload-api.test.ts src/preload/api-types.ts src/preload/index.ts -> 0 warnings / 0 errors.
  • git diff --check HEAD^..HEAD passed.
  • git merge-tree --write-tree origin/main HEAD passed with tree 4f10a65fda58c0a39c536ce12d0aca3b5793bea0.
  • GitHub now reports mergeable: MERGEABLE, mergeStateStatus: UNSTABLE; no checks are currently reported on the branch.

Did not merge.

@nwparker

Copy link
Copy Markdown
Contributor

@brennanb2025 You are working on this, right?

@nwparker nwparker added the risk:medium Medium risk change label May 30, 2026
@brennanb2025

Copy link
Copy Markdown
Contributor

Really sorry about the communication delay here, we ended up adding this feature here as the 'Auto-rename branch' in settings.
image

We decided it was a bit safer to rename the branch based on the first message sent to an agent. Sorry about the delay getting back to you on this again. Appreciate the PR though, it was helpful as reference for the final implementation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:medium Medium risk change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants