Skip to content

refactor(ui): share request subscription cancellation - #140860

Merged
steipete merged 1 commit into
mainfrom
steipete/dedup-ui-0906-requests
Sep 7, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/dedup-ui-0906-requests

Conversation

@steipete

@steipete steipete commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Model catalog requests and session-reference lookups separately implement subscriber registration, per-consumer abort racing, last-member producer cancellation, and listener/member cleanup. Maintaining that cancellation boundary in two places makes it easier for one cancelled consumer to retire another consumer's work.

Why This Change Was Made

lib/shared-request-subscription.ts now owns consumer subscription and cleanup. Callers choose their existing membership identity: a fresh object for each model catalog call, and the AbortSignal itself for route lookup. Route cache cleanup stays in the same synchronous final-cleanup step and retains its shared-request identity check. Production delta: +48/-66, net -18; tests unchanged.

User Impact

No intended behavior change. Catalog callers without a signal remain members until completion. Catalog requests still forward their existing producer signal to models.list; route lookup still only prevents deferred startup and abandons cancelled consumers, without adding a signal to sessions.resolve. Abort reasons, cache TTL/cooldown, refresh fencing, and connection ownership are unchanged.

Evidence

All 55 existing model-catalog, route-resolution, and route-handoff cases passed. UI build and explicit performance passed at 346474 B startup JavaScript gzip and 8 requests, with the baseline unchanged. Independent Codex review was clean through P2; node scripts/check-changed.mjs passed.

node scripts/run-vitest.mjs ui/src/lib/model-catalog-store.test.ts ui/src/pages/chat/route-resolution.test.ts ui/src/pages/chat/route-resolution-handoff.test.ts

Source inspection found no current runtime caller intentionally starting concurrent reference lookups under one signal: the four loadChatRoute call sites are mutually exclusive or sequential, and the installed router coalesces same-match loads and creates a controller per navigation. The extraction nevertheless preserves signal-keyed membership exactly, including concurrent shared-signal calls. It does not change either owner's cancellation semantics.

This is the shared-request item in the maintainer-requested UI consolidation campaign. No configuration, wire, public SDK, or persistent-state changes.

Rebased onto freshly fetched main 61d957a9cb64bd8c70cc125e644778b3fb034c49; full pre/post-rebase patches compare byte-identically. Current head: a0f1a72319a268a25f9f14fc2642c269a5f873fe. Focused local proof applies to that unchanged patch. Full pnpm build on this rebased head passed in 14m 20.4s, followed by the explicit performance check. Hosted CI run 34086799540 passed for the exact head. Native review artifacts are validated; prepare/merge use hosted-proof mode, without a separate Testbox lease.

Preserve caller-selected membership, abort reasons and synchronous release ordering while keeping producer and cache policies local. Proof: 55 focused catalog and route cases, check-changed, UI build and performance.
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: S maintainer Maintainer-authored PR labels Sep 7, 2026
@steipete
steipete marked this pull request as ready for review September 7, 2026 05:26
@clawsweeper clawsweeper Bot added 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 1:36 AM ET / 05:36 UTC.

ClawSweeper review

What this changes

Shares Control UI request subscription and cancellation handling between model catalog loading and session-link resolution while preserving their existing cleanup policies.

Merge readiness

✅ Ready for maintainer review

The consolidation remains useful: current main still implements subscription cleanup separately. No introduced correctness or security defect was found, and this maintainer-authored PR is protected from automatic closure.

Priority: P3
Reviewed head: a0f1a72319a268a25f9f14fc2642c269a5f873fe

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving extraction with relevant existing coverage and no blocking findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored internal extraction is exempt from the external-contributor proof gate; reported focused tests and builds are supplemental validation, not live cancellation proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored internal extraction is exempt from the external-contributor proof gate; reported focused tests and builds are supplemental validation, not live cancellation proof.
Evidence reviewed 6 items Verified introduced extraction: The pinned base-to-head diff moves the existing abort race and membership cleanup into one helper. Catalog calls retain fresh object identities; session lookups retain signal identities and synchronous, identity-checked cache cleanup.
Current-main necessity: Fetched main retains the private catalog subscription helper; inspection of its session-reference owner also shows the separate inline subscription implementation. The requested consolidation is not present there.
Producer and connection boundaries preserved: Session resolution still checks connection identity before and after the request, prevents deferred startup after cancellation, and does not forward the producer signal to sessions.resolve. Catalog loading still forwards its existing optional producer signal to models.list. These are OpenClaw UI lifecycle contracts; this extraction does not depend on Codex runtime semantics.
Findings None None.
Security None None.

