Reload only the rows that changed
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:
+64
-62
@@ -328,73 +328,75 @@ 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 = [];
|
||||
// -- Change detection --------------------------------------------------
|
||||
//
|
||||
// Sections compose these into their own signature. Reloading rebuilds every
|
||||
// row and loses the scroll position, so a section redraws only when what it
|
||||
// actually shows has changed — run churn must not disturb someone reading
|
||||
// pull requests, and nothing at all should disturb an idle tree.
|
||||
|
||||
// The loading flag only reaches the screen while there is nothing else
|
||||
// to show; including it always would defeat the whole comparison.
|
||||
/** Whether there is anything to draw, and which repositories. */
|
||||
baseSignature() {
|
||||
const parts = [
|
||||
`error:${this.lastError || ""}`,
|
||||
`unmatched:${this.unmatchedHosts.map((entry) => entry.host).join(",")}`,
|
||||
`repos:${this.repos.map((repo) => `${repo.key}/${repo.branch || ""}`).join(",")}`,
|
||||
];
|
||||
// Only reaches the screen while there is nothing else to show.
|
||||
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("|");
|
||||
}
|
||||
|
||||
runsSignature(repoKey) {
|
||||
const entry = this.runsFor(repoKey);
|
||||
return [
|
||||
`runs:${entry.error || ""}/${entry.legacy}`,
|
||||
...entry.runs.map(
|
||||
(run) => `${run.id}/${run.status}/${run.conclusion}/${run.updated_at || ""}`,
|
||||
),
|
||||
].join(",");
|
||||
}
|
||||
|
||||
pullsSignature(repoKey) {
|
||||
const entry = this.pullRequestsFor(repoKey);
|
||||
return [
|
||||
`pulls:${entry.error || ""}`,
|
||||
...entry.items.map(
|
||||
(pull) => `${pull.number}/${pull.state}/${pull.draft}/${pull.updated_at}`,
|
||||
),
|
||||
].join(",");
|
||||
}
|
||||
|
||||
instancesSignature() {
|
||||
return [...this.instanceStatus.entries()]
|
||||
.map(([url, s]) => `${url}/${s.ok}/${s.version || ""}/${s.user || ""}/${s.error || ""}`)
|
||||
.join(",");
|
||||
}
|
||||
|
||||
settingsSignature(repoKey) {
|
||||
const secrets = this.secrets.get(repoKey);
|
||||
const variables = this.variables.get(repoKey);
|
||||
return [
|
||||
secrets ? `s:${secrets.error || ""}/${secrets.items.map((x) => x.name).join(",")}` : "s:-",
|
||||
variables
|
||||
? `v:${variables.error || ""}/${variables.items
|
||||
.map((x) => `${x.name}=${x.data || x.value || ""}`)
|
||||
.join(",")}`
|
||||
: "v:-",
|
||||
].join("|");
|
||||
}
|
||||
|
||||
/**
|
||||
* A coarse time bucket, present only while one of `runs` is in progress, so
|
||||
* a section showing a live elapsed clock keeps it moving — and a section
|
||||
* showing none of them stays perfectly still.
|
||||
*/
|
||||
elapsedTick(runs) {
|
||||
if (!runs.some(isActiveRun)) return "";
|
||||
const seconds = Math.max(5, config.runningInterval());
|
||||
return `tick:${Math.floor(Date.now() / 1000 / seconds)}`;
|
||||
}
|
||||
|
||||
// -- Housekeeping ------------------------------------------------------
|
||||
|
||||
_pruneCaches() {
|
||||
|
||||
Reference in New Issue
Block a user