Skip to content

fix(ui): keep non-Git agent workspaces usable for new sessions - #133664

Merged
steipete merged 3 commits into
mainfrom
codex/fix-plain-agent-workspace
Aug 31, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/fix-plain-agent-workspace

Conversation

@steipete

@steipete steipete commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where starting a Control UI session in an ordinary agent workspace could offer Worktree, then fail with agent workspace is not a git checkout. A .git marker or a saved project path does not prove that the folder has a usable checkout; newly initialized workspaces can have Git metadata without any commits.

Why This Change Was Made

The New Session repository controller now uses the Gateway's repository discovery result as the authority for worktree availability. Confirmed Git checkouts and selected remote repositories awaiting cloning support isolation. Saved workspace and group defaults go through that same decision, including when discovery is already cached. Switching placement after discovery reuses the resolved repository so a remembered base branch is preserved. Changing folders retires the previous discovery request before its reply can consume the new folder's preference.

An explicitly selected worktree remains selected when a later Git check fails, with Start blocked until the user clears isolation or reselects the folder. Ordinary sessions continue to run directly. Gateway worktree validation and remote-placement isolation requirements are unchanged.

User Impact

Plain folders and fresh repositories without commits work for ordinary local sessions without requiring users to initialize or commit a repository. Worktree controls are offered only when usable, and valid GitHub, project, cloud, and reconnect flows retain their intended selections.

Evidence

  • Reproduced the capability mismatch in a running Control UI: repository discovery returned unavailable while the Worktree option remained enabled.
  • Added owner-boundary regressions for unverified workspace and project paths and repeated group-default adoption. Both capability regressions failed before the fix.
  • 52 focused unit tests passed across repository selection, submit gates, and submission flow.
  • 38 browser E2E scenarios passed (25 together plus all 13 device-dispatch cases) across workspace validation, GitHub projects, saved place preferences, and session-group defaults, and device dispatch. The first CI run caught a group-default ordering regression; it reproduced locally and was fixed by retiring the old folder's repository request before validating the new folder.
  • Corrected device-dispatch fixtures to return a verified Git checkout instead of relying on workspaceGit alone; the four previously failing cases and all nine siblings pass without changing dispatch assertions.
  • Manually exercised the synthetic before/after pages in Chrome, then started a direct session successfully. Screenshots use only synthetic data and the mocked Gateway; they are not live provider proof.
  • Fresh Codex autoreview completed with no accepted findings. Production LOC: +23/-24 (net -1); tests: +88/-17. Repository discovery remains the single owner of availability and preference restoration.
  • Remote changed-file checks passed; the one-shot Testbox was stopped. Exact-head hosted CI passed on 9ea3b23853bde7accd79fdd8394c161c45ca6991: CI run 33345931670.

Before: the unavailable checkout still offers a selected Worktree and an enabled Start button.

Before: false Worktree selection

After: the same folder starts directly without a Worktree control.

After: direct session from the same folder

Real-Gateway Proof Limit

The suggested isolated real-Gateway check was attempted: a fresh production UI build, an isolated Gateway, an unborn Git workspace, and the real browser handshake all succeeded. Source-module loading then blocked the shared runner event loop for about 221 seconds; navigation timed out before the Worktree-control and direct-creation assertions. The attempt is incomplete and is not counted as successful behavior proof. No provider turn was requested. All task-owned processes, listener ports, and temporary state were cleaned up.

The remaining gap is the optional real-Gateway UI proof for the persisted-preference transition. The completed proof is the mocked-Gateway browser flow plus the owner regressions; exact-head hosted CI also passed before landing. The startup-loading observation is recorded here for follow-up; no unrelated startup change is included.

@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
@steipete
steipete marked this pull request as ready for review August 31, 2026 00:29
@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, 9:01 PM ET / August 31, 2026, 01:01 UTC.

ClawSweeper review

What this changes

