Skip to content

Conversation

@spboyer
Copy link

@spboyer spboyer commented Dec 18, 2025

Description

This PR fixes issue #229 where newly triggered workflow runs required manual refresh to see updates in the UI. The extension now automatically polls for workflow run updates and reflects changes in real-time.

Changes

Enhanced Polling Mechanism

  • Added checks for window focus and view visibility before polling to prevent unnecessary API calls
  • Enhanced logging to show run status and conclusion during polling attempts
  • Improved cleanup of polling intervals when runs complete or polling attempts are exhausted

Key Improvements

  1. Respects window focus and view visibility, optimizing API usage
  2. Workflow runs now update automatically without requiring manual refresh
  3. Proper cleanup prevents memory leaks and unnecessary API calls

Related Issues

Fixes #229

Testing

The fix ensures that:

  • When a new workflow is triggered, it automatically appears and updates in the extension view
  • Re-running workflows shows progress updates in real-time
  • Polling stops when runs complete
  • API calls are minimized when the window is not focused or the view is not visible

Copilot AI review requested due to automatic review settings December 18, 2025 20:54
@spboyer spboyer requested a review from a team as a code owner December 18, 2025 20:54
@spboyer spboyer requested review from cschleiden and thyeggman and removed request for Copilot December 18, 2025 20:54
@spboyer
Copy link
Author

spboyer commented Dec 18, 2025

Related #285

Copilot AI review requested due to automatic review settings December 19, 2025 15:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements an automatic polling mechanism to update workflow runs in real-time without requiring manual refresh, addressing issue #229. The solution adds intelligent polling that respects window focus and view visibility to minimize unnecessary API calls.

Key changes include:

  • Automatic polling for active workflow runs (in_progress, queued, waiting, requested) with a 4-second interval for up to 15 minutes
  • Window focus and view visibility tracking to pause polling when the extension is not in use
  • Enhanced workflow trigger command that waits for new runs to appear and automatically starts polling them

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/treeViews/workflows.ts Exports WorkflowsTreeNode type to enable access from other modules
src/treeViews/workflowRunTreeDataProvider.ts Adds automatic polling initiation for active workflow runs when tree nodes are created
src/treeViews/treeViews.ts Tracks workflow tree view visibility state and notifies the store
src/store/workflowRun.ts Unconditionally clears job cache on run updates to ensure polling fetches latest job status
src/store/store.ts Implements polling mechanism with focus/visibility checks and cleanup logic for completed runs
src/extension.ts Registers window state change handler to track focus state
src/commands/triggerWorkflowRun.ts Enhanced to detect newly triggered runs and automatically start polling them

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +81 to 87
if (!this._isFocused || !this._isViewVisible) {
return;
}

log(`Fetching run update: ${updater.runId}. Remaining attempts: ${updater.remainingAttempts}`);

updater.remainingAttempts--;
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fetchRun method skips the API call when the window is not focused or view is not visible, but it still decrements remainingAttempts (line 87). This means if the window is unfocused for a long time, the remaining attempts could be exhausted without making any API calls. When the user returns to the window, polling may have already stopped. Consider only decrementing remainingAttempts when an API call is actually made.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Comment on lines +28 to +36
// Auto-poll active runs
if (
workflowRun.run.status === "in_progress" ||
workflowRun.run.status === "queued" ||
workflowRun.run.status === "waiting" ||
workflowRun.run.status === "requested"
) {
// Poll every 4 seconds for up to 15 minutes (225 attempts)
this.store.pollRun(workflowRun.run.id, gitHubRepoContext, 4000, 225);
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pollRun method in workflowRunTreeDataProvider is called every time runNodes is invoked, which could be during tree refreshes. This means that active runs that are already being polled will have their polling restarted with full attempts (225), potentially creating multiple polling intervals for the same run. The store's pollRun does clear the existing interval before creating a new one, but this restart behavior may not be desired. Consider checking if polling is already active for a run before starting new polling.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Comment on lines +35 to +36
// Poll every 4 seconds for up to 15 minutes (225 attempts)
this.store.pollRun(workflowRun.run.id, gitHubRepoContext, 4000, 225);
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic numbers 4000 and 225 are used directly without explanation. While there is a comment stating "Poll every 4 seconds for up to 15 minutes", having these values as named constants would improve maintainability and make it easier to adjust the polling strategy across the codebase. Consider defining constants like POLL_INTERVAL_MS and MAX_POLL_ATTEMPTS.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Comment on lines +54 to +56
const relativeWorkflowPath = vscode.workspace.asRelativePath(workflowUri, false);
if (!workflowIdForApi) {
workflowIdForApi = basename(workflowUri.fsPath);
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflowIdForApi is set twice when args is a vscode.Uri - once at line 27 and again at line 56. The second assignment is redundant since the condition "!workflowIdForApi" will never be true when args is a Uri. Consider restructuring this logic to avoid the unnecessary check and assignment.

Copilot uses AI. Check for mistakes.
);
}

return vscode.commands.executeCommand("github-actions.explorer.refresh");
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the loop completes (either by finding the new run or exhausting 20 attempts), the code always calls the refresh command at line 207. However, if a new run was found and already triggered a refresh at line 194, this results in a redundant refresh. Consider skipping the final refresh if the new run was already detected and refreshed.

Copilot uses AI. Check for mistakes.
spboyer and others added 2 commits December 19, 2025 10:51
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When running a new workflow, you have to manually click refresh and there are not automatic updates.

1 participant