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
+67
View File
@@ -328,6 +328,73 @@ class Store {
this.notify();
}
/**
* Fingerprint of everything the sidebar draws. `main.js` compares it before
* reloading, so an idle poll that changes nothing leaves the tree — and the
* user's scroll position and open rows — completely alone.
*/
signature() {
const parts = [];
// The loading flag only reaches the screen while there is nothing else
// to show; including it always would defeat the whole comparison.
if (!this.repos.length) parts.push(`loading:${this.loading}`);
parts.push(`error:${this.lastError || ""}`);
for (const entry of this.unmatchedHosts) parts.push(`unmatched:${entry.host}`);
// The branch filter changes what is drawn without changing any data.
const filter = config.branchFilter();
parts.push(`filter:${filter.mode}:${filter.branch || ""}`);
for (const [baseUrl, status] of this.instanceStatus) {
parts.push(
`instance:${baseUrl}:${status.ok}:${status.version || ""}:${status.user || ""}:${status.error || ""}`,
);
}
for (const repo of this.repos) {
parts.push(`repo:${repo.key}:${repo.branch || ""}`);
const runs = this.runsFor(repo.key);
parts.push(`runs:${runs.error || ""}:${runs.legacy}`);
for (const run of runs.runs) {
parts.push(`run:${run.id}:${run.status}:${run.conclusion}:${run.updated_at || ""}`);
}
const pulls = this.pullRequestsFor(repo.key);
parts.push(`pulls:${pulls.error || ""}`);
for (const pull of pulls.items) {
parts.push(`pull:${pull.number}:${pull.state}:${pull.draft}:${pull.updated_at}`);
}
const secrets = this.secrets.get(repo.key);
if (secrets) {
parts.push(
`secrets:${secrets.error || ""}:${secrets.items.map((x) => x.name).join(",")}`,
);
}
const variables = this.variables.get(repo.key);
if (variables) {
parts.push(
`variables:${variables.error || ""}:${variables.items
.map((x) => `${x.name}=${x.data || x.value || ""}`)
.join(",")}`,
);
}
}
// While something is running its elapsed time is on screen and has to
// keep moving, so let the signature change once per active interval.
if (this.hasActiveRuns) {
const seconds = Math.max(5, config.runningInterval());
parts.push(`tick:${Math.floor(Date.now() / 1000 / seconds)}`);
}
return parts.join("|");
}
// -- Housekeeping ------------------------------------------------------
_pruneCaches() {