Repository navigation
ui: refetch the sandbox, node and template lists every 10 seconds - #1263
Conversation
|
Thanks for opening this pull request! A SPACE maintainer will take a look. CONTRIBUTING.md explains how we review outside contributions. |
Withdrawing this approval for now. Any feedback above still stands.
Review — 2 findingsMedium
Low
What I checked: all three pages ( Verified against |
the-gigi-pplx
left a comment
There was a problem hiding this comment.
Approved. 2 non-blocking findings in the review comment above.
The background refresh of the sandbox, nodes and templates pages treated a view as stale after one second, so an open sandbox list refetched the full admin list (up to 1000 projected rows) roughly every two seconds, and the templates page its several admin reads at the same rate, per browser. The staleness window is now 10 seconds. Pages still refresh immediately after an action an operator takes on them, and the Refresh buttons are unchanged. A sandbox created from the list appears once its create operation has run, which the old two-second refresh used to pick up; the list now refreshes again when that operation completes.
…ost-create read The stale stamp lived in localStorage while every tab keeps its own rows, so one tab's refresh made the others skip theirs and show older data; with two visible tabs a list could go 20-30 seconds without refreshing at a 10 second window. The stamp is now per tab, so every visible tab refetches on its own window (hidden tabs still skip). The cross-tab lock stays, only to stop two tabs fetching at the same instant and a tab overlapping its own fetch. With snapshots checked, the create handler has already waited for the create operation, so the extra wait that refreshes the list on completion is only started when snapshots are not requested.
9577d11 to
80483db
Compare
|
Thanks, both fixed. 80483db keeps the freshness stamp per tab, so every visible tab refreshes on its own 10 s window (the cross-tab lock only stops two tabs fetching at the same instant), with a unit test for two tabs sharing one localStorage. With "snapshots" checked the list is read once. The risk line now says load grows with visible tabs. |
Summary
The sandbox, nodes and templates pages now refetch their data every 10 seconds instead of about every 2 seconds. Each tab tracks its own freshness, so every visible tab refetches on its own 10-second window and hidden tabs skip.
Their background refresh checks every second whether the view is stale, and it treated a view as stale after one second. An open sandbox list therefore refetched the full admin list (up to 1000 projected rows, the handler's busiest read) about every two seconds per browser. The templates page re-ran its several admin reads at the same rate. With the page idle for 25 seconds, the loop counted 13 list requests.
The staleness window is now 10 seconds, kept per tab: one tab's refresh no longer makes other tabs skip theirs, which would have left them showing older rows. The check itself still runs every second, which costs nothing. The cross-tab lock stays only so two tabs do not fetch at the same instant and one tab never overlaps its own fetch; a tab that loses it retries on its next check. Pages still refresh immediately after an action an operator takes on them, and the Refresh buttons are unchanged.
A sandbox created from the list is listed only once its create operation has run. The old two-second refresh used to pick it up, so the list now also refreshes when that operation completes. With "snapshots" checked, the create handler has already waited for that operation, so the list is read once and no second wait is started.
Stack
Independent of the other open console PRs. It edits the sandbox create handler next to #1249's change and the shared refresh constant that #1244 and #1252 rely on; whichever merges later may need a small rebase.
Validation
npm ci,npm test(95 pass),npx tsc --noEmitandnpm run buildinui/, on a head rebased onto currentmain. A new unit test covers two tabs sharing one localStorage.main(production build) and on this branch (the Kindspace-uiimage). An idle sandbox list, in one tab, made 13 list requests in 25 seconds onmain, and at most 4 here; these single-tab figures come from an earlier head of this branch, and two tabs were not measured in a browser.main.Severity and risk
Severity: medium. The old cadence is load on the API and Postgres that grows with every open console tab.
Risk: low. Load still grows with the number of visible tabs: each visible tab makes one list read per 10-second window, where it made one about every 2 seconds. Hidden tabs make none. A change made outside the console, for example by an API client or the reconciler, now appears up to 10 seconds later instead of 2. Roll back by reverting the commits.
AI assistance: Claude Code wrote the code and this description, and ran the validation; a maintainer reviews it.