This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
Commit 1f5a644
refactor(plugin-dashboard): one auto-refresh timer for both dashboard surfaces, pinned by call counts (objectui#8820) (#10995)
Fixes #8820
Clause-②: no
## What changed
`DashboardGridLayout` and `DashboardRenderer` each carried their own
copy of the dashboard auto-refresh logic: a `refreshing` flag, a
`handleRefresh` callback used by both the "Refresh All" button and the
timer, and an effect that read `refreshIntervalSeconds` and drove
`setInterval`. Both surfaces now call one hook,
`useDashboardAutoRefresh` (new file
`packages/plugin-dashboard/src/useDashboardAutoRefresh.ts`), which is
that logic moved unchanged. The authored period is now read in one
place. The hook is internal: the package entry is not touched.
A new pin,
`packages/plugin-dashboard/src/__tests__/dashboardAutoRefreshTimer.test.tsx`,
mounts both components and counts `onRefresh` calls under fake timers.
## Base re-read, measured on `42687baf2` before any edit
- The two timers were identical in logic: the same `refreshing` state,
the same `handleRefresh` body (`setRefreshing(true)`, `onRefresh()`, a
600ms reset), the same early return (no timer when
`refreshIntervalSeconds` is falsy, is zero or less, or `onRefresh` is
missing), the same `setInterval(handleRefresh,
schema.refreshIntervalSeconds * 1000)`, and the same dependency list
`[schema.refreshIntervalSeconds, onRefresh, handleRefresh]`. They
differed only in comments and in `React.useX` versus named imports.
- Each read only `refreshIntervalSeconds`. The string `refreshInterval`
appears in both files only inside comments.
- The installed `@objectstack/spec` is 17.4.0, and its `DashboardSchema`
refuses `refreshInterval` by name (`safeParse` answers `invalid_type` on
that path, with the rename message). So the hook reads one key and has
no fallback.
## Why this is behaviour-neutral
- The gate, the seconds-to-milliseconds arithmetic and the dependency
list are copied as they were.
- The effect keeps the interval id in an effect-local constant instead
of `intervalRef`. The ref was read only by the cleanup of the effect
that wrote it, so the two forms clear the same interval in every
sequence.
- In `DashboardRenderer` the hook call sits where the old
`handleRefresh` and effect sat, so the refresh effect keeps its order
relative to the component's other effects. In `DashboardGridLayout` it
sits where that component's effect sat.
## Departures from the prior-art branch
(`claude/issue-8820-dashboard-refresh-interval-seconds`, `e5d95e1a4`)
That branch was not pushed to or rewritten; this is a new branch.
- **Dropped the both-spelling read**, as the card asks.
- **Dropped the number-only filter** (`resolveRefreshIntervalSeconds`,
which refused a string `'30'` and `NaN`). On base, the early return only
rejects a falsy or non-positive value, so it starts a 30s timer for a
string `'30'`, and refusing it would be a behaviour change beyond
de-duplication.
- **Did not carry** its edits to the published `inputs` row, the config
panel, or the i18n overlay: the card puts them out of scope, and
objectui#8783 has already moved them.
- **Reworked the pin** for a single spelling. The missing-handler case
now counts pending timers instead of only asserting that nothing throws.
New cases: a changed period re-arming (the card names it), a negative
period, the retired spelling, the phase across an equal-period
re-render, a handler swap, and the de-duplication case.
## The pin: 11 cases per surface, 22 in all
Each block is `describe.each` over both components, so a failure names
the surface.
1. fires every `refreshIntervalSeconds` seconds (30s period, 95s
elapsed: exactly 3 calls, none before the first period);
2. does not start when no period is authored;
3. and 4. does not start for a period of `0` or `-30`;
5. does not read the retired `refreshInterval` spelling;
6. arms no interval without an `onRefresh` host handler (pending
fake-timer count, with a control leg: the same period plus a handler
arms exactly one more timer than no period);
7. stops when the dashboard unmounts;
8. re-arms on a changed period: 30s becomes 60s at t=30s, there is no
second call by t=89s, and there is one at t=90s;
9. keeps its phase across a re-render that repeats the same period in a
new schema object;
10. calls the current `onRefresh` after the host swaps it, never the old
one;
11. takes its timer from the shared `useDashboardAutoRefresh` hook (the
de-duplication case: the real hook is wrapped in a `vi.fn` passthrough).
## Evidence
All test and type-check runs went through `os-verify-lock`. Each verdict
below is the one the tool printed. The base leg and the ablation ran at
`b98eb6164`. The last commit, `f990a9997`, changes only comments in the
hook and the pin plus one changeset sentence, and everything else below
was rerun on it.
- **Base leg** (the two components checked out at `42687baf2`, with the
new hook and pin present). Predicted before the run: only case 11 goes
red, on both surfaces. Observed: `Tests 2 failed | 20 passed (22)`. The
two failures are the case-11 pair, each reading `Number of calls: 0`.
The firing cases are green on base because base's two copies do fire;
firing is proven load-bearing by the ablation below. Restore was `git
checkout HEAD --` on absolute paths inside a trap. After it, the two
blobs were back to their HEAD hashes (`6b2cf9e46`, `bde5d0e96`), `git
diff HEAD` was empty and `git status --porcelain` was empty.
- **Reader ablation**, through `ablation-replace.mjs`. The anchor `const
seconds = schema.refreshIntervalSeconds;` became `const seconds =
undefined as number | undefined;`. On disk: anchor x1 to x0, replacement
x0 to x1, blob `dd029bbd0484` to `5e8e6e2ffff3`. Predicted before the
run: cases 1 and 6 to 10 go red on both surfaces (12), and cases 2 to 5
and 11 stay green (10). Case 6 goes red through its control leg.
Observed: `Tests 12 failed | 10 passed (22)`, exactly that set. Restore:
`blob == HEAD (dd029bb) and git diff HEAD is empty`, and the tree
was clean afterwards. No `dist/` is involved: the pin imports the
components and the hook by relative `src` paths.
- **`@object-ui/plugin-dashboard` suite plus the derived suites below,
in one run** at `f990a9997`: `Test Files 171 passed (171)`, `Tests 2123
passed | 6 skipped (2129)`. At `b98eb6164` the same two sets, run
separately, gave 150 files (1368 passed, 6 skipped) and 21 files (755
passed).
- **Type-check**: at `b98eb6164`, `turbo run type-check
--filter=@object-ui/plugin-dashboard` built the dependencies first and
gave `Tasks: 14 successful, 14 total`. At `f990a9997`, `pnpm --filter
@object-ui/plugin-dashboard type-check` (`tsc --noEmit && tsc -p
tsconfig.test.json`) exited 0. `tsc --listFilesOnly` shows both
`tsconfig.json` and `tsconfig.test.json` include the touched files.
- **Suites that read the touched files from disk or scan their corpus.**
The set is: the `scripts/__tests__` suites for `vi-mock-specifiers`,
`vi-mock-inherit`, `vi-mock-override-shape`, `markdown-test-inputs`,
`one-authority-per-exported-name-6273`, `new-cross-file-line-citations`,
`handler-key-read-sites`, `control-bytes`, `test-path-roots`,
`unreferenced-sources`, `type-check-coverage`,
`side-effects-declaration-consistency`, the six changeset suites and
`changeset-polarity-census`; plus
`packages/sdui-parser/src/__tests__/dashboard-widget-options-census.test.ts`
and
`examples/schema-catalog/test/plugin-dashboard-gallery-render.test.tsx`,
which read or render these two components.
- **Pin at `f990a9997`**: all 22 cases pass inside the run above.
- **Gates** at `f990a9997`, each exit 0 with an OK verdict:
`check-control-bytes`, `check:new-line-citations` (`0 new citation(s)`),
`check-vi-mock-specifiers`, `check-vi-mock-inherit`,
`check-vi-mock-override-shape`, `check-test-path-roots`,
`check-unreferenced-sources`, `check-type-check-coverage`,
`check:self-import`, `check-phantom-dependencies`,
`check:handler-key-reads`, `check-changeset-presence`,
`check-changeset-no-major`, `check-changeset-fixed`,
`check-changeset-claims`, `check-changeset-overwrite`,
`check-pending-changeset-literals`, and `check-governed-queue-guard
--test` (`NOT GOVERNED`).
- **eslint, narrowed**, at `f990a9997`, to the four touched TypeScript
files with `--no-inline-config`. The population is those four files;
`eslint --print-config` resolves a config for each. The count comes from
`--format json`: 4 files, 0 errors, 16 warnings. The same two components
at `42687baf2` give 8 + 8 warnings with the same rule counts, and the
two new files give none. `eslint.config.js` declares no `projectService`
or `parserOptions.project`, so linting is not type-aware and this diff
cannot move the verdict of any untouched file. The repo-wide `eslint .`
run belongs to CI.
## Acceptance notes
- 1 parent 8aa68b1 commit 1f5a644
5 files changed
Lines changed: 324 additions & 44 deletions
File tree
- .changeset
- packages/plugin-dashboard/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
131 | | - | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
193 | 179 | | |
194 | 180 | | |
195 | 181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
286 | 287 | | |
287 | 288 | | |
288 | 289 | | |
289 | | - | |
290 | 290 | | |
291 | | - | |
292 | 291 | | |
293 | 292 | | |
294 | 293 | | |
| |||
488 | 487 | | |
489 | 488 | | |
490 | 489 | | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
512 | 495 | | |
513 | 496 | | |
514 | 497 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
0 commit comments