Repository navigation
fix: avoid repeated background reads while loading chat - #146953
Conversation
Separate model catalog transports from caller cancellation and explicit deadlines. Advance empty native catalogs without replaying every prior page, and retire cyclic sweeps so discovery can recover. Use indexed child snapshots for announcement facts.
|
🦞👀 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: blocked before merge. Reviewed September 13, 2026, 7:59 AM ET / 11:59 UTC (Revision 4). ClawSweeper reviewWhat this changesThe PR serializes model-catalog refreshes, advances empty native-session discovery without replaying earlier pages, and narrows subagent announcement reads to the relevant child session. Merge readiness⛔ Blocked before merge - 2 items remain This remains a useful, distinct follow-up to the earlier merged catalog repair; current main still contains the redundant-read paths. No blocking correctness findings were identified. Priority: P2 Review scores
Verification
How this fits togetherThe Control UI reads model choices and session catalogs from the Gateway to populate chat controls and the sidebar. Separately, subagent announcements read retained run facts to identify their requester and completion state. flowchart LR
A[Chat and catalog changes] --> B[Scoped model request queue]
B --> C[Gateway catalog reads]
C --> D[Model controls and sidebar]
E[Empty session pages] --> F[Finite discovery progress]
F --> C
G[Subagent announcement] --> H[Child session registry snapshot]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +273, Tests +511, Docs +4. Total +788 across 26 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Chat metadata and announcements should converge with bounded background work, preserved drafts, and measured resource use. Do we have a high-confidence way to reproduce the issue? Yes, from source: invalidation or caller cancellation can release a model request while server work remains outstanding, and empty discovery replays earlier pages. The focused regressions exercise these triggers; this review did not run them. Is this the best way to solve the issue? Yes. The patch extends the existing request, discovery, and registry owners while preserving scope fences and caller cancellation; the scoped agent performance measurements remain outstanding. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 970992db26c8. 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
History |
Keep main’s single queued-refresh owner while preserving finite hidden catalog discovery, cycle recovery, and typed Gateway test fixtures.
Use the application metadata observer for connection retirement and retain cancellation, stale-state, and loading assertions with serialized catalog responses. Exercise held old and new replies through the real Gateway without losing editor drafts.
|
Merged via squash.
|
* commit '4aff70f27016f9acf62d0acc19c8bd3592993e4c': (1537 commits) test: align plugin fixtures with current runtime contracts (#147000) refactor(browser): separate session tab tracking from cleanup (#146973) fix(tests): make systemd clock fixtures private (#146990) fix(linux): retire sleep guards when logind disconnects (#146046) refactor(matrix): share draft fallback delivery (#144840) fix(sessions): preserve cross-agent replies after reload (#146799) test(models): cover quota recovery during catalog discovery (#146708) fix(macos): recover browser sign-in when no browser opens (#146787) fix(process): prevent one-shot agents exiting while polling (#144268) fix(status): label the session inventory as stored (#146979) fix: avoid repeated background reads while loading chat (#146953) refactor(ui): narrow Skill Workshop proposal context (#146977) perf(sessions): keep cleanup responsive and reuse workers (#140897) fix(sessions): prevent stranded writers after abort and restart (#146792) refactor: reuse deferred owners in Gateway and infra fixtures (#146809) fix: prevent queued conversation replies from switching storage (#146984) test(ui): preserve nested failure summaries in CI logs (#146864) fix(test): respect process memory limits in local scheduling (#146298) fix: validate large media data URLs without regexp stack exhaustion (#146972) fix(ui): label model usage contributions as messages (#146735) ...
* temp/pr-145950: (101 commits) refactor(memory-wiki): share freshness result construction (#146935) improve(gateway): use metadata projection for presence (#146817) test(agents): reuse complete Responses model fixtures (#147015) fix(sessions): align the reclamation-memory test with the archive session owner (#147028) refactor(terminal): simplify copy-sensitive token checks (#146934) refactor(media): remove duplicate spaced path fallback (#146933) refactor(cli): reuse command-group names (#146893) improve(plugins): reduce JavaScript generation capture work (#146993) test: align plugin fixtures with current runtime contracts (#147000) refactor(browser): separate session tab tracking from cleanup (#146973) fix(tests): make systemd clock fixtures private (#146990) fix(linux): retire sleep guards when logind disconnects (#146046) refactor(matrix): share draft fallback delivery (#144840) fix(sessions): preserve cross-agent replies after reload (#146799) test(models): cover quota recovery during catalog discovery (#146708) fix(macos): recover browser sign-in when no browser opens (#146787) fix(process): prevent one-shot agents exiting while polling (#144268) fix(status): label the session inventory as stored (#146979) fix: avoid repeated background reads while loading chat (#146953) refactor(ui): narrow Skill Workshop proposal context (#146977) ...
* commit '060e856e5f9df245d63c98990fcb47e18108c6b9': (97 commits) refactor(memory-wiki): share freshness result construction (#146935) improve(gateway): use metadata projection for presence (#146817) test(agents): reuse complete Responses model fixtures (#147015) fix(sessions): align the reclamation-memory test with the archive session owner (#147028) refactor(terminal): simplify copy-sensitive token checks (#146934) refactor(media): remove duplicate spaced path fallback (#146933) refactor(cli): reuse command-group names (#146893) improve(plugins): reduce JavaScript generation capture work (#146993) test: align plugin fixtures with current runtime contracts (#147000) refactor(browser): separate session tab tracking from cleanup (#146973) fix(tests): make systemd clock fixtures private (#146990) fix(linux): retire sleep guards when logind disconnects (#146046) refactor(matrix): share draft fallback delivery (#144840) fix(sessions): preserve cross-agent replies after reload (#146799) test(models): cover quota recovery during catalog discovery (#146708) fix(macos): recover browser sign-in when no browser opens (#146787) fix(process): prevent one-shot agents exiting while polling (#144268) fix(status): label the session inventory as stored (#146979) fix: avoid repeated background reads while loading chat (#146953) refactor(ui): narrow Skill Workshop proposal context (#146977) ...
* commit '4aff70f27016f9acf62d0acc19c8bd3592993e4c': (30 commits) test: align plugin fixtures with current runtime contracts (#147000) refactor(browser): separate session tab tracking from cleanup (#146973) fix(tests): make systemd clock fixtures private (#146990) fix(linux): retire sleep guards when logind disconnects (#146046) refactor(matrix): share draft fallback delivery (#144840) fix(sessions): preserve cross-agent replies after reload (#146799) test(models): cover quota recovery during catalog discovery (#146708) fix(macos): recover browser sign-in when no browser opens (#146787) fix(process): prevent one-shot agents exiting while polling (#144268) fix(status): label the session inventory as stored (#146979) fix: avoid repeated background reads while loading chat (#146953) refactor(ui): narrow Skill Workshop proposal context (#146977) perf(sessions): keep cleanup responsive and reuse workers (#140897) fix(sessions): prevent stranded writers after abort and restart (#146792) refactor: reuse deferred owners in Gateway and infra fixtures (#146809) fix: prevent queued conversation replies from switching storage (#146984) test(ui): preserve nested failure summaries in CI logs (#146864) fix(test): respect process memory limits in local scheduling (#146298) fix: validate large media data URLs without regexp stack exhaustion (#146972) fix(ui): label model usage contributions as messages (#146735) ...
) * fix: avoid repeated background reads while loading chat Separate model catalog transports from caller cancellation and explicit deadlines. Advance empty native catalogs without replaying every prior page, and retire cyclic sweeps so discovery can recover. Use indexed child snapshots for announcement facts. * test(ui): verify catalog callers across queued reads Use the application metadata observer for connection retirement and retain cancellation, stale-state, and loading assertions with serialized catalog responses. Exercise held old and new replies through the real Gateway without losing editor drafts. * test(ui): isolate palette catalog request scope
Related: #146810
What Problem This Solves
Fixes redundant background reads that compete with opening and using a chat, especially during catalog updates or discovery of large native-session histories.
User Impact
Model controls keep their current choices while refreshes converge, hidden native catalogs make forward progress, and subagent announcements avoid loading unrelated retained runs.
Why This Change Was Made
The model catalog owner retains one active request and one queued demand per connection, projection, and timeout policy. Publication, caller cancellation, and explicit numeric deadlines no longer release an outstanding transport early. Callers still receive their own timeout; a same-scope retry waits for the outstanding read or connection retirement instead of duplicating server work. Stale results, pushed snapshots, and reentrant subscriptions retain their existing authority checks.
Hidden native catalogs now advance a finite discovery sweep separately from visible-page reconciliation, within the existing single refresh lifecycle. Each refresh still checks the first page, completed empty sweeps restart, and archive/adoption or connection changes clear progress. Single-child announcement lookups use the existing indexed child snapshot, preserving generation selection, live-memory precedence, and persistence semantics.
Evidence
Regressions failed before each repair. Actual Gateway request-correlation tests cover invalidation bursts, cancellation, explicit timeout/retry/late-response ordering, queued deadlines, pushed snapshots, reconnects, and reentrant subscribers. Hidden discovery reaches the same eighth page in 14 requests instead of 35, with fresh-head, membership, cursor-error, visibility, and scope cases retained. The announcement tests verify requester and completion facts without full registry hydration.
Focused suites passed: 260 model-catalog and caller tests, 167 catalog tests after current-main integration, and 41 registry tests. Independent P2 reviews are clean. Final integration typechecks, lint, styles, export, schema, and import-cycle guards passed. Combined P2 review caught and led to correction of cursor-cycle recovery; its regression failed before the correction and now passes. The corrected combined review is clean. CI exposed caller fixtures coupled to raw cancellation and overlapping replies. Those fixtures now use the real metadata observer and verify serialized/stale-result behavior. The complete UI unit suite passed 17,326 tests across 991 files, and all 56 real-Gateway tests across 28 files passed on the final head, including held-response, draft-preservation, command-palette publication, and selected-agent scope checks. The palette test now identifies its own exact request without depending on the last request from concurrent Chat callers. Exact-head CI is 34755573027; production performance verification follows the canonical deployment after landing. No schema, retention, permission, dependency, or protocol changes are included.