Skip to content

Keep worktree branches unless CLI deletion is requested - #35948

Merged
brennanb2025 merged 10 commits into
mainfrom
brennanb2025/lu-rm-keep-branch
Oct 30, 2026
Merged

brennanb2025 merged 10 commits into
mainfrom
brennanb2025/lu-rm-keep-branch

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1231 $\color{#cf222e}{\Huge{\mathbf{−}}}$​45 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1186
Prod 24 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​371 $\color{#cf222e}{\Huge{\mathbf{−}}}$​86 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​285

orca worktree rm could delete the worktree’s branch after the command returned. On updated hosts, removal now keeps that branch by default; use --delete-branch to request the existing safe branch cleanup. --force does not imply branch deletion. Desktop deletion keeps its existing behavior.

Host running the worktree Plain rm or rm --force rm --delete-branch
Updated host with the new behavior Removes the worktree and keeps its branch. Folder entries are classified by the host and keep their directory. Requests safe branch cleanup after worktree removal. Safety checks can retain the branch; the command reports the host’s result.
Older host, including older SSH and paired hosts Sends the same removal request as before. The older host keeps its existing branch behavior, which may delete the branch. A warning explains that keep-by-default does not apply on that host. Also uses the unchanged legacy request. The older host’s existing policy controls branch cleanup; the flag cannot override it. The command reports the returned result and does not claim a kept or deleted branch when the host has not confirmed that outcome.

Background acceptance is reported as removal in progress, not completed branch cleanup. Existing dirty-worktree, main-worktree, unmerged-branch and expected-head safety checks remain in force.

The CLI checks the executing host on the same connection that sends removal. A missing branch-choice capability selects the legacy request; a failed status, authentication or protocol check is an error and sends no removal. The original selector and host routing stay unchanged. Older CLIs, desktop and phone callers still omit the new field and retain their existing metadata policy.

Optional branch intent is resolved once into the removal job’s existing saved boolean. Background completion, partial recovery and restart retain that accepted choice. A conflicting choice cannot silently join or retry an accepted job. No new saved field or second cleanup operation is added.

The common pattern makes branch cleanup explicit. Intended differences are the existing metadata policy for legacy callers, host-owned completion across disconnect/restart, multiple-host routing, and safe branch cleanup that may retain unmerged or replaced work. Unserved SSH targets retain their existing refusal and do not fall back to the client’s Git.

Tracked in STA-10355.

Validation: real CLI arguments pass through local and authenticated paired sockets, the RPC dispatcher, runtime lifecycle and real temporary Git repos. The updated typed fixture uses actual folder/catalog/selector producers. Focused verification included 124 passing tests with 16 Windows-only skips, followed by 62 passing integration/transport cases and 23 passing real-runtime integration cases after fixture repairs; these are separate invocations, not additive unique-test totals. Additional targeted runs covered accepted-job recovery, complete failed retry and settlement, raw legacy payloads, status/dispatch timeouts, safe branch/head cleanup, current/WSL selection, archive hooks and unchanged desktop/web consumers. The served-environment test uses the production route with an authenticated loopback receiver and separate client repo; it does not claim a live SSH-daemon run.

QA classification is qa=tests: CLI/transport integration and existing removal-intent recovery. No rendered UI, provider login, native-chat lifecycle or process-ownership implementation changed, so no app, agent, emulator or screenshot run is required. Final-head CI passes, including mobile, all twelve unit shards, static analysis/typecheck, Linux/Windows packaging, WSL and SSH Docker checks. The real-runtime integration also passes under the CI Bun runner after its cross-runtime exit-status cleanup was corrected.

Full review path applies: this changes a deletion default, cross-version RPC intent and durable removal behavior across more than five production files. It is not eligible for the light path. A reviewed plan and full design-panel settlement precede the compatibility repair. Normal precommit and final CI passed. Source review, the full design-panel settlement and the fresh convergence check are complete; no blocking finding remains. No merge or release is included.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 29, 2026 15:03
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Summary

orca worktree rm now keeps Git branches unless the user passes --delete-branch.

  • Git worktree removal keeps the branch unless the CLI asks to delete it.
  • The runtime carries the branch choice through accepted worktree cleanup.

No actionable issues found. Tests were inspected, not run during this review.

Compatibility note: brennanb2025 explicitly identifies older-runtime refusal as an open compatibility decision. No finding reported.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  CLI["orca worktree rm"] --> Kind{"Folder workspace?"}
  Kind -->|Yes| Folder["Pin workspace ID; omit branch choice"]
  Kind -->|No| Intent["Keep by default; delete only with flag"]
  Intent --> Check["Check capability on removal connection"]
  Check -->|Supported| Queue["Queue host-owned removal"]
  Check -->|Unsupported| Refuse["Refuse before mutation"]
  Folder --> Queue
  Queue --> Match["Reject conflicting accepted choice"]
  Match --> Job["Run removal with recorded choice"]
  Job --> Git["Remove checkout; safely delete branch only if requested"]
  Job --> Resume["Reuse recorded choice after restart"]
Loading

Reviews (1) · Last reviewed commit: "Merge origin/main before final CI" · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review.

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: 2f05c1f1-d9ed-4c4f-9368-2ced4e312804
Commits

Reviewing files that changed from the base of the PR and between 6a2c4ed and dc6003c.

Files selected for processing: 7
  • src/cli/runtime/client.ts
  • src/cli/runtime/status.ts
  • src/cli/runtime/transport.test.ts
  • src/cli/runtime/transport.ts
  • src/cli/runtime/websocket-transport.test.ts
  • src/shared/rpc-contract/worktree-params.ts
  • src/shared/worktree-runtime-capabilities.ts

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

Walkthrough

The change adds --delete-branch to worktree removal and carries the choice through runtime requests, lifecycle processing, and retries. The CLI selects request parameters based on runtime capabilities. Hosts without the capability receive the legacy request and a warning. Text output reports confirmed removal only when the result confirms it; otherwise, it reports that removal is not confirmed.

Priority: Normal

Merge Risk: Minimal · previous review dc600

The previously reported CLI type error is no longer present, and the inspected removal preflight rejects failed status responses before sending a removal. No actionable code issue remains established here.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description follows the template's main sections: ELI5 is absent, but What Changed, Why, Testing, and Notes are covered in substance. It explains the before and after behavior in a table for updat… Add a plain-language ELI5 section. Add the issue link in the form 'Fixes #' with the issue number, or explain why none exists. Add 'N/A' with a reason under Visual Proof, since the change is CLI behavior rather than UI. State the alternativ…
Docstring Coverage Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title "Keep worktree branches unless CLI deletion is requested" matches the main change. The PR makes updated hosts keep a worktree's branch by default on orca worktree rm, and --delete-branch…
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.
Full details: Title check

Explanation

The title "Keep worktree branches unless CLI deletion is requested" matches the main change. The PR makes updated hosts keep a worktree's branch by default on orca worktree rm, and --delete-branch requests the existing safe cleanup. The title is specific and short, and it does not describe anything missing from the changeset. It omits the compatibility handling for older hosts, which is expected for a title.

Full details: Description check

Explanation

The description follows the template's main sections: ELI5 is absent, but What Changed, Why, Testing, and Notes are covered in substance. It explains the before and after behavior in a table for updated and older hosts, and it describes the mechanism: capability check over the same connection, legacy request fallback, and preserved accepted branch intent. It gives detailed validation, including test counts from separate invocations and CI status. Several template sections are missing or incomplete: the Linked Issue section has only a Linear reference (STA-10355) and no 'Fixes #' issue link, the Visual Proof section has no explicit N/A statement, the ELI5 section is missing, the AI Disclosure and agent-skill boundary sections are unaddressed, and the checklist and manual testing boxes are unchecked. The 'Why' section compares the change against alternatives only indirectly.

Resolution

Add a plain-language ELI5 section. Add the issue link in the form 'Fixes #' with the issue number, or explain why none exists. Add 'N/A' with a reason under Visual Proof, since the change is CLI behavior rather than UI. State the alternatives considered under Why. Address the AI Disclosure section and the agent skill upstream boundary checkbox. Check or explain the Testing checkboxes, including whether manual testing happened on macOS, Linux, Windows, or SSH. Tighten the description. It is long and repeats test counts across several paragraphs. Summarize the validation results once.

Full details: Docstring Coverage

Explanation

Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 21 functions across 32 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • 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

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: 2


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: c22bd5cd-99ac-4d9c-b7d2-7b3935059dc7
Commits

Reviewing files that changed from the base of the PR and between 54fa316 and 2ebea0f.

Files selected for processing: 24
  • src/cli/handlers/worktree-removal-request.ts
  • src/cli/handlers/worktree.ts
  • src/cli/index.test.ts
  • src/cli/runtime/client-execution-host.test.ts
  • src/cli/runtime/client.ts
  • src/cli/runtime/remote-runtime-compat-gate.ts
  • src/cli/runtime/transport.test.ts
  • src/cli/runtime/transport.ts
  • src/cli/runtime/types.ts
  • src/cli/runtime/websocket-transport.test.ts
  • src/cli/specs/core.ts
  • src/cli/worktree-rm-real-git.test.ts
  • src/main/runtime/runtime-interrupted-local-worktree-removal.test.ts
  • src/main/runtime/runtime-registered-local-worktree-removal.ts
  • src/main/runtime/runtime-worktree-selection.test.ts
  • src/main/runtime/runtime-worktree-selection.ts
  • src/main/runtime/workspaces/workspace-lifecycle-commands.ts
  • src/main/runtime/workspaces/workspace-removal-target.ts
  • src/main/runtime/workspaces/workspace-removal.ts
  • src/main/worktree-background-removal.ts
  • src/renderer/src/web/web-preload-api-workspace-catalog.test.ts
  • src/shared/cli-argument-boundary.ts
  • src/shared/rpc-contract/worktree-params.ts
  • src/shared/worktree-runtime-capabilities.ts

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

Comment thread src/cli/handlers/worktree.ts Resolved
Comment thread src/cli/worktree-rm-real-git.test.ts Resolved
@brennanb2025

brennanb2025 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Worktree removal could delete its branch after the command returned. Updated hosts now keep the branch by default, including with --force; --delete-branch requests existing safe cleanup. Older local, served SSH and paired hosts receive the unchanged legacy request plus a warning, retaining their existing branch policy. The CLI reports only confirmed outcomes; desktop deletion is unchanged. The PR description includes the requested new-host/older-host comparison table.

The full source review, design settlement and convergence checks completed on 6a2c4edc714a6256c6fadedb424f4d6880f8ad97. Independent narrow review passed the transport integration in main merge dc6003c6e58e0c30097c2b4135c8a63c4e6ae59e: both error classification and same-connection request selection survive through one optional options object, and both test sets remain. Final main merge b0f5f04d003606faf68600c4a221af1f077fedad incorporates b67c5254f04489d11167efa0b9788be2b50bb3e1, including the e2e ratchet repair. It was conflict-free, with no overlap between incoming paths and this PR's paths; incoming files match main exactly. The prior qa=tests evidence carries across both main merges.

Verification: 139 tests in nine named affected CLI/transport/runtime integration files passed through tc-gate after the transport merge; required merge lint-staged passed for both merges. Tests exercise actual CLI arguments through local/authenticated paired sockets, real RPC/lifecycle dispatch and temporary Git repos, covering default/force/opt-in, exact legacy requests and warnings, folders/root refusal, served routing, preparation/no-replay, restart recovery and complete failed retry/settlement. Earlier core coverage included 124 passes and 16 Windows-only skips; counts across invocations are not additive unique coverage. Final merged-head CI: 42 passing checks and 28 intentionally skipped checks, including passing static analysis/typecheck, both packages, all twelve unit shards, mobile verification and all three WSL distro checks. The branch is pushed and clean, with no conflicts or unresolved review threads.

All changed flows are CLI/tests rows (qa=tests). No rendered screen, native-chat/agent lifecycle, login or process-ownership implementation changed, so no app, agent or screenshot run is required. The served-route fixture does not claim a live SSH-daemon run. Deferred: minor accepted-choice retry-message clarification. The separate pre-existing dynamic-selector queue identity discrepancy is on the lane owner's list.

For Brennan's review:

@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: 2


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: bf04c363-ca65-454b-845c-0f7846b788e1
Commits

Reviewing files that changed from the base of the PR and between 2ebea0f and e24720d.

Files selected for processing: 18
  • src/cli/handlers/worktree-removal-request.ts
  • src/cli/handlers/worktree.ts
  • src/cli/index.test.ts
  • src/cli/runtime/client.ts
  • src/cli/runtime/remote-runtime-compat-gate.ts
  • src/cli/runtime/transport.test.ts
  • src/cli/runtime/transport.ts
  • src/cli/runtime/types.ts
  • src/cli/runtime/websocket-transport.test.ts
  • src/cli/runtime/websocket-transport.ts
  • src/cli/specs/core.ts
  • src/main/runtime/rpc/worktree-rm-cli.integration.test.ts
  • src/main/runtime/rpc/worktree-rm-paired.test-fixture.ts
  • src/main/runtime/rpc/worktree-rm-pty.test-fixture.ts
  • src/shared/remote-runtime/remote-runtime-client.ts
  • src/shared/remote-runtime/requests/remote-runtime-request-response-router.ts
  • src/shared/remote-runtime/requests/remote-runtime-request-socket.ts
  • src/shared/runtime-rpc-envelope.ts

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

@brennanb2025
brennanb2025 merged commit cf5f427 into main Oct 30, 2026
70 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/lu-rm-keep-branch branch October 30, 2026 08:39
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.

1 participant