Skip to content

Commit 8011fcd

Browse files
committed
Fixed auto-poll timer, tidied labels
1 parent 8d91ea9 commit 8011fcd

6 files changed

Lines changed: 307 additions & 127 deletions

File tree

CLAUDE.md

Lines changed: 0 additions & 109 deletions
This file was deleted.

package.json

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,30 @@
8181
"default": 30,
8282
"scope": "window"
8383
},
84+
"github-actions.combined-workflows.auto-refresh.enabled": {
85+
"type": "boolean",
86+
"description": "Auto-refresh combined workflows view. Note: this uses polling and counts against your GitHub API rate limit",
87+
"default": false,
88+
"scope": "window"
89+
},
90+
"github-actions.combined-workflows.auto-refresh.interval": {
91+
"type": "number",
92+
"description": "Time to wait between calls to update combined workflows in seconds",
93+
"default": 60,
94+
"scope": "window"
95+
},
96+
"github-actions.combined-workflows.auto-refresh.duration": {
97+
"type": "number",
98+
"description": "Duration in minutes to continue auto-refreshing after a git push before stopping automatically",
99+
"default": 15,
100+
"scope": "window"
101+
},
102+
"github-actions.combined-workflows.auto-refresh.on-push-only": {
103+
"type": "boolean",
104+
"description": "Only enable auto-refresh after detecting a git push. If false, auto-refresh starts when the extension loads",
105+
"default": true,
106+
"scope": "window"
107+
},
84108
"github-actions.remote-name": {
85109
"type": "string",
86110
"description": "The name of the repository's git remote that points to GitHub",
@@ -114,6 +138,23 @@
114138
"light": "resources/icons/light/refresh.svg"
115139
}
116140
},
141+
{
142+
"command": "github-actions.combined-workflows.toggle-auto-refresh",
143+
"category": "GitHub Actions",
144+
"title": "Toggle Auto-Refresh"
145+
},
146+
{
147+
"command": "github-actions.combined-workflows.toggle-auto-refresh-on",
148+
"category": "GitHub Actions",
149+
"title": "Auto-Refresh: ON",
150+
"icon": "$(sync~spin)"
151+
},
152+
{
153+
"command": "github-actions.combined-workflows.toggle-auto-refresh-off",
154+
"category": "GitHub Actions",
155+
"title": "Auto-Refresh: OFF",
156+
"icon": "$(sync-ignored)"
157+
},
117158
{
118159
"command": "github-actions.explorer.openRun",
119160
"category": "GitHub Actions",
@@ -278,7 +319,7 @@
278319
},
279320
{
280321
"id": "github-actions.combined-workflows",
281-
"name": "Combined Workflows",
322+
"name": "Chrono",
282323
"when": "github-actions.internet-access && github-actions.signed-in && github-actions.has-repos"
283324
},
284325
{
@@ -330,6 +371,16 @@
330371
"command": "github-actions.explorer.current-branch.refresh",
331372
"group": "navigation",
332373
"when": "view == github-actions.current-branch"
374+
},
375+
{
376+
"command": "github-actions.combined-workflows.toggle-auto-refresh-on",
377+
"group": "navigation",
378+
"when": "view == github-actions.combined-workflows && github-actions.combined-workflows.auto-refresh-active"
379+
},
380+
{
381+
"command": "github-actions.combined-workflows.toggle-auto-refresh-off",
382+
"group": "navigation",
383+
"when": "view == github-actions.combined-workflows && !github-actions.combined-workflows.auto-refresh-active"
333384
}
334385
],
335386
"editor/title": [

src/git/repository.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface GitHubUrls {
1616
protocol: Protocol;
1717
}
1818

19-
async function getGitExtension(): Promise<API | undefined> {
19+
export async function getGitExtension(): Promise<API | undefined> {
2020
const gitExtension = vscode.extensions.getExtension<GitExtension>("vscode.git");
2121
if (gitExtension) {
2222
if (!gitExtension.isActive) {
@@ -25,7 +25,6 @@ async function getGitExtension(): Promise<API | undefined> {
2525
const git = gitExtension.exports.getAPI(1);
2626

2727
if (git.state !== "initialized") {
28-
// Wait for the plugin to be initialized
2928
await new Promise<void>(resolve => {
3029
if (git.state === "initialized") {
3130
resolve();

src/treeViews/combinedWorkflows.ts

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import * as vscode from "vscode";
22

33
import {canReachGitHubAPI} from "../api/canReachGitHubAPI";
44
import {getGitHubContext} from "../git/repository";
5-
import {logDebug, logError} from "../log";
5+
import {logError} from "../log";
66
import {RunStore} from "../store/store";
7+
import {AutoRefreshManager} from "./combinedWorkflows/autoRefreshManager";
78
import {CombinedWorkflowRunNode} from "./combinedWorkflows/combinedWorkflowRunNode";
89
import {AttemptNode} from "./shared/attemptNode";
910
import {AuthenticationNode} from "./shared/authenticationNode";
@@ -30,9 +31,33 @@ export class CombinedWorkflowsTreeProvider
3031
{
3132
private _onDidChangeTreeData = new vscode.EventEmitter<CombinedWorkflowsTreeNode | null>();
3233
readonly onDidChangeTreeData = this._onDidChangeTreeData.event;
34+
private autoRefreshManager: AutoRefreshManager;
35+
private treeView?: vscode.TreeView<CombinedWorkflowsTreeNode>;
3336

3437
constructor(store: RunStore) {
3538
super(store);
39+
this.autoRefreshManager = new AutoRefreshManager(
40+
() => this.refresh(),
41+
(description: string) => this.updateViewDescription(description)
42+
);
43+
}
44+
45+
setTreeView(treeView: vscode.TreeView<CombinedWorkflowsTreeNode>): void {
46+
this.treeView = treeView;
47+
this.updateViewDescription(this.autoRefreshManager.getDescription());
48+
this.updateAutoRefreshContext();
49+
}
50+
51+
private updateViewDescription(description: string): void {
52+
if (this.treeView) {
53+
this.treeView.description = description;
54+
}
55+
this.updateAutoRefreshContext();
56+
}
57+
58+
private updateAutoRefreshContext(): void {
59+
const isActive = this.autoRefreshManager.isActive();
60+
void vscode.commands.executeCommand("setContext", "github-actions.combined-workflows.auto-refresh-active", isActive);
3661
}
3762

3863
protected _updateNode(node: WorkflowRunNode): void {
@@ -47,18 +72,31 @@ export class CombinedWorkflowsTreeProvider
4772
}
4873
}
4974

75+
setVisible(visible: boolean): void {
76+
this.autoRefreshManager.setVisible(visible);
77+
}
78+
79+
onPush(): void {
80+
this.autoRefreshManager.onPush();
81+
}
82+
83+
getAutoRefreshManager(): AutoRefreshManager {
84+
return this.autoRefreshManager;
85+
}
86+
87+
dispose(): void {
88+
this.autoRefreshManager.dispose();
89+
}
90+
5091
getTreeItem(element: CombinedWorkflowsTreeNode): vscode.TreeItem | Thenable<vscode.TreeItem> {
5192
return element;
5293
}
5394

5495
async getChildren(element?: CombinedWorkflowsTreeNode | undefined): Promise<CombinedWorkflowsTreeNode[]> {
5596
if (!element) {
56-
logDebug("Getting combined workflow runs from all repos");
57-
5897
try {
5998
const gitHubContext = await getGitHubContext();
6099
if (!gitHubContext) {
61-
logDebug("could not get github context for combined workflows");
62100
return [new GitHubAPIUnreachableNode()];
63101
}
64102

@@ -101,7 +139,7 @@ export class CombinedWorkflowsTreeProvider
101139

102140
return allRuns;
103141
} catch (e) {
104-
logError(e as Error, "Failed to get GitHub context");
142+
logError(e as Error, (e as Error).message);
105143

106144
if ((e as Error).message.startsWith("Could not get token from the GitHub authentication provider.")) {
107145
return [new AuthenticationNode()];

0 commit comments

Comments
 (0)