Skip to content

fix(ui): prevent cloud draft recovery dead ends - #120970

Merged
steipete merged 4 commits into
mainfrom
steipete/cloud-ui-draft-deadends
Aug 9, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/cloud-ui-draft-deadends

Conversation

@steipete

@steipete steipete commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Refs #120953

What Problem This Solves

Fixes four dead ends in the Control UI cloud new-session flow: transient placement lookup failures could leave paid workers orphaned, recovery ownership changes could fail silently and replay a stale send, interrupted tab navigation could incorrectly blame a Gateway change, and pending cloud placements with a live environment had no stop-worker action.

Why This Change Was Made

The UI now cleans up the last known environment before rejecting an ambiguous placement lookup, retires only the current submission's recovery state when another window takes ownership, records the actual interruption reason for recovery messaging, and routes stop-worker actions through the placement owner: active placements use sessions.reclaim, while pending placements with an environment use unforced environments.destroy.

This PR is limited to the Control UI. The two Gateway issues described in #120953 are intentionally excluded and remain owned by the sibling Gateway branch. AI-assisted; no agent transcript is included.

User Impact

Cloud sessions now leave a visible, accurate outcome instead of silently replaying work or blaming an unrelated Gateway change. Users can also stop paid workers that are stuck before the active state, while active workers keep the existing reclaim behavior and confirmation flow.

Evidence

  • node scripts/run-vitest.mjs ui/src/pages/new-session/ ui/src/e2e/mcp-app-conformance.e2e.test.ts ui/src/e2e/control-ui-auth-transports.e2e.test.ts ui/src/e2e/new-session-page.cloud-startup.e2e.test.ts src/gateway/server-chat-metadata-lifecycle.test.ts src/gateway/server-methods/chat-metadata-runtime.test.ts: gateway 23 tests passed; UI 8,086 passed and 46 skipped; browser E2E 10 tests passed. The first broad UI pass exposed an order-sensitive ui/src/app/overlays.test.ts failure; its isolated rerun passed 47/47 and the required aggregate retry passed.
  • Touched files passed node scripts/run-oxlint.mjs with no findings.
  • pnpm ui:i18n:baseline verified 97 raw-copy baseline entries and 4,615 source keys with no baseline diff.
  • git diff --check passed.
  • Final autoreview reported one P2 request to retain same-key replacement recovery across remounts. That finding is consciously rejected under the named multi-tab tradeoff below because it requires restoring the removed lease/successor ownership design or adding a new persisted tombstone contract.

Reduced ownership model and land-onto-red repair

The pre-existing main Control UI E2E breakage came from #120926 eagerly running the chat.metadata catch-up refresh during minimal Gateway startup. On that path, the roughly 120-second model-catalog build blocked startup. This PR includes the land-onto-red repair: minimal metadata startup stays lazy, so the catch-up refresh no longer blocks the startup path.

Cloud recovery now uses the simpler ownership identity of Gateway URL, recovery scope, and session key. The realm-local lease/successor-token design was removed after repeated reset/remount races. The accepted tradeoff is that concurrent same-key replacement pages may both clear recovery in the rare multi-tab flow; preserving that edge is not worth reintroducing the ownership machinery.

@clawsweeper

clawsweeper Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 9, 2026 07:01
@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label Aug 9, 2026
@clawsweeper

clawsweeper Bot commented Aug 9, 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 size: L maintainer Maintainer-authored PR labels Aug 9, 2026
@steipete
steipete force-pushed the steipete/cloud-ui-draft-deadends branch from bb4e124 to f1d250d Compare August 9, 2026 07:08
@clawsweeper clawsweeper Bot added 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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 9, 2026
@clawsweeper

clawsweeper Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 9, 2026, 4:49 AM ET / 08:49 UTC.

ClawSweeper review

What this changes

The PR improves Control UI cloud-session recovery and adds a Stop action for non-active cloud workers that have an environment.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

Keep this PR open: most recovery repairs are coherent, but the new Stop action can offer a dead-end during attached-worker teardown states. The protected maintainer label and unresolved lifecycle contract require maintainer handling before merge.

Priority: P1
Reviewed head: f1d250df645a0e6353e695731e73a3f6ba8a4671
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The recovery work has focused coverage, but one state-lifecycle defect and unresolved exact-head UI checks prevent a higher rating.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied test and CI evidence remains useful supplemental validation.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied test and CI evidence remains useful supplemental validation.
Evidence reviewed 6 items Stop resolver covers teardown states: The new resolver offers raw environment destruction for every non-active cloud placement with an environment ID; the placement-state predicate includes draining and reconciling states.
Gateway rejects attached raw destruction: The public unforced environment-destroy path delegates to unattached-worker destruction; Gateway tests require attached workers to be stopped through the session lifecycle instead.
Teardown lifecycle retains environments: Failure and reclamation cleanup can retain an attached environment while placements are draining, reconciling, or failed, so placement state alone does not prove raw destruction is valid.
Findings 1 actionable finding [P1] Restrict Stop to workers Gateway knows are unattached
Security None None.

How this fits together

The Control UI creates and recovers cloud sessions through Gateway placement and environment APIs. It presents recovery outcomes and session controls to operators after placement state changes.

flowchart LR
A[New session form] --> B[Cloud placement]
B --> C[Gateway lifecycle]
C --> D[Recovery state]
D --> E[Visible UI outcome]
E --> F[Session Stop action]
Loading

Decision needed

