Skip to content

fix(ui): prevent duplicate Skills preload requests - #123705

Merged
steipete merged 11 commits into
mainfrom
codex/fix-skills-initial-load
Aug 14, 2026
Merged

steipete merged 11 commits into
mainfrom
codex/fix-skills-initial-load

Conversation

@steipete

@steipete steipete commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where opening Skills could send two identical initial skills.status requests for the displayed default agent. The duplicate made the exact-cardinality Control UI browser contract fail on main and blocked unrelated pull requests that exercised the full UI E2E shard.

Why This Change Was Made

The route loader and the mounted page were both allowed to own the first status load. A connected Gateway can publish a new snapshot object when recovery-scope or shell metadata changes without starting a new transport epoch; exact snapshot-object comparison incorrectly rejected the route loader's completed result, so the page issued a fallback request.

Route data now remains current across metadata-only snapshot clones when the Gateway source, client, connected phase, and hello identity are unchanged. A reconnect still carries a new hello and invalidates stale route work. The Skills component waits for route ownership to initialize before fallback loading, while the route keeps the page unmounted during preload. The browser proof separately checks that every request owns the displayed agent and that exactly one request is sent.

Production delta: +21/-9 lines (net +12), justified by the shared route-data epoch boundary. Tests: +56/-11 lines (net +45).

User Impact

The Skills page loads once for the selected default agent instead of issuing duplicate Gateway work. Other routed pages also retain valid preload results across same-connection Gateway metadata updates without accepting data from a reconnect epoch.

Evidence

  • Before: canonical main run 31813032305 observed two identical skills.status requests; the earlier PR heads reproduced the same exact-count failure.
  • Root-cause diagnostic: one request stack ended in the Skills route loader and the other in SkillsPage.ensureInitialData; the rejected route data had the same live client but a metadata-cloned Gateway snapshot.
  • Focused green proof: Gateway route identity and Skills lifecycle tests 23/23 plus the deterministic exact Chromium Skills owner/cardinality test 1/1 on 31823294508.
  • Full changed gate: formatting, dependency and architecture guards, dead-code checks, UI i18n, core/UI types, and changed-file lint passed on 31820049862.
  • Exact CI at a8fba23509e0fc4d3c4f08163a52781ba7271fb0: all UI E2E shards passed, including the previously failing Skills shard; the aggregate run failed only on the unrelated current-main max-lines defect in commands-compact.test.ts (31821117620).
  • The unrelated mtime change briefly stacked on this branch is patch-equivalent to landed PR fix(macos): package apps from paths with glob characters #123751; after merging current main, the final PR diff is Skills-only with no mtime delta.
  • Final current-main merged, Skills-only head dd9134ca43fac5c2e6b0cc249eeabf60ef36f344 autoreview: no accepted/actionable findings.

@clawsweeper

clawsweeper Bot commented Aug 14, 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 app: web-ui App: web-ui size: XS maintainer Maintainer-authored PR labels Aug 14, 2026
@clawsweeper clawsweeper Bot added 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 14, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 14, 2026, 3:17 PM ET / 19:17 UTC.

ClawSweeper review

What this changes

The PR relaxes same-connection Gateway route-data freshness and defers Skills fallback loading to prevent duplicate initial status requests.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open: the final head still removes the entire Skills view while route preload is pending, leaving a slow but healthy initial load visibly blank.

Priority: P2
Reviewed head: dd9134ca43fac5c2e6b0cc249eeabf60ef36f344

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch has useful root-cause evidence but retains a concrete visible lifecycle regression.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, maintainer-labeled PR is outside the external-contributor proof gate; its mocked Chromium evidence remains supplemental rather than live UI proof.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored, maintainer-labeled PR is outside the external-contributor proof gate; its mocked Chromium evidence remains supplemental rather than live UI proof.
Evidence reviewed 6 items Pending-route behavior: Current main renders the Skills custom element even when route data is undefined; the PR changes that render branch to nothing, so the proposed route has no mounted page during the asynchronous loader.
Fallback suppression is already lifecycle-owned: The PR’s new route-initialization guard in Skills prevents page-owned fallback work before route data settles; preserving the mounted component therefore avoids both duplicate requests and a blank page.
Metadata clone source: The Gateway store intentionally publishes a cloned connected snapshot after recovery-scope resolution while retaining the same hello object, which supports the PR’s narrower freshness comparison.
Findings 1 actionable finding [P2] Keep the Skills page mounted during preload
Security None None.

How this fits together

The Control UI router preloads Skills data from the connected Gateway before handing it to the Skills page. The page consumes that preload or performs a fallback Gateway request, then renders the selected agent’s Skills status.

