Repository navigation
refactor(ui): adopt @lit/task for async data lifecycle - #115131
Conversation
- migrate chat diff/discussion, new-session discovery, and MCP app setup reads - migrate usage, plugins, transcript/checkpoint, worktree, memory-import, and model-setup reads - delete read-lane request counters, abort-controller epochs, and current-request predicates while retaining mutation epochs and keyed caches
Dependency GuardThis PR changes dependency-related files. Maintainers should confirm these changes are intentional. Changed files:
Maintainer follow-up:
|
Dependency graph changes notedThis PR includes dependency graph changes. The dependency guard is informational because the PR author is a repository admin or a member of
Security review is still recommended before merge when the dependency graph change is intentional. |
|
Codex review: needs real behavior proof before merge. Reviewed July 28, 2026, 7:12 AM ET / 11:12 UTC. ClawSweeper reviewWhat this changesThis PR adds exact-pinned Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 4 items remain Keep open. This is a broad but plausible Control UI lifecycle refactor; the reviewed diff and focused stale-result tests do not establish a discrete patch defect, but the PR still lacks inspectable after-fix evidence from a real browser session showing that a superseded request cannot repaint an older view. The Likely related people:
Priority: P3 Review scores
Verification
How this fits togetherThe Control UI renders Gateway-backed pages and components that issue asynchronous read RPCs as connection, route, and user-selection inputs change. This PR moves selected read lanes from component-specific cancellation and stale-result logic into Lit Task, which supplies argument-keyed reruns, cancellation signals, and pending/complete/error state for rendering. flowchart LR
A[Gateway connection and route state] --> B[Control UI component]
B --> C[Task arguments]
C --> D[Async Gateway read]
D --> E[Task lifecycle state]
E --> F[Rendered page or panel]
C --> G[Superseded request cancellation]
G --> E
Before merge
Agent review detailsSecurityNone. PR surfaceSource +279, Tests +58, Config +2, Other +14. Total +353 across 29 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep Task limited to read lanes, preserve the existing mutation and streaming guards, and add redacted browser or terminal-backed proof that deliberately resolves an older Gateway request after a newer selection while the UI continues to display only the newer state. Do we have a high-confidence way to reproduce the issue? Not applicable as a reported bug: this PR is a preventive internal refactor. The branch includes source-level race tests, but no inspectable real browser run has been supplied to reproduce the before/after behavior in a live setup. Is this the best way to solve the issue? Yes in principle: a shared, argument-keyed Task abstraction is a more maintainable way to protect read lanes from stale completions than repeating counters and abort bookkeeping. The remaining requirement is proof that the chosen lifecycle semantics preserve visible behavior across a real rapid-switching flow. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 64991433137f. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
|
Merged via squash.
|
* refactor(ui): adopt @lit/task for async data lifecycle - migrate chat diff/discussion, new-session discovery, and MCP app setup reads - migrate usage, plugins, transcript/checkpoint, worktree, memory-import, and model-setup reads - delete read-lane request counters, abort-controller epochs, and current-request predicates while retaining mutation epochs and keyed caches * chore(ui): drop dead plugin search helper (knip) * chore(deps): allowlist @lit/task as root UI-workspace dependency in knip * fix(ui): preserve usage refresh lifecycle * test(ui): source workboard fixture copy from en locale (raw-copy gate) * test(ui): read workboard fixture copy via t() (typed locale access) * style: format test-support imports
What Problem This Solves
The Control UI hand-rolls the same async data lifecycle in dozens of components: fire an RPC from
updated(), stash results in@statefields, guard staleness with a monotonic generation counter compared after everyawait, checkthis.isConnected, and juggleloading/errorbooleans. An audit found ~85 such counters across 45 files, plus components carrying both an AbortController AND an epoch for the same race, and one page tracking aloadedKey/requestedKey/loadedClient/requestedClientquadruple that reimplements args-comparison by hand.Why This Change Was Made
@lit/task(official Lit-team package, exact-pinned 1.0.3 like our@lit/context) replaces the entire pattern: args-keyed task function, automatic discard of stale completions, per-run AbortSignal, INITIAL/PENDING/COMPLETE/ERROR status for rendering. Task semantics were verified from the installed source, not memory (shallow arg compare via Lit notEqual, auto-run during hostUpdate,_callIdstale-commit guard, abort-only-signals-pending, initialState retention — the last two handled explicitly in disconnect/reset paths).This is wave 1 of 2: foundation plus the highest-value surfaces. Rules applied consistently: Task is for reads (mutations/streaming/pagination stay hand-rolled — mutation generations and apply epochs retained where they guard writes); debounce timers kept, feeding debounced values into args; render output byte-identical.
User Impact
No behavior change. Rapid navigation/switching races (stale responses painting over newer ones) are now handled structurally by Task instead of per-site counter discipline, and ~1,100 lines of lifecycle scaffolding are deleted alongside an equal amount of new, uniform Task declarations (net −2 non-test LOC excluding lockfile, with 14 fewer bespoke lifecycle mechanisms).
Evidence
Migrated: session-diff-panel, session-discussion-panel (7 guard sites → one Task), gateway-name-discovery + cloud-profile-discovery (bespoke token classes → stateless loaders), new-session-page, mcp-app-view (Task result owns iframe/bridge teardown via abort), usage-page (3 request IDs + 3 loading flags → 3 Tasks), plugins-page (3 generations → 3 Tasks, mutation lane untouched), sessions-page (transcript-search + checkpoint lanes only; session-list lane untouched), worktrees-page (branches race on keystroke fixed), memory-import-page + onboarding-memory-import, model-setup-page (3 AbortControllers + 3 epochs → 3 Tasks).
Validation: UI prod + test tsgo; targeted oxlint/format; 131 focused tests; targeted browser tests; full UI e2e 360/361 (one unrelated Workboard form-fill flake, passed 3/3 on isolated retry); commit-mode autoreview clean. Testbox was unavailable for the new dependency; trusted-source proof ran locally per policy. Numstat: 1449/1155 total, non-test excluding lockfile 1122/1124 (net −2).