Keep the sidebar's open rows across refreshes
CI / Tests (push) Successful in 1m34s
CI / Generated images (push) Successful in 2m0s

Expanding a workflow run and waiting through one poll closed it again.

Two causes. Nova applies whatever collapsible state getTreeItem returns,
and it returned Collapsed for every row that was not built default-open,
so each reload closed everything the user had opened. On top of that, a
reload fired on every poll whether or not anything had changed, so an
idle tree was rebuilt every 15 to 60 seconds for no reason.

The provider now tracks expansion by node identifier, fed from the tree
view's expand and collapse events. A node built default-open seeds that
set the first time its identifier is seen, so such a section can still be
closed by hand and stay closed.

Node identifiers consequently have to be stable across rebuilds. The
fallback for nodes without an explicit one was a counter, which changed
on every build; it is now derived from the node's kind and name. Step
rows were keyed by step number alone, which collided between jobs, and
are now qualified by the job.

Reloads are also skipped entirely when store.signature() is unchanged.
The signature covers everything drawn, including the branch filter, which
changes the tree without changing any data. A live run contributes a
coarse time bucket so its elapsed clock still ticks, and the explicit
Refresh command always redraws.

Adds twelve checks covering expansion surviving a rebuild, a default-open
section staying closed once closed, and the signature responding to run
state and the branch filter but not to a no-op poll. 143 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:21:19 -03:00
co-authored by Claude Opus 5
parent 87851de921
commit 4bc81b59e7
9 changed files with 267 additions and 19 deletions
+15 -2
View File
@@ -70,8 +70,12 @@ Controllers mutate through it. It owns:
- `repos`, `unmatchedHosts`, `instanceStatus`
- per-run `jobs`/`artifacts`, per-PR `pullRequestDetail`, `secrets`, `variables`
- `onDidChange``main.js` debounces 150ms → every provider's `invalidate()` +
`reload()`
- `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.
- 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.
@@ -81,6 +85,15 @@ only `roots()`. Nodes are plain objects (`views/nodes.js` `node()`), turned into
`TreeItem`s centrally. A node with `load` fetches when expanded; the result is
cached onto `element.children`.
It also owns **expansion state**, which is not optional bookkeeping. Nova
applies whatever `collapsibleState` `getTreeItem` returns, so a reload closes
every row the provider does not report as open. `main.js` feeds
`onDidExpandElement`/`onDidCollapseElement` into `setExpanded`, keyed by node
identifier. A node built with `expanded: true` seeds that set the first time its
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.
**`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