Skip to content

fix(ui): preserve worktree base branch across reconnects - #133744

Merged
steipete merged 3 commits into
mainfrom
codex/preserve-worktree-branch-on-reconnect
Aug 31, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/preserve-worktree-branch-on-reconnect

Conversation

@steipete

@steipete steipete commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Related: #133664, #133705

What Problem This Solves

Fixes an issue where users editing the base branch on the New Session page lose that choice when the Gateway reconnects or Git discovery retries. Live stress testing reproduced proof-base becoming empty after restart; successful rediscovery could then replace it with the repository default.

Why This Change Was Made

The repository controller now keeps an explicit or saved branch override and derives the fallback from current Git discovery. This removes the duplicate branch-restoration state and generation bookkeeping, so asynchronous repository results cannot overwrite operator input. Actual folder/project changes clear both current and saved checkout details. Project discovery now distinguishes a disconnect or failed refresh from a confirmed empty catalog, preserving the selected project and its checkout details until an authoritative result removes it.

Production delta: 35 additions / 36 deletions (net -1). Regression tests: 77 additions / 1 deletion (net +76). No protocol, configuration, or database changes.

User Impact

Worktree selection, edited base branch, and checkout name survive reconnects and temporary Git failures. Selecting a different repository clears stale repository-specific details.

Evidence

  • Real built Gateway + production Chromium reproduced the branch loss before the fix. Five owner regressions failed before their fixes and now pass.
  • 64 focused owner/submission/browser-controller tests and 11 Chromium cloud-dispatch/workspace-validation tests pass. The existing cloud-dispatch E2E caught the catalog-disconnect interaction; its assertion was retained and now passes.
  • Fresh Codex autoreview of the complete candidate: no accepted/actionable findings.
  • Real Gateway stress at runtime commit b4cf3ef9f4937826808f83c794aa708256407c51 passed 360 repository probes (12 concurrent), 120 direct session creations (8 concurrent), 12 managed-worktree creations (4 concurrent), 30 browser navigation transitions, nine implicit-workspace group-default dialogs, and ten restart/recovery transitions followed by a completed worktree session. The ten restart/recovery transitions used a registered project, verified that its selection survived each reconnect, and ended in a completed isolated session. All browser runs recorded zero page errors. The final commit only removes a release-owned changelog edit; runtime code is unchanged.
  • Plain, unborn-Git, and committed-Git sessions completed real UI/Gateway turns with the repository's deterministic loopback provider. This proves UI, Gateway, filesystem and session lifecycle behavior; it does not claim external model-provider coverage. Chrome independently completed plain/unborn sessions and managed-worktree creation.
  • The changed-code gate passed on the branch-override repair, including core-test/UI types and lint. Exact-head hosted CI covers the final combined candidate. An earlier core security shard exited via SIGKILL; no assertions failed in that shard.

Before: the edited base branch disappears after reconnect.

Before reconnect repair

After: the edited branch and name remain while Git is unavailable.

After reconnect repair

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: S maintainer Maintainer-authored PR labels Aug 31, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 11:08 PM ET / August 31, 2026, 03:08 UTC.

ClawSweeper review

What this changes

The branch retains New Session worktree branch and checkout-name choices through Gateway reconnects or failed discovery, and clears those details only when the selected repository actually changes.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

No introduced blocking defect was found. Keep this maintainer-authored, maintainer-labeled PR open for explicit maintainer handling because the reviewer could not load current-main source from the partial clone to complete the required exact-main comparison.

Priority: P2
Reviewed head: 572eb6557a5c98cbdfa3ad6c1171da80f030a94b
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative state-owner repair with relevant regression coverage; exact-current-main inspection remains unavailable in this checkout.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable: repository metadata identifies this as a MEMBER PR. Its supplied body reports built-Gateway and production-Chromium before/after proof, but attachment retrieval was blocked by DNS and is not treated as a contributor proof failure.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable: repository metadata identifies this as a MEMBER PR. Its supplied body reports built-Gateway and production-Chromium before/after proof, but attachment retrieval was blocked by DNS and is not treated as a contributor proof failure.
Evidence reviewed 7 items State-owner repair: The repository controller now retains an explicit branch override while deriving only the fallback from the latest verified Git result; reconnect invalidation no longer clears the override.
Caller preserves repository boundaries: The New Session state clears persisted branch details before clearing a confirmed-missing project, and when a device switch replaces a non-worktree-capable location with the agent workspace.
Catalog failure handling: The project browser retains its last successful project catalog on disconnect or request error, while a successful empty catalog still invokes the missing-project callback.
Findings None None.
Security None None.

How this fits together

The Control UI combines the selected folder or project with Gateway repository discovery to decide whether a worktree can be used and which branch to check out. The resulting details are stored in New Session preferences and flow into session creation.

flowchart LR
  A[Folder or project selection] --> B[New Session draft]
  B --> C[Gateway repository discovery]
  C --> D[Worktree branch and name]
  D --> E[Saved draft preference]
  E --> F[Session creation]
Loading

Decision needed