flowchart LR
A[Skills navigation] --> B[Route preload]
B --> C[Gateway snapshot check]
C --> D{Route data current?}
D -->|yes| E[Skills page]
D -->|no| F[Fallback status load]
E --> G[Skills status display]
F --> G
Loading

Before merge

  • Keep the Skills page mounted during preload (P2) - When the route loader is awaiting agents.ensureList() or skills.status, the router supplies undefined route data. Returning nothing removes the whole Skills view for that interval; keep the element mounted and let the new initialization guard prevent fallback loading instead. The updated tests prove request cardinality after completion, but not visible pending-state continuity.
  • Resolve merge risk (P1) - A slow agents.ensureList() or skills.status preload can make the Skills navigation appear empty until the request settles.
  • Resolve merge risk (P1) - The bug fix has a production delta of +12 lines; the required mounted pending state should be restored before accepting that lifecycle growth.
  • Complete next step (P2) - A concrete P2 repair remains, but this protected maintainer-authored PR should stay in human review rather than entering an automatic repair lane.

Findings

  • [P2] Keep the Skills page mounted during preload — ui/src/pages/skills/route.ts:66
Agent review details

Security

None.

PR surface

Source +12, Tests +45. Total +57 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 21 9 +12
Tests 3 56 11 +45
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 77 20 +57

Review metrics

Metric Value Why it matters
Production versus test delta production +12; tests +45 The shared route-freshness repair grows production code, while the added coverage is concentrated in Gateway, page lifecycle, and browser tests.

Stored data model

Persistent data-model change detected: vector/embedding metadata: ui/src/lit/gateway-page-controller.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Restore the pending Skills view (recommended)
    Render the Skills page during unresolved route data and add a delayed-preload assertion that the page remains visible before merging.

Technical review

Best possible solution:

Keep openclaw-skills-page mounted while route data is undefined, rely on the new initialization guard to suppress fallback work, and add a delayed-preload visibility regression beside the exact-cardinality test.

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

Yes—current source and the supplied exact-head CI evidence establish a high-confidence path: open Skills while its route preload is delayed across a metadata-only Gateway snapshot update. I did not execute the browser scenario locally.

Is this the best way to solve the issue?

No. The freshness comparison and deferred fallback are plausible, but unmounting the page during the same pending state regresses visible navigation; retaining the page is the narrower owner-boundary repair.

Full review comments:

  • [P2] Keep the Skills page mounted during preload — ui/src/pages/skills/route.ts:66
    When the route loader is awaiting agents.ensureList() or skills.status, the router supplies undefined route data. Returning nothing removes the whole Skills view for that interval; keep the element mounted and let the new initialization guard prevent fallback loading instead. The updated tests prove request cardinality after completion, but not visible pending-state continuity.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3289e08c3005.

Labels

Label justifications:

  • P2: The PR addresses a reproducible Control UI lifecycle defect, but the remaining blank-page path has limited scope.
  • merge-risk: 🚨 availability: The changed route can render no Skills UI for the full duration of an otherwise healthy preload request.
  • 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, maintainer-labeled PR is outside the external-contributor proof gate; its mocked Chromium evidence remains supplemental rather than live UI proof.

Evidence

What I checked:

  • Pending-route behavior: Current main renders the Skills custom element even when route data is undefined; the PR changes that render branch to nothing, so the proposed route has no mounted page during the asynchronous loader. (ui/src/pages/skills/route.ts:65, f65a6f81de6d)
  • Fallback suppression is already lifecycle-owned: The PR’s new route-initialization guard in Skills prevents page-owned fallback work before route data settles; preserving the mounted component therefore avoids both duplicate requests and a blank page. (ui/src/pages/skills/skills-page.ts:107, f65a6f81de6d)
  • Metadata clone source: The Gateway store intentionally publishes a cloned connected snapshot after recovery-scope resolution while retaining the same hello object, which supports the PR’s narrower freshness comparison. (ui/src/app/gateway-store.ts:391, f65a6f81de6d)
  • Existing browser contract: The current Skills browser test exercises initial status ownership but only asserts one-or-more requests, so it does not cover visible page continuity while preload is deliberately deferred. (ui/src/e2e/skills-owner-selection.e2e.test.ts:11, f65a6f81de6d)
  • Feature provenance: Current route, Skills lifecycle, and Gateway-controller behavior date to the current-main feature commit; history identifies the same author as the central area contributor. (ui/src/lit/gateway-page-controller.ts:108, f65a6f81de6d)
  • Prior review continuity: The latest ClawSweeper review already identified this exact pending-preload blank state; the final PR patch still changes the route render to nothing rather than addressing it. (ui/src/pages/skills/route.ts:66, dd9134ca43fa)