The PR makes New Session offer worktree isolation only after repository discovery confirms a usable Git checkout or a remote repository awaiting cloning.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

The PR addresses a real current-main mismatch and no introduced correctness defect was found. Its targeted reset of a persisted worktree preference is compatibility-sensitive, so the protected maintainer review should remain open for explicit acceptance.

Priority: P2
Reviewed head: 9ea3b23853bde7accd79fdd8394c161c45ca6991
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused, net-negative repair has coherent owner-boundary coverage and no concrete introduced defect; only the intentional persisted-preference policy needs maintainer acceptance.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored PR is exempt from the external-contributor proof gate. The supplied mocked browser flow and focused regression evidence support review but do not claim a completed isolated real-Gateway observation.
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 proof gate. The supplied mocked browser flow and focused regression evidence support review but do not claim a completed isolated real-Gateway observation.
Evidence reviewed 5 items Current-main defect: Current main treats any selected project root, and an unavailable workspace marked workspaceGit, as worktree-capable rather than requiring confirmed repository status.
Gateway contract: The Gateway reports unavailable when repository resolution fails, including a checkout with no verifiable HEAD; the UI can therefore use this status as the availability authority.
Changed owner and regression coverage: The introduced controller restricts availability to confirmed Git or pending clone, while focused unit and browser E2E tests cover unavailable discovery and clearing an explicitly selected worktree.
Findings None None.
Security None None.

How this fits together

The Control UI turns saved, group, and user-selected destinations into a New Session request. It queries the Gateway for repository status, then either permits Git worktree isolation or allows a direct session.

flowchart LR
A[New Session defaults] --> B[Selected workspace]
B --> C[Gateway repository discovery]
C --> D{Usable Git checkout?}
D -->|Yes| E[Worktree isolation]
D -->|No| F[Direct session]
E --> G[Create session]
F --> G
Loading

Decision needed

Question Recommendation
Should an existing saved worktree preference be reset to false when the Gateway confirms that its selected folder is not a usable Git checkout? Accept the targeted reset: Persist direct mode only after confirmed non-Git discovery so future sessions do not restore an invalid worktree choice.

Why: The behavior fixes an invalid session-start state but intentionally changes retained user preference during upgrade; source evidence cannot decide the desired persistence policy.

Before merge

  • Resolve merge risk (P1) - On upgrade, a saved worktree preference is persisted as false once discovery confirms that the selected folder is not a Git checkout. That prevents a false available state, but changes an existing remembered setting and needs explicit maintainer acceptance.
Agent review details

Security

None.

PR surface

Source -1, Tests +71, Docs +2. Total +72 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 2 23 24 -1
Tests 3 88 17 +71
Docs 1 3 1 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 114 42 +72

Review metrics

Metric Value Why it matters
Production versus test delta production +23/-24 (net -1); tests +88/-17; docs +3/-1 The repair remains net-negative in production while adding focused state and browser-flow regression coverage.

Merge-risk options

Maintainer options:

  1. Confirm the preference-reset policy (recommended)
    Accept the narrow reset of an invalid saved worktree preference after confirmed non-Git discovery before merging.
  2. Pause for a different upgrade policy
    Keep the PR open if retained worktree preferences must survive a confirmed non-Git result without being rewritten.

Technical review

Best possible solution:

Adopt repository discovery as the sole worktree-availability authority and explicitly accept the narrow preference reset for confirmed non-Git folders.

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

Yes, source-reproducible: current main exposes worktree availability from a saved project root or workspace marker despite an unavailable repository result, while the Gateway contract distinguishes usable Git from unavailable state.

Is this the best way to solve the issue?

Yes: placing the decision in the repository controller uses the Gateway result that already verifies Git and HEAD availability, rather than duplicating weaker path or marker heuristics in callers.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 252e80d1cc4f.

Labels

