Repository navigation
refactor(ui): share request subscription cancellation - #140860
Conversation
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.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 1:36 AM ET / 05:36 UTC. ClawSweeper reviewWhat this changesShares 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 Review scores
Verification
How this fits togetherThe 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]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -18. Total -18 across 3 files. View PR surface stats
Review metricsNone. Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
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.
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.tsnow 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 tosessions.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.mjspassed.Source inspection found no current runtime caller intentionally starting concurrent reference lookups under one signal: the four
loadChatRoutecall 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. Fullpnpm buildon 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.