-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
feat(actions): implement adaptive auto-refresh for workflow runs list #38329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
SudhanshuMatrix
wants to merge
9
commits into
go-gitea:main
Choose a base branch
from
SudhanshuMatrix:feat/actions-auto-refresh
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+390
−98
Draft
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
25cabd1
feat(actions): implement adaptive auto-refresh for workflow runs list
SudhanshuMatrix 9de3277
fix
wxiaoguang 97862a4
fix
wxiaoguang edc593b
fix
wxiaoguang bf02fee
fix
wxiaoguang 809d8b6
fix
wxiaoguang b3b646b
fine tune
wxiaoguang f488720
fix(actions): combine active page timer with idiomorph morphing to pr…
SudhanshuMatrix a515772
fix(actions): remove unused parameter curWorkflowID to resolve golang…
SudhanshuMatrix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| import {createApp} from 'vue'; | ||
| import {Idiomorph} from 'idiomorph'; | ||
| import RepoActionView from '../components/RepoActionView.vue'; | ||
| import {registerGlobalInitFunc} from '../modules/observer.ts'; | ||
| import {html} from '../utils/html.ts'; | ||
| import {GET} from '../modules/fetch.ts'; | ||
|
|
||
| export function updateWorkflowBadgeFields(form: HTMLElement, branch: string): void { | ||
| const badgeURLParsed = new URL(form.getAttribute('data-badge-url')!); | ||
|
|
@@ -27,6 +29,7 @@ function initWorkflowBadgeForm(form: HTMLElement): void { | |
| export function initRepositoryActions() { | ||
| registerGlobalInitFunc('initWorkflowBadgeForm', initWorkflowBadgeForm); | ||
| initRepositoryActionsView(); | ||
| initRepositoryActionsList(); | ||
| } | ||
|
|
||
| function initRepositoryActionsView() { | ||
|
|
@@ -103,3 +106,53 @@ function initRepositoryActionsView() { | |
| }); | ||
| view.mount(el); | ||
| } | ||
|
|
||
| function initRepositoryActionsList(): void { | ||
| const runsList = document.querySelector('#actions-runs-list'); | ||
| if (!runsList) return; | ||
|
|
||
| let timerId: number | null = null; | ||
| let pollingInterval = 3000; | ||
|
|
||
| const runPolling = async () => { | ||
| if (!document.contains(runsList)) { | ||
| if (timerId) { | ||
| clearTimeout(timerId); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| if (document.hidden) { | ||
| timerId = window.setTimeout(runPolling, pollingInterval); | ||
| return; | ||
| } | ||
|
|
||
| const hasActiveRuns = document.querySelector( | ||
|
wxiaoguang marked this conversation as resolved.
Outdated
|
||
| '#actions-runs-list .run-list .item[data-status="running"], ' + | ||
| '#actions-runs-list .run-list .item[data-status="waiting"], ' + | ||
| '#actions-runs-list .run-list .item[data-status="cancelling"]', | ||
|
wxiaoguang marked this conversation as resolved.
Outdated
|
||
| ) !== null; | ||
|
|
||
| pollingInterval = hasActiveRuns ? 3000 : 10000; | ||
|
|
||
| try { | ||
| const url = new URL(window.location.href); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. open run action-menu (kebab dropdown) is reset on every morph. |
||
| url.searchParams.set('runs-list-only', 'true'); | ||
| const response = await GET(url.href, { | ||
| headers: { | ||
| 'X-Requested-With': 'XMLHttpRequest', | ||
|
wxiaoguang marked this conversation as resolved.
Outdated
|
||
| }, | ||
| }); | ||
| if (response.ok) { | ||
| const htmlText = await response.text(); | ||
| Idiomorph.morph(runsList, htmlText, {morphStyle: 'innerHTML'}); | ||
| } | ||
| } catch (e) { | ||
| console.error('Failed to update actions runs list:', e); | ||
| } | ||
|
|
||
| timerId = window.setTimeout(runPolling, pollingInterval); | ||
| }; | ||
|
|
||
| timerId = window.setTimeout(runPolling, pollingInterval); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The runs-list-only short-circuit is placed after every prepare* call. So every 3s (per open tab, per client, forever) the server re-runs prepareWorkflowTemplate → actions.ListWorkflows (git tree read) → reads and YAML-parses every workflow file → ResolveUses for reusable workflows (actions.go:188-227), plus the scoped/other/dispatch prep — all of it discarded, only runs_list returned. On a repo with many/large workflow files this is a large, continuous CPU + git-I/O cost for a "lightweight" refresh.