Label justifications:

  • P2: The PR repairs a bounded Control UI session-start path without evidence of broader runtime failure.
  • merge-risk: 🚨 compatibility: A confirmed non-Git result now rewrites an existing saved worktree preference to direct mode.
  • 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 proof gate. The supplied mocked browser flow and focused regression evidence support review but do not claim a completed isolated real-Gateway observation.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: 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 resetting a saved invalid worktree preference 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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-31T00:37:00.753Z sha 8fee8f7 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-31T00:48:04.984Z sha bf15f9d :: needs maintainer review before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

CI caught a group-default ordering regression on the first head. I reproduced it locally: an old workspace-discovery reply arrived while the saved group folder was being validated, consumed the new folder's worktree preference, and left the group in direct mode. The controller now retires the old request immediately when the target changes and consumes the current preference when matching discovery resolves.

On bf15f9d2263d525d9f44c62f5fc803ae3562f9b2, all 25 browser scenarios pass together (workspace validation, GitHub projects, saved place preferences, and session-group defaults), along with 52 focused unit tests. Fresh Codex autoreview has no accepted findings. Production is now +23/-24, net -1; tests remain +79/-7. No config, protocol, persistence schema, or Gateway authorization change.

The review's positive-production-LOC concern is resolved. The persisted-preference distinction remains intentional: inferred/saved isolation is adopted only for a usable checkout, while an explicit selection is retained and submission blocked after a failed recheck. I am checking the optional isolated real-Gateway proof while exact-head CI runs.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor Author

Review follow-up: persisting worktree: false for a confirmed non-Git folder is existing behavior, not a new preference migration. The base controller already clears and persists that value in adoptResolvedRepository (base source, lines 262–267). This PR removes false-positive eligibility from workspace metadata/saved paths and routes group restoration through the same owner. Explicit worktree selection after an unavailable recheck remains selected and visibly blocked.

The latest push only corrects device-dispatch fixtures to provide the Git discovery response their scenarios require. The four failures reproduced locally and all 13 device cases now pass, with their dispatch-order and capacity assertions unchanged. Together with the other suites, focused browser coverage is 38 passing scenarios; focused units remain 52 passing.

The real-Gateway Rank-up move was attempted and remains incomplete: production UI build, isolated unborn workspace, Gateway startup, and browser handshake passed; synchronous source-module loading blocked the shared event loop for about 221 seconds, then navigation timed out before the target assertions. The PR body records this concrete proof limitation. All owned processes, ports, and temporary state were cleaned, and no provider turn was requested. I am retaining the completed mocked-Gateway browser and owner-boundary evidence and waiting for the final exact-head checks before native landing.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready on 9ea3b23853bde7accd79fdd8394c161c45ca6991: CI run 33345931670 completed successfully, including the required openclaw/ci-gate and both previously failing browser shards. No checks were waived.

The repair keeps repository discovery as the capability/restoration owner, removes metadata-based eligibility and the group bypass, and retires obsolete-folder requests. Production is net -1 line. Verification includes 52 focused unit tests, 38 browser scenarios, pre-fix failures, manual synthetic before/after browser proof, remote changed checks, and clean Codex autoreview. The PR records the incomplete isolated real-Gateway attempt and its source-loading blocker; no provider turn or deployment is claimed.

Latest exact-head ClawSweeper review and Rank-up move are addressed. This fix intentionally retains the existing direct-mode reset after confirmed non-Git discovery; confirmed-non-Git preference clearing already existed in base (source linked above), the extra real-Gateway attempt and limit are documented, and exact-head CI is now green. Proceeding through the native landing workflow.

@steipete
steipete merged commit 9dc5c3d into main Aug 31, 2026
165 of 167 checks passed
@steipete
steipete deleted the codex/fix-plain-agent-workspace branch August 31, 2026 01:14
@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
…law#133664)

* fix(ui): keep non-Git agent workspaces usable for new sessions

* fix(ui): retire stale repository discovery on preference changes

* test(ui): verify Git in device dispatch fixtures
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