Repository navigation
perf: narrow Send anyway's event read; memoize Google settings' last-visited bot - #47978
Conversation
…e settings' last-visited bot Send anyway now reads the events from its ask onward plus earlier asks (whose question lines still decide pairing), instead of the item's whole history inside the write. Google settings reworks the host's last-visited bot only when visit times or the host's bot list change, not on every store update.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Two small performance follow-ups. No behavior or UI change.
STA-17703: Send anyway read the item's whole history inside the write
skippedQuestionsOf(src/main/bots/bot-item-waiting-ask-keep.ts) replayed every event of the item to find which lines the answer skips. It now reads the events from the ask onward, plus earlier asks. Earlier asks are still needed: their question lines decide whether a later comment likeEarlier question → Yesanswers the current ask's first open line by order. A plainid >= askread would change the skipped lines in that case.Test:
bot-items-open-questions.test.tsadds that case (earlier ask, later ask, a comment answering the earlier one, then Send anyway). It passes with this change and fails with a plainid >= askread.STA-17704: Google settings recomputed the last-visited bot on every store update
useLastVisitedBot(use-google-setup-start.tsx) looped over the host's bots in a store selector on every app-store update. The selector is now memoized: it is rebuilt when the host's bot list changes and recomputes only whenlastVisitedAtByWorktreeIdchanges. Same pattern ascreateBotHomesSelectorinbot-catalog.ts.Checks run locally: the changed test file,
tc:web,tc:node, oxlint/oxfmt on the changed files, and the whole-hot-map and layout-writer ratchets.Performance
Both changes do less work. Send anyway's write no longer decodes or replays the rows before the ask in JS; SQLite filters them to earlier asks. Measured per Send anyway click (rows returned in parentheses):
The
OR json_extractfilter still scans the item's events in SQLite, so cost still grows with the item's history, about 2.3 ms at 11.6k events, once per click. Left as is: a two-step read (events since the ask first, earlier asks only when needed) would cut it further but adds a branch for little gain.The Google settings selector skips its loop on store updates that leave visit times unchanged.
Risk
Level: Low
The riskiest part is the narrowed read changing which lines Send anyway records as skipped; the added test covers the one case where earlier events still matter. Nothing saved changes shape. Back out with a plain revert.