Skip to content

Web app: read again on the server's change hints instead of polling - #2665

Merged
davidmckayv merged 9 commits into
mainfrom
waste/web-push
Dec 2, 2026
Merged

davidmckayv merged 9 commits into
mainfrom
waste/web-push

Conversation

@davidmckayv

@davidmckayv davidmckayv commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

The web app stops polling and reads again on the server's change hints (the conversation events socket's dataChanged). Builds on #2652 (merged: four new hint kinds, deployment.dataChanged, the components list's view and ETag).

Why. One signed-in person with one conversation open made about 120 requests a minute while doing nothing, all day in OpenBot Desktop, and several polls read lists that only grow (run history, tasks) to their last page, so load grew with the account's age.

What changes

  • Hints. The socket asks for data-changed. Each hint marks stale the reads of its kind (lib/live/apply-hints.ts); a hint about one Bot reaches only that Bot's per-Bot reads, and one about another organization is dropped. A hint-fed read keeps its answer for five minutes and has no timer while the server says it sends that kind (deployment.dataChanged). A server that doesn't say gets a slow fallback poll (60 s), paused while the page is hidden. A reopened socket or a resync marks every hint-fed read stale.
  • Approvals. The inbox's seven lists become three reads: the live queue (approvals and questions, hint-fed), the settings (preferences, rules, organization settings: read once, refreshed by their own writes) and the conversation grants (hint-fed). Each approval card mount no longer refetches anything. Carry-on after a decision comes from the hint-fed queue (the server announces the decision and the end), with a timer for its ten-minute limit, instead of a 2 s/10 s poll.
    • The conversation's work field does not say an approval carry-on is going: the server lists only a turn on its own carried-turn queue, which an approval's carry-on joins only when it is handed on (channels/working.ts, turns/carry.ts afterApproval). So carry-on is read from the approval queue as the hints keep it, which costs no requests.
  • Computer control. Every view of a computer shares one read of its wheel, and it runs on the computers hint (a take-over, a hand-back, a secret asked for, the computer starting or sleeping), not every second. A read that fails is tried again each second until it answers. A server that doesn't send the hint keeps the old 1 s read. (Reading it only while the sheet is open broke the take-over card and the password prompt opening the Computer by itself; with the hint, nothing runs on a timer anyway.)
  • Run histories. A routine's and a goal's runs are read a page of 20 at a time with Show more, never to the end, and again on the routines hint.
  • Everything else polled on a timer is hint-fed: routines and goals, memory and its sources, check-ins and their items, deliveries, devices and destinations, shared-use and app access requests (the admin's watcher still polls out of sight only where the server sends no grants hint), a Bot's activity and attention, and a Bot's components. The components lists ask for view=summary (the screens) or view=published (a conversation), and the app asks again with the ETag it holds (If-None-Match, lib/api/revalidated.ts), so an unchanged page is a 304. A reopened socket re-reads every hint-fed list except a Bot's grants, which every tab re-reading at once after a deploy is what slowed Cloud on 2026-11-30.
  • Tasks. Waiting on the person no longer counts as moving, so a task that needs input doesn't keep the list on a 3 s poll. The list is read on the needsYou hint.
  • Group chats poll only while a turn is owed an answer and for at most ten minutes from when it began, instead of for as long as a reply said it was running.

Tests

  • data-changed-hints.test.tsx: through the real socket hook, factories and screen, with a month of runs (8,640): one page read, no timers, a hint about another organization or another kind reads nothing, the routines hint brings a new run onto the screen, Show more reads one more page, and a server without hints only polls at 60 s or slower. Forty approval cards drawn one after another read the queue once and never the settings. Red when the hint isn't applied.
  • waiting-is-not-moving.test.ts: 300 tasks with a hundred waiting on the person poll nothing; a group reply past its deadline isn't polled.
  • computer-control-store.test.tsx: the wheel is read on its own hint and not every second.
  • components-etag.test.ts: 60 published components with large sources; read again unchanged, each page is asked with its ETag and answered 304; published again, read whole.
  • Existing tests moved to the new keys.

The idle-tab request budget on an aged account is pinned in an end-to-end journey in the server's suite, which needs this and the server's side of the hints.

Screens changed: a routine's page and a goal's page (Runs: Show more), the routine row's run history.

Changelog

The web app.

  • Changed: an idle tab no longer polls. An open conversation, the approvals inbox, routines, goals, tasks, memory, components and the rest are read again when OpenBot says they changed, so an idle tab asks OpenBot almost nothing and stays current. A routine's or goal's runs show the newest 20, with Show more for older ones.

The server already says on the conversation events socket when something the person sees outside
their conversations changed (dataChanged), but the app never asked for it and polled instead:
about 120 requests a minute from one idle conversation tab, all day in OpenBot Desktop, with
several polls reading lists that only grow to their last page.

- The socket asks for data-changed, and each hint marks stale the reads of its kind
  (lib/live/apply-hints.ts); one about one Bot reaches only that Bot's reads. Hint-fed reads keep
  their answer for five minutes and poll only for a kind the server does not say it sends
  (deployment.dataChanged), slowly (60 s) and never while the page is hidden. A reopened socket or
  a resync marks every hint-fed read stale.
- Approvals: the inbox's seven lists become the live queue (approvals and questions, hint-fed),
  the settings (preferences, rules, organization settings: read once, refreshed by their writes)
  and the conversation grants. Carry-on after a decision is read from the hint-fed queue, with a
  timer for its ten-minute limit, instead of a 2 s/10 s poll. An approval card no longer reads
  seven lists on mount.
- Computer control: read on the computers hint, not every second, and the conversation reads it
  only while the Computer is open as a sheet over it. A server without the hint keeps the old
  1 s read while someone watches.
- Run histories (a routine's, a goal's) read their newest page of 20, with Show more for older
  runs, instead of every page every 5 or 10 seconds.
- Routines, goals, memory, check-ins, deliveries, shared-use and app access requests, a Bot's
  activity and attention, and a Bot's components are hint-fed. Components lists ask for
  view=summary or view=published, and the browser revalidates them by ETag.
- Tasks: waiting on the person no longer counts as moving, so a task that needs input does not
  keep the list on a 3 s poll. Group chats poll only while a reply streams, up to ten minutes.
… only where shown, components asked with their ETag, grants left out of a reconnect's re-read
…h runs only on the server's hint where the server sends one
@davidmckayv
davidmckayv removed this pull request from the merge queue due to a manual request Dec 2, 2026
@davidmckayv
davidmckayv added this pull request to the merge queue Dec 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Dec 2, 2026
…he spread-out read

Main now waits a random 0 to 2 s before a reconnected or resynced socket reads its lists again (#2668). The hint-fed reads join that read instead of going out the moment the socket opens, so a deploy that drops every tab doesn't bring their hint-fed reads back together. The first opening reads only the lists, as before.
@davidmckayv
davidmckayv enabled auto-merge December 2, 2026 03:31
@davidmckayv

Copy link
Copy Markdown
Contributor Author

Merged main in (merge commit, no rebase) after #2668, #2646, #2661 and #2664. Two files conflicted.

app/src/lib/channels/use-channel-events.ts, where #2668 and this PR overlap. Both changed what the socket reads after a reconnect or a resync:

Kept both, in one read. readAgain (the jittered recovery read) now marks every hint-fed read stale and then reads the lists. The first opening calls readLists alone, as both PRs had it. So the hint-fed reads go out inside the spread, not the moment 200 sockets reopen together after a deploy, which is #2668's point and the Cloud slowdown this PR cites. grants stay out of the re-read as before. This PR's separate openedBefore flag is gone; #2668's wasOpen does the same job.

New test in conversation-socket-reconnect.test.tsx: after a reconnect, and after a resync, no hint-fed read goes out the moment the socket opens, one goes out within the spread, and it covers every kind but grants. It is red when the hint-fed read fires on open (this PR's old behaviour) and green now.

app/src/lib/approvals.ts. Import conflict only: this PR's hinted and #2668's taskKeys (used by its narrowed question dismissal). Kept both. #2668's dismissal invalidates approvalKeys.all through settle, which still covers this PR's three approval reads.

Also checked: channel-chat.tsx merged clean (#2668's one-read-per-announced-reply and this PR's group-chat polling don't touch the same lines). CHANGELOG.md is unchanged from main.

Local: app typecheck, biome lint and format, and the 33 app test files this PR and #2668 touch (381 pass). Real-browser routine page, needs-you board and section strip pass in Chromium and WebKit. approval-answered-layout.test.tsx fails 8 of 8 in both engines, and it fails the same way on main and on this PR's old head, so the merge didn't cause it.

# Conflicts:
#	app/src/components/routines/routine-page.tsx
#	app/src/lib/channels/use-channel-events.ts
#	app/src/lib/computers/use-control.ts
# Conflicts:
#	app/src/components/channels/channel-chat.tsx
@davidmckayv
davidmckayv added this pull request to the merge queue Dec 2, 2026
@davidmckayv
davidmckayv removed this pull request from the merge queue due to a manual request Dec 2, 2026
# Conflicts:
#	app/src/components/approvals/settings.tsx
@davidmckayv
davidmckayv added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit bcf44a6 Dec 2, 2026
67 of 70 checks passed
@davidmckayv
davidmckayv deleted the waste/web-push branch December 2, 2026 08:55
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