Question Recommendation
Should pending-cloud Stop be limited to Gateway-proven unattached placements, or should Gateway define a stateful stop operation for attached transitional and failed placements? Narrow the UI action: Offer raw environment destruction only for placement states that Gateway guarantees are unattached.

Why: The UI cannot safely infer attachment ownership from placement state, while the raw Gateway method intentionally rejects attached workers.

Before merge

  • Restrict Stop to workers Gateway knows are unattached (P1) - This resolver enables raw environments.destroy for draining, reconciling, and failed placements as well as provisioning ones. Those states can retain an attached worker, and Gateway rejects raw destruction for attached workers while sessions.reclaim only accepts active placements, leaving the new enabled control at a dead end. Limit it to Gateway-proven unattached states or add a Gateway-owned lifecycle stop path, with state-matrix coverage.
  • Resolve merge risk (P1) - Merging as written can show Stop for draining, reconciling, or failed placements whose attached workers Gateway refuses to destroy, recreating a visible dead end.
  • Resolve merge risk (P1) - The current head has unresolved UI E2E and CI-gate failures; exact-head green results are needed after the lifecycle repair.
  • Complete next step (P2) - The protected maintainer label and the unresolved Gateway lifecycle choice require maintainer review rather than an automated repair lane.

Findings

  • [P1] Restrict Stop to workers Gateway knows are unattached — ui/src/components/cloud-worker-stop.ts:17-29
Agent review details

Security

None.

PR surface

Source +164, Tests +241. Total +405 across 20 files.

View PR surface stats
Area Files Added Removed Net
Source 13 248 84 +164
Tests 7 244 3 +241
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 20 492 87 +405

Review metrics

Metric Value Why it matters
Production versus test LOC production +201/-84; tests +291/-3 The production growth adds cloud lifecycle behavior; its new Stop path needs a settled Gateway ownership contract before merge.

Stored data model

Persistent data-model change detected: serialized state: ui/src/components/session-organizer-operations.runtime.ts, serialized state: ui/src/components/session-row-badges.ts, serialized state: ui/src/pages/sessions/sessions-page.test.ts, serialized state: ui/src/pages/sessions/sessions-page.ts, serialized state: ui/src/test-helpers/app-sidebar-cases/sessions.ts, unknown-data-model-change: ui/src/pages/sessions/sessions-page.ts, and 1 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Restrict raw destruction to unattached workers (recommended)
    Change the resolver so the UI does not advertise a Stop action in attached teardown states, then add state-matrix regression coverage.
  2. Define a lifecycle-safe Gateway stop
    Add a Gateway-owned operation only if maintainers want Stop to handle attached transitional and failed workers.

Technical review

Best possible solution:

Make Stop available only when Gateway can prove the worker is unattached, or add a Gateway-owned lifecycle operation with explicit safe teardown semantics and cover transitional and failed states.

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

Yes, source-reproducible: a draining, reconciling, or failed placement with an attached environment receives the new Stop action, while Gateway rejects its raw destroy request.

Is this the best way to solve the issue?

No: the UI currently infers destruction eligibility from placement state even though Gateway owns attachment lifecycle; narrow the UI action or add a stateful Gateway contract.

Full review comments:

  • [P1] Restrict Stop to workers Gateway knows are unattached — ui/src/components/cloud-worker-stop.ts:17-29
    This resolver enables raw environments.destroy for draining, reconciling, and failed placements as well as provisioning ones. Those states can retain an attached worker, and Gateway rejects raw destruction for attached workers while sessions.reclaim only accepts active placements, leaving the new enabled control at a dead end. Limit it to Gateway-proven unattached states or add a Gateway-owned lifecycle stop path, with state-matrix coverage.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 29c442d48389.

Labels

Label changes:

  • add P1: The PR addresses cloud-session paths that can strand paid workers or leave operators with a non-working recovery control.
  • add merge-risk: 🚨 availability: The new visible Stop action can lead to a Gateway rejection during normal teardown states.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied test and CI evidence remains useful supplemental validation.

Label justifications:

  • P1: The PR addresses cloud-session paths that can strand paid workers or leave operators with a non-working recovery control.
  • merge-risk: 🚨 availability: The new visible Stop action can lead to a Gateway rejection during normal teardown states.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied test and CI evidence remains useful supplemental validation.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the original cloud-worker feature, an adjacent repair, the related Gateway repair, and this PR. (role: cloud-worker feature owner and recent area contributor; confidence: high; commits: 4f0e131cd270, c063c8e4f9b3, 411777dc1fcc; files: ui/src/components/cloud-worker-stop.ts, src/gateway/server-methods/environments.ts, src/gateway/worker-environments/placement-dispatch-failure.ts)

Rank-up moves

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

  • Restrict or redesign the Stop lifecycle path and add transitional/failed placement coverage.
  • Resolve the failed exact-head UI E2E and CI-gate checks.

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
steipete force-pushed the steipete/cloud-ui-draft-deadends branch from f1d250d to ead07d2 Compare August 9, 2026 10:46
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Aug 9, 2026
@steipete
steipete merged commit 44a2a87 into main Aug 9, 2026
131 checks passed
@steipete
steipete deleted the steipete/cloud-ui-draft-deadends branch August 9, 2026 11:06
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 10, 2026
* fix(ui): harden cloud draft recovery

Refs openclaw#120953.

* fix(gateway): keep minimal metadata startup lazy

* fix(ui): preserve interrupted cloud setup state

* fix(ui): separate cloud recovery lifecycle fences
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 gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant