Skip to content

refactor(ui): simplify workspace discovery and preference restoration - #133705

Merged
steipete merged 3 commits into
mainfrom
codex/simplify-workspace-discovery
Aug 31, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/simplify-workspace-discovery

Conversation

@steipete

@steipete steipete commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Related: #133664

What Problem This Solves

Fixes an issue where group defaults offered Worktree for an agent workspace whose .git marker existed but whose checkout could not be verified. Reviewing the surrounding new-session flow also reproduced saved cloud preferences leaving plain folders stuck on “Restoring preferences,” and delayed identity preferences losing their base branch while repository discovery was pending or overwriting already-edited checkout details after discovery.

Why This Change Was Made

Repository discovery now uses its existing state union directly, reuses the invalidation and worktree-selection owners, and reads the latest preferred base branch when a request completes while retaining the user-edit generation fence. Late identity preferences also preserve edited branch and checkout-name details when discovery is already cached. Group defaults inspect the agent workspace through the same Gateway operation as custom folders. Dead folder-permission bookkeeping and an impossible submission predicate are removed; the Gateway remains the folder authorization owner.

Production LOC: +53/-109, net -56. Tests: +148/-60, net +88. Documentation: +2. No new configuration, persistence schema, dependencies, or Gateway protocol changes.

User Impact

Plain workspaces remain usable, group defaults stop advertising unverified isolation, and saved cloud preferences finish restoring instead of indefinitely blocking Start. Transient Git failures clear only the current draft's cloud restoration and preserve the saved destination for a later visit. Explicit cloud/worktree choices retain their existing behavior.

Evidence

  • Before the fix, the new implicit-workspace group-default case displayed Worktree instead of the verification failure; the cloud-restoration cases never became ready; and the delayed branch preference resolved to main instead of the saved branch. All now pass.
  • 49 focused repository/submission tests, 34 sidebar group tests, and 38 Chromium mocked-Gateway E2E scenarios pass. Browser coverage includes failed Git probes and retry, identity defaults, changed group defaults, reconnects, remembered worktree restoration, contained/symlinked folders, and actionable Gateway rejection of typed folders.
  • The first hosted type-check run caught a test-only ES library mismatch (Promise.withResolvers). The test now uses the shared deferred helper; its focused suite passes. The final hosted run verifies the pinned dependencies; the local shared dependency tree is older than this checkout.
  • Fresh Codex autoreview: no accepted/actionable P0 findings. The final exact-head CI run is green, including all 14 Chromium E2E shards and the real-Gateway smoke lane. Native prepare and merge completed at 9f6d8c5a60b4ce251157e354b459d29037179f57.
  • Browser evidence is deterministic Chromium against the real UI with a mocked Gateway. Real-Gateway proof was attempted during fix(ui): keep non-Git agent workspaces usable for new sessions #133664 but source-module loading blocked the event loop before target assertions; it is not claimed as live proof here.
  • Provenance: the implicit-workspace .git shortcut was added by Show worktree option only for Git group folders #125280 (a928da457f82), verified against its raw parent 41c081875133. Exact introduction of the other preference defects is not established.

Before: group defaults incorrectly offer Worktree for an unverified workspace.

Before

After: verification failure offers Retry and prevents saving invalid isolation.

After

@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: M maintainer Maintainer-authored PR labels Aug 31, 2026
@steipete steipete self-assigned this Aug 31, 2026
@steipete
steipete marked this pull request as ready for review August 31, 2026 01:42
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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, 10:01 PM ET / August 31, 2026, 02:01 UTC.

ClawSweeper review

What this changes

The branch makes Control UI worktree eligibility depend on Gateway repository inspection and restores saved placement preferences without blocking local drafts or overwriting checkout details edited during discovery.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. Current main does not contain this branch’s repository-discovery and preference-restoration changes, and the member-authored, maintainer-labeled PR contains a coherent bounded fix with no concrete introduced correctness defect found.

Priority: P2
Reviewed head: 7681b4607c4c15115ff7bc918ddfdf4bc8857204

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent, net-negative production refactor with focused owner and browser regressions, pending normal exact-head CI completion and compatibility acceptance.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored PR is exempt from the external-contributor real-behavior gate. The body supplies before/after screenshots and mocked-Gateway Chromium evidence, but DNS failure prevented independent attachment inspection, so this review does not treat those images as proof sufficient.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored PR is exempt from the external-contributor real-behavior gate. The body supplies before/after screenshots and mocked-Gateway Chromium evidence, but DNS failure prevented independent attachment inspection, so this review does not treat those images as proof sufficient.
Evidence reviewed 7 items Changed owner boundary: The repository controller now represents initial discovery directly as its existing state union, preserves user-edited checkout details, and resolves saved worktree/base-branch state after the authoritative Git result.
Entry point and restoration caller: Each New Session page update invokes preference restoration after agent readiness, so an asynchronous repository result can finish the saved-cloud decision rather than leave the draft restoring.
Gateway authorization contract: The newly used workspace probe still goes through the existing Gateway handler, which resolves an authorized repository root before listing branches; Gateway tests cover write-scoped containment and rejection of arbitrary paths.
Findings None None.
Security None None.

