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
59 lines
2.0 KiB
JavaScript
59 lines
2.0 KiB
JavaScript
//
|
|
// "Pull Requests" section: open pull requests across every discovered
|
|
// repository, each expanding into its reviews, comments, and changed files.
|
|
//
|
|
|
|
const builders = require("./builders.js");
|
|
const nodes = require("./nodes.js");
|
|
const { NodeProvider } = require("./provider.js");
|
|
|
|
const { node, message, errorNode } = nodes;
|
|
|
|
class PullRequestsProvider extends NodeProvider {
|
|
// No elapsed clock here, so this section never redraws on run activity.
|
|
signature() {
|
|
const store = this.store;
|
|
return [
|
|
store.baseSignature(),
|
|
...store.repos.map((repo) => store.pullsSignature(repo.key)),
|
|
].join("|");
|
|
}
|
|
|
|
roots() {
|
|
const store = this.store;
|
|
|
|
if (!store.hasAnyToken) {
|
|
return [message("No token stored. Run “Gitea → Set Token…” to sign in.")];
|
|
}
|
|
if (!store.repos.length) {
|
|
if (store.unmatchedHosts.length) return builders.unmatchedHostNodes(store);
|
|
return [message(store.loading ? "Loading…" : "No Gitea repositories found.")];
|
|
}
|
|
|
|
const sections = store.repos.map((repo) => this.repoSection(repo));
|
|
return store.repos.length === 1 ? sections[0].children : sections;
|
|
}
|
|
|
|
repoSection(repo) {
|
|
const { items, error } = this.store.pullRequestsFor(repo.key);
|
|
|
|
let children;
|
|
if (error) children = [errorNode(error)];
|
|
else if (!items.length) children = [message("No open pull requests.")];
|
|
else children = items.map((pull) => builders.pullRequestNode(this.store, repo, pull));
|
|
|
|
return node("repo", repo.fullName, {
|
|
identifier: `pr-repo-${repo.key}`,
|
|
description: items.length ? String(items.length) : "",
|
|
tooltip: repo.htmlUrl,
|
|
contextValue: "repo",
|
|
repo: repo,
|
|
data: { repoKey: repo.key },
|
|
expanded: true,
|
|
children: children,
|
|
});
|
|
}
|
|
}
|
|
|
|
exports.PullRequestsProvider = PullRequestsProvider;
|