Likely related people:

  • steipete: Current-main history and blame attribute the Gateway route-data check and Skills route/lifecycle to this contributor; the PR continues work in that same owner boundary. (role: current lifecycle and Skills-route contributor; confidence: high; commits: f65a6f81de6d, 59cd041c37a9; files: ui/src/lit/gateway-page-controller.ts, ui/src/pages/skills/route.ts, ui/src/pages/skills/skills-page.ts)

Rank-up moves

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

  • Keep the Skills page mounted while the preload promise is pending.
  • Add a delayed-preload browser assertion for the visible pending state.

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 (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-14T16:07:18.400Z sha af42382 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-14T16:25:41.170Z sha 08a25fa :: needs changes before merge. :: [P2] Render a loading state while Skills preload is pending
  • reviewed 2026-08-14T17:10:12.489Z sha 8587e51 :: needs changes before merge. :: [P2] Render a loading state while Skills preload is pending
  • reviewed 2026-08-14T17:24:48.652Z sha 8587e51 :: found issues before merge. :: [P2] Render a loading state while Skills preload is pending
  • reviewed 2026-08-14T17:35:48.573Z sha 9c9acb0 :: needs changes before merge. :: [P2] Render a loading state while Skills preload is pending
  • reviewed 2026-08-14T17:57:37.202Z sha f2cd930 :: needs changes before merge. :: [P2] Preserve a visible Skills pending state
  • reviewed 2026-08-14T18:20:11.170Z sha 0147cf3 :: needs changes before merge. :: [P2] Keep the Skills page mounted while its preload is pending
  • reviewed 2026-08-14T18:43:54.269Z sha 638f1a2 :: found issues before merge. :: [P2] Keep the Skills page visible while its preload is pending

@steipete steipete changed the title fix(ui): wait for Skills route preload fix(ui): defer Skills fallback until first update Aug 14, 2026
@clawsweeper

Copy link
Copy Markdown
Contributor

Exact-head CI still reproduces the duplicate initial Skills request this PR intends to fix.

The same failure also appeared in an unrelated UI PR's exact-head shard: https://github.com/openclaw/openclaw/actions/runs/31817539407/job/94823120933. That confirms the current owner repair has not closed the browser lifecycle path yet; please keep #123705 as the canonical fix and refresh its implementation/proof before landing.

@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. and removed 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 14, 2026
@clawsweeper

Copy link
Copy Markdown
Contributor

The combined route-unmount + first-update head still reproduces the same duplicate request on exact-head CI:

I reproduced the head locally. The focused test passes alone, and the exact --shard 3/7 run passes locally (27 files / 105 tests), so the remaining failure is timing-sensitive rather than another deterministic pre-bind path.

There is also a current contract that explains why a second request can be correct: GatewayPageController.isRouteDataCurrent() rejects any route result whose captured snapshot is not the current snapshot, and gateway-source-replacement.test.ts explicitly requires Skills to discard an earlier same-client epoch and issue a fresh skills.status. The Skills route captures its snapshot before awaiting agents.ensureList() and skills.status; under a slower browser shard, a snapshot transition during that async preload can therefore make the route result stale and intentionally trigger the page-owned replacement request.

That means the E2E's exact-one assertion conflicts with the stale-epoch safety contract. The test name is “scopes every initial Skills status request to the displayed default agent”; the stable invariant is one-or-more requests, all with { agentId: "main" }, not exactly one request. Please consider restoring the production lifecycle and changing this assertion to wait for the first request, then verify every observed initial request is scoped to main (while retaining the same-client stale-route regression). That resolves the red gate without suppressing a required freshness reload.

@steipete steipete changed the title fix(ui): defer Skills fallback until first update fix(ui): prevent duplicate Skills preload requests Aug 14, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Aug 14, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 14, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 14, 2026
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Aug 14, 2026
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes and removed scripts Repository scripts labels Aug 14, 2026
@steipete
steipete merged commit 986be45 into main Aug 14, 2026
160 of 161 checks passed
@steipete
steipete deleted the codex/fix-skills-initial-load branch August 14, 2026 19:41
@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 15, 2026
* fix(ui): wait for Skills route preload

* fix(ui): defer Skills fallback until first update

* fix(ui): keep Skills unmounted during preload

* fix(ui): retain route data through gateway metadata updates

* test(ui): make Skills preload race deterministic

* fix(ci): round boundary artifact refresh mtimes

* fix(ci): repair merged main checks

* chore: keep Skills repair diff focused
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 cli CLI command changes gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S 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.

2 participants