Question Recommendation
Does a maintainer approve the persisted New Session preference behavior after an exact-current-main comparison is available? Refresh exact merge evidence: Compare the exact merge result with current main and, if it preserves the documented repository-boundary behavior, proceed through normal maintainer review.

Why: The PR is maintainer-authored and carries the protected maintainer label, while changing when saved worktree details are retained or cleared.

Before merge

  • Resolve merge risk (P1) - Current-main source could not be read from this partial clone, so the exact three-way merge must be refreshed before landing; this PR deliberately changes persisted preference clearing at confirmed repository boundaries.
  • Complete next step (P2) - The protected maintainer label and unavailable current-main blob require explicit maintainer review rather than automated repair or closure.
Agent review details

Security

None.

PR surface

Source -1, Tests +76, Docs +2. Total +77 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 35 36 -1
Tests 2 77 1 +76
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 114 37 +77

Review metrics

Metric Value Why it matters
Production versus regression-test delta runtime +35/-36 (net -1); tests +77/-1; docs +2 The bug repair removes more runtime code than it adds while adding focused reconnect and catalog-failure coverage.

Merge-risk options

Maintainer options:

  1. Refresh exact merge evidence (recommended)
    Verify the exact current-main merge still limits persisted branch/name clearing to genuine folder or project changes before landing.
  2. Pause for complete source context
    Hold the change until a complete checkout can compare current-main preference behavior and exact-head validation.

Technical review

Best possible solution:

Retain the single explicit branch-override owner and land only after a maintainer verifies the exact current-main merge and current-head checks preserve the documented clear-on-real-repository-change behavior.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: the prior controller reset its base value during invalidation and each discovery load, and the new regression test follows that reconnect sequence. The read-only checkout has no dependencies, so this reviewer did not execute the test.

Is this the best way to solve the issue?

Yes: a single explicit override plus a discovery-derived fallback removes the duplicate restoration state and prevents asynchronous discovery from replacing an edited branch; catalog errors are correctly separated from authoritative absence.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 346fae9a762d.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: The PR changes persisted base-branch and checkout-name behavior at folder, project, and device-selection boundaries.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable: repository metadata identifies this as a MEMBER PR. Its supplied body reports built-Gateway and production-Chromium before/after proof, but attachment retrieval was blocked by DNS and is not treated as a contributor proof failure.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This fixes a bounded Control UI preference-loss regression without evidence of an immediate availability or security impact.
  • merge-risk: 🚨 compatibility: The PR changes persisted base-branch and checkout-name behavior at folder, project, and device-selection boundaries.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable: repository metadata identifies this as a MEMBER PR. Its supplied body reports built-Gateway and production-Chromium before/after proof, but attachment retrieval was blocked by DNS and is not treated as a contributor proof failure.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Refresh the exact-main comparison and current-head checks in a complete checkout before landing.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-31T02:54:14.353Z sha 34bc851 :: found issues before merge. :: [P2] Remove the release-owned changelog entry

@steipete

Copy link
Copy Markdown
Contributor Author

Addressed the review finding and rank-up move: removed the release-owned CHANGELOG edit; release-note context remains in the PR body.

The final runtime also fixes a connected project-catalog issue caught by the existing cloud-dispatch E2E: a disconnected/failed catalog lookup no longer masquerades as a confirmed missing project. The original assertion is retained and passes. Fresh Codex autoreview is clean at its configured blocking priority.

Completed live proof now includes 360 repository probes, 120 direct creations, 12 managed worktree creations, 30 browser transitions, nine group-default checks, and ten real Gateway restart/recovery transitions with a registered project selected. The selected project, edited branch, and checkout name survive, and the final isolated session completes with the deterministic loopback provider. All browser runs recorded zero page errors. Before/after screenshots are in the PR body.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 31, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Completed the maintainer review and the remaining rank-up move in a complete checkout. Current main is 69464f7ab8ba4f62d756924ed0a654ae72462948; its three affected production modules are unchanged from the inspected pre-fix baseline. git merge-tree --write-tree produces a clean merge, and all three resulting module blobs are byte-identical to the tested PR head 572eb6557a5c98cbdfa3ad6c1171da80f030a94b.

The persisted-preference behavior is intentional: reconnects and failed catalog/Git lookups preserve the operator's existing repository and checkout choices; an explicit repository change or a confirmed missing project clears the old repository's branch/name. Preference shapes and storage schema are unchanged. The real registered-project restart test, folder-boundary regressions, and unchanged cloud-dispatch E2E cover this distinction.

No remaining code finding or owner-boundary concern. Exact-head CI is finishing with no failures; the native prepare/merge gates will enforce completion before landing.

@steipete
steipete merged commit d8d70cf into main Aug 31, 2026
162 checks passed
@steipete
steipete deleted the codex/preserve-worktree-branch-on-reconnect branch August 31, 2026 03:20
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
…3744)

* fix(ui): preserve worktree base branch across reconnects

* fix(ui): retain project selection during catalog reconnects

* docs: leave workspace release notes in the pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant