Reload only the rows that changed
CI / Tests (push) Successful in 11s
CI / Generated images (push) Successful in 41s

Refreshing rebuilt the whole tree, and TreeView.reload() with no
argument drops the scroll position. Watching a job meant the view jumped
every fifteen seconds.

The provider now reconciles instead of replacing. update() rebuilds from
the store, matches rows to the existing nodes by identifier, copies the
rendered fields onto them, and reports the topmost rows that actually
changed; main.js reloads just those. Node identity survives the merge,
which is what makes a targeted reload possible. An open row that fetches
its own children has that cache dropped so it refetches — the running-job
path. A job finishing now reloads one run's row and nothing else.

Sections also each describe what they draw, so a section only rebuilds
when its own content moved: run activity no longer disturbs the pull
request list, and an idle tree is left alone entirely. This does not slow
anything down — a section showing a run in progress still updates on
every poll, and contributes a time bucket so its elapsed clock keeps
moving.

A row set changing at the root still needs a whole-tree reload; there the
selected row is re-revealed afterwards, which is the closest thing to a
scroll anchor Nova exposes.

Adds seventeen checks: no-op updates reporting nothing, a finishing job
naming only its own row, node identity surviving, a new run reloading
just its workflow group, and a new workflow escalating to a full reload.
168 checks total.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MQuusXgZC2dzwpJJ1qhtti
This commit is contained in:
2026-08-28 20:30:17 -03:00
co-authored by Claude Opus 5
parent 4bc81b59e7
commit cf97f0dc2a
11 changed files with 496 additions and 97 deletions
+32 -6
View File
@@ -70,12 +70,8 @@ Controllers mutate through it. It owns:
- `repos`, `unmatchedHosts`, `instanceStatus`
- per-run `jobs`/`artifacts`, per-PR `pullRequestDetail`, `secrets`, `variables`
- `onDidChange``main.js` debounces 150ms, compares `store.signature()`, and
reloads only when it changed. An idle poll therefore leaves the tree, its
scroll position, and its open rows completely alone. Anything that changes
what is drawn has to appear in that signature — the branch filter is in there
for exactly that reason, and a live run contributes a coarse time bucket so
its elapsed clock keeps moving.
- `onDidChange``main.js` debounces 150ms, then asks each section whether it
needs anything (see **Redrawing** below)
- adaptive polling: `runningInterval` when anything is queued or running, else
`idleInterval`. `refresh()` coalesces — a second call while one is in flight
returns the same promise rather than stacking.
@@ -94,6 +90,36 @@ identifier is seen, so a default-open section can still be closed and stay
closed. **Node identifiers must therefore be stable across rebuilds** — never
derive one from a counter or from anything that changes between refreshes.
## Redrawing
Nova has no API to read or set a tree's scroll offset, and `TreeView.reload()`
with no argument rebuilds every row and drops the scroll position. Polling every
15 seconds while a job runs therefore cannot go through a full reload. Three
things keep the view still, in order of how often they fire:
1. **Per-section signatures.** Each provider implements `signature()` describing
only what it draws. `main.js` compares it and skips the section entirely when
unchanged, so run activity never disturbs the Pull Requests section and an
idle tree is never touched. Anything that changes the drawing must be in
there — the branch filter is, because it changes the tree without changing
any data. A section showing a run in progress adds a coarse time bucket
(`store.elapsedTick`) so its elapsed clock keeps moving.
2. **`provider.update()` reconciles in place.** It rebuilds from the store and
merges the result onto the node objects Nova already holds, matching rows by
identifier and copying the rendered fields across. Node identity survives,
which is what makes a targeted reload possible at all.
3. **Targeted `view.reload(node)`.** `update()` returns the topmost rows that
actually changed, and only those are reloaded. Watching a running job
reloads that one run's row, nothing else.
`update()` returns `{ full: true }` when a row set changed at the root and the
merge cannot patch it; only then does a whole-tree reload happen, and
`fullReload` re-reveals the selected row afterwards as the nearest thing to a
scroll anchor Nova offers.
An open row whose children are lazily loaded has its `children` cache dropped by
the merge, so the reload refetches — that is the running-job path. Keep that.
**`controllers/selection.js`** — a command can arrive from a sidebar (Nova
passes the `TreeView`), from a node directly, or from a menu with no argument at
all. `selectedNode()` normalises all three; `resolveRepo()` falls back to the