How this fits together

The Control UI New Session flow combines agent workspace data, selected folders or projects, saved placement preferences, and a Gateway Git probe to choose direct, worktree, device, or cloud execution. The resulting placement state controls whether Start is enabled and which session parameters reach the Gateway.

flowchart LR
  A[Agent workspace and preferences] --> B[New Session draft]
  C[Folder or project selection] --> B
  B --> D[Gateway Git inspection]
  D --> E[Placement eligibility]
  E --> F[Start session]
  E --> G[Visible recovery state]
Loading

Before merge

  • Resolve merge risk (P1) - For an existing saved cloud destination whose workspace now resolves conclusively as direct (non-Git), the branch intentionally persists Local in its place; that upgrade behavior should be accepted explicitly before merge.
  • Complete next step (P2) - No discrete repair is indicated; this is an active member-authored PR that needs ordinary maintainer review, compatibility acceptance, and exact-head CI completion.
Agent review details

Security

None.

PR surface

Source -56, Tests +88, Docs +2. Total +34 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 5 53 109 -56
Tests 3 148 60 +88
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 203 169 +34

Review metrics

Metric Value Why it matters
Production versus test delta production +53/-109 (net -56); tests +148/-60 (net +88); docs +2 The fix reduces production control-flow surface while adding focused preference, group-default, and mocked-Gateway browser regressions.

Merge-risk options

Maintainer options:

  1. Confirm the Local fallback (recommended)
    Accept rewriting a saved cloud destination to Local when the workspace conclusively resolves as non-Git, preventing an unusable saved placement from recurring.
  2. Preserve cross-workspace cloud selection
    If saved cloud destinations must survive a direct workspace, clear only the draft selection and add an upgrade regression that proves the preference remains available later.

Technical review

Best possible solution:

Keep Gateway repository inspection as the single eligibility authority, preserve saved cloud destinations for transient unavailable probes, and retain the explicit Local fallback for a conclusively non-Git workspace only if maintainers accept that preference migration.

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

Yes—source-reproducible. The prior sidebar branch trusted the workspaceGit hint for an implicit workspace, while the added owner and mocked-Gateway browser scenarios exercise unavailable and direct Git results; this read-only review did not execute them.

Is this the best way to solve the issue?

Yes. The branch removes the non-authoritative workspace hint and routes eligibility through the existing Gateway inspection owner, rather than layering another client-side permission or repository-status cache.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 14f86793ecd6.

Labels

Label changes:

  • add P2: This is a bounded repair to Control UI session placement and saved-preference behavior without evidence of an emergency runtime failure.
  • add merge-risk: 🚨 compatibility: The branch deliberately changes an existing persisted cloud placement preference to Local when the workspace resolves as a direct non-Git folder.
  • 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: This member-authored PR is exempt from the external-contributor real-behavior gate. The body supplies before/after screenshots and mocked-Gateway Chromium evidence, but DNS failure prevented independent attachment inspection, so this review does not treat those images as proof sufficient.

Label justifications:

  • P2: This is a bounded repair to Control UI session placement and saved-preference behavior without evidence of an emergency runtime failure.
  • merge-risk: 🚨 compatibility: The branch deliberately changes an existing persisted cloud placement preference to Local when the workspace resolves as a direct non-Git folder.
  • 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: This member-authored PR is exempt from the external-contributor real-behavior gate. The body supplies before/after screenshots and mocked-Gateway Chromium evidence, but DNS failure prevented independent attachment inspection, so this review does not treat those images as proof sufficient.

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)
  • jesse-merhi: 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.

  • Confirm that replacing a saved cloud destination with Local for a conclusively non-Git workspace is the intended upgrade behavior.

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.

@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer review: the saved-preference choice is intentional for this repair. A conclusively non-Git source cannot support cloud worktree placement, so its restored default is repaired to Local and the operator can start the draft. This follows the existing repair of a saved worktree preference for a confirmed plain folder. It applies only to restored defaults: explicit cloud/worktree selections remain intact, and a transient unavailable Git result preserves the stored cloud destination for a later retry. The owner regressions assert both persistence outcomes.

This addresses the compatibility question and Rank-up move. The final code has no outstanding review findings. The previously failing test-type shard and the hosted real-Gateway smoke test are green on 7681b4607c4c15115ff7bc918ddfdf4bc8857204; native landing will wait for the aggregate exact-head gate.

@steipete
steipete merged commit 9f6d8c5 into main Aug 31, 2026
162 checks passed
@steipete
steipete deleted the codex/simplify-workspace-discovery branch August 31, 2026 02:10
@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
…openclaw#133705)

* refactor(ui): simplify workspace discovery and preference restoration

* fix(ui): preserve edited checkout details during preference adoption

* test(ui): use shared deferred helper for workspace discovery
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: M 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