How this fits together

The Control UI requests model catalogs and resolves session links through the Gateway. Shared subscriptions let individual consumers cancel without abandoning work that another consumer still needs.

flowchart TD
  A[Model catalog consumers] --> C[Shared request subscription]
  B[Session link navigation] --> C
  C --> D[Await result or consumer cancellation]
  D --> E[Other subscribers remain]
  E -->|Yes| F[Keep shared request alive]
  E -->|No| G[Cancel producer when supported]
  D --> H[Release membership and caller cleanup]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -18. Total -18 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 3 48 66 -18
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 48 66 -18

Review metrics

None.

Technical review

Best possible solution:

Keep subscription mechanics shared while leaving request production, cache fencing, and connection ownership with each caller.

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

Not applicable: this PR consolidates existing behavior rather than reporting a new failure; source comparison found no introduced failing path.

Is this the best way to solve the issue?

Yes. The extraction removes duplicated mechanics without moving producer policy or changing caller-selected membership and cleanup ordering.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4c2acea8ecc4.

Labels

Label changes:

  • add P3: This is a bounded internal consolidation with no intended user-visible behavior change.
  • 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: The maintainer-authored internal extraction is exempt from the external-contributor proof gate; reported focused tests and builds are supplemental validation, not live cancellation proof.

Label justifications:

  • P3: This is a bounded internal consolidation with no intended user-visible behavior change.
  • 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: The maintainer-authored internal extraction is exempt from the external-contributor proof gate; reported focused tests and builds are supplemental validation, not live cancellation proof.

Evidence

What I checked:

  • Verified introduced extraction: The pinned base-to-head diff moves the existing abort race and membership cleanup into one helper. Catalog calls retain fresh object identities; session lookups retain signal identities and synchronous, identity-checked cache cleanup. (ui/src/lib/shared-request-subscription.ts:12, a0f1a72319a2)
  • Current-main necessity: Fetched main retains the private catalog subscription helper; inspection of its session-reference owner also shows the separate inline subscription implementation. The requested consolidation is not present there. (ui/src/lib/model-catalog-store.ts:146, 4c2acea8ecc4)
  • Producer and connection boundaries preserved: Session resolution still checks connection identity before and after the request, prevents deferred startup after cancellation, and does not forward the producer signal to sessions.resolve. Catalog loading still forwards its existing optional producer signal to models.list. These are OpenClaw UI lifecycle contracts; this extraction does not depend on Codex runtime semantics. (ui/src/pages/chat/route-loader-session-reference.ts:95, a0f1a72319a2)
  • Existing cancellation coverage: Existing catalog tests cover coalesced refreshes, independent subscriber cancellation, final-subscriber cancellation, and immediate replacement of an aborted request. Route tests reject results after navigation cancellation. These tests were inspected, not executed during this read-only review. (ui/src/lib/model-catalog-store.test.ts:196, a0f1a72319a2)
  • Prior area history: Current-main history records prior catalog work by Peter Steinberger, Erick Kinnee, Josh Lehman, and Vyctor H. Brzezowski. Deeper blame and historical blob inspection could not complete because required objects were unavailable and the network lookup failed; no line-introduction attribution is claimed. (ui/src/lib/model-catalog-store.ts, 4c2acea8ecc4)
  • Captured validation and maintainer context: The supplied PR body identifies a maintainer-requested consolidation campaign and reports 55 focused cases, UI build, performance, and changed checks passing for the unchanged patch. Supplied GitHub context identifies MEMBER authorship and the protected maintainer label. No live-runtime result is inferred from those test/build claims. (a0f1a72319a2)

Likely related people:

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

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 merged commit afed2b5 into main Sep 7, 2026
186 checks passed
@steipete
steipete deleted the steipete/dedup-ui-0906-requests branch September 7, 2026 05:42
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
Preserve caller-selected membership, abort reasons and synchronous release ordering while keeping producer and cache policies local. Proof: 55 focused catalog and route cases, check-changed, UI build and performance.
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 maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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