Skip to content

fix(history): serialize message polling (INV-07) - #149

Merged
mergify[bot] merged 2 commits into
mainfrom
codex/inv-07-performance
Oct 3, 2026
Merged

mergify[bot] merged 2 commits into
mainfrom
codex/inv-07-performance

Conversation

@Cuarroc

@Cuarroc Cuarroc commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Der Nachrichtenverlauf startet bei einem langsamen Lesezugriff jetzt keine immer neuen Abfragen mehr.
Ein Regressionstest misst dafür über 30 Sekunden virtuelle Zeit höchstens eine offene Anfrage.
Die übrigen bestätigten Ressourcenrisiken sind unten als getrennte Folgepakete erfasst.

Report

What changed

  • Added a focused fake-timer regression test for overlapping HistoryView message polls.
  • Serialized message reads per worker with a small in-flight set in src/components/HistoryView.tsx:32-48.
  • The package changes 47 lines, stays below the size-S limit, and does not touch a serial seam.

Evidence

  • npx vitest run src/components/HistoryView.polling.test.tsx before the fix: exit 1; 30 seconds of virtual time produced 4 calls while the first promise was still pending.
  • npx vitest run src/components/HistoryView.polling.test.tsx after the fix: exit 0; the same measurement produced 1 call.
  • npm run typecheck: exit 0.
  • npm run lint: exit 0.
  • bash scripts/ci/red-first.sh: exit 0; the test was absent at merge base d738595 and green at head b95f186.
  • bash scripts/ci/gates.sh lane prepush: exit 0; 393 frontend tests, 502 HQ tests, and 1658 Rust tests passed, with 7 Rust tests skipped.
  • Push hook bash scripts/ci/gates.sh lane prepush: exit 0.
  • git ls-remote origin codex/inv-07-performance: exit 0; remote head equals b95f1865add87bd49d8935b49ec8316a3a9b5390.

NICHT ABGEDECKT

  • Linux does not compile or run the #[cfg(windows)] tests for run_in_pty, npm_shim, ConPTY, and DPAPI, nor the Windows-only clippy arms. The Windows lane runs in the merge queue.
  • External services and real slow IPC were not exercised; the resource bound is measured deterministically with a pending mocked IPC promise.

Review

Review: Stufe B abgeschlossen; Windows-Bahn läuft in der Merge-Queue.

Review disposition

Reviewer: Claude Sonnet 5.5 (Familie Claude, Autor: codex), Kandidat b95f1865add87bd49d8935b49ec8316a3a9b5390, Diff 47 Zeilen, Gates CI grün (linux, red-first).

  • Niedrig — src/components/HistoryView.tsx:32-48: a late response from worker A can still call setMessages after switching to worker B (stale write). Rejected: pre-existing race, not introduced or worsened by this change; out of package scope. Follow-up candidate for the shared polling primitive.
  • Niedrig — src/components/HistoryView.tsx:53-57: switching A→B→A while A's read is pending skips the new refresh and shows the empty state until the old read returns. Rejected: self-heals when the pending read resolves (bounded by the IPC time), cosmetic only.
  • Hoch/Mittel: keine.

Bestandsaufnahme

  • Mittel — src/lib/useQuestions.ts:84,127,131; src-tauri/src/store.rs:3924-3963: the five-second poll fetches every matching question without a SQL limit, then trims closed history to 50 only after DB, Rust, IPC, and React copies; proposed package: a seam-coordinated bounded open-plus-recent query.
  • Mittel — src/lib/useAttentionBlockers.ts:49,88: every 15 seconds a new O(worker count) readiness batch starts even when the previous batch is pending; proposed package: serialize or cancel batches and prove the request bound with fake timers.
  • Mittel — src-tauri/src/digest.rs:472-480; src-tauri/src/store.rs:1835-1851: a daily digest loads every message for every worker into one vector and sorts the complete set in memory, while the SQL query deliberately has no limit; proposed package: a seam-coordinated chunked or streaming digest read that preserves complete-day semantics.
  • Niedrig — src/lib/useBoard.ts:93-100, src/components/UsageView.tsx:131-135, src/components/StatisticsView.tsx:127-133, src/components/ActivityView.tsx:158-161, src/components/InsightsView.tsx:79-83: independent interval pollers can overlap their own asynchronous reads; proposed package: a shared serialized polling primitive migrated in small frontend batches.
  • Idee, niedrig — src/lib/useBoard.ts:93-104: board status events already coexist with a five-second fallback poll; proposed package: one visibility-aware polling coordinator with event-triggered invalidation and backoff to reduce duplicate background reads.

Test-First: src/components/HistoryView.polling.test.tsx::keeps at most one message request in flight
Test-First: src/components/HistoryView.polling.test.tsx::keeps at most one message request in flight
@Cuarroc
Cuarroc marked this pull request as ready for review October 3, 2026 01:05
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-03T01:07:11.621239Z b95f186 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@mergify

mergify Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@Cuarroc

Cuarroc commented Oct 3, 2026

Copy link
Copy Markdown
Owner Author

@Mergifyio queue

@mergify

mergify Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 43 minutes 9 seconds in the queue, including 10 minutes 12 seconds running CI.

Required conditions to merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant