Skip to content

Commit d295cb5

Browse files
authored
Add a setting to increase PR refresh rate (#6911)
* Add a setting to increase PR refresh rate Fixes #6909 * units
1 parent b711052 commit d295cb5

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,11 @@
481481
"markdownDescription": "%githubPullRequests.experimental.useQuickChat.description%",
482482
"default": false
483483
},
484+
"githubPullRequests.webviewRefreshInterval": {
485+
"type": "number",
486+
"markdownDescription": "%githubPullRequests.webviewRefreshInterval.description%",
487+
"default": 60
488+
},
484489
"githubIssues.ignoreMilestones": {
485490
"type": "array",
486491
"default": [],

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
"githubPullRequests.experimental.notificationsView.description": "Enables the notifications view, which shows a list of your GitHub notifications. When combined with `#githubPullRequests.experimental.chat#`, you can have Copilot sort and summarize your notifications. View will not show in a Codespace accessed from the browser.",
9191
"githubPullRequests.experimental.notificationsMarkPullRequests.description": "Adds an action in the Notifications view to mark pull requests with no non-empty reviews, comments, or commits since you last viewed the pull request as read.",
9292
"githubPullRequests.experimental.useQuickChat.description": "Controls whether the Copilot \"Summarize\" commands in the Pull Requests, Issues, and Notifications views will use quick chat. Only has an effect if `#githubPullRequests.experimental.chat#` is enabled.",
93+
"githubPullRequests.webviewRefreshInterval.description": "The interval, in seconds, at which the pull request and issues webviews are refreshed when the webview is the active tab.",
9394
"githubIssues.ignoreMilestones.description": "An array of milestones titles to never show issues from.",
9495
"githubIssues.createIssueTriggers.description": "Strings that will cause the 'Create issue from comment' code action to show.",
9596
"githubIssues.createIssueTriggers.items": "String that enables the 'Create issue from comment' code action. Should not contain whitespace.",

src/common/settingKeys.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export const EXPERIMENTAL_USE_QUICK_CHAT = 'experimental.useQuickChat';
5757
export const EXPERIMENTAL_NOTIFICATIONS = 'experimental.notificationsView';
5858
export const EXPERIMENTAL_NOTIFICATIONS_PAGE_SIZE = 'experimental.notificationsViewPageSize';
5959
export const EXPERIMENTAL_NOTIFICATIONS_SCORE = 'experimental.notificationsScore';
60+
export const WEBVIEW_REFRESH_INTERVAL = 'webviewRefreshInterval';
6061

6162
// git
6263
export const GIT = 'git';

src/github/issueOverview.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as vscode from 'vscode';
88
import { openPullRequestOnGitHub } from '../commands';
99
import { COPILOT_ACCOUNTS, IComment } from '../common/comment';
1010
import Logger from '../common/logger';
11+
import { WEBVIEW_REFRESH_INTERVAL } from '../common/settingKeys';
1112
import { ITelemetry } from '../common/telemetry';
1213
import { CommentEvent, EventType, TimelineEvent } from '../common/timelineEvent';
1314
import { asPromise, formatError } from '../common/utils';
@@ -132,13 +133,26 @@ export class IssueOverviewPanel<TItem extends IssueModel = IssueModel> extends W
132133
this.pollForUpdates(true);
133134
}
134135

136+
private getRefreshInterval(): number {
137+
return vscode.workspace.getConfiguration().get<number>(`githubPullRequests.${WEBVIEW_REFRESH_INTERVAL}`) || 60;
138+
}
139+
140+
private refreshIntervalSetting: vscode.Disposable | undefined;
135141
private pollForUpdates(shorterTimeout: boolean = false): void {
136142
const webview = shorterTimeout || vscode.window.tabGroups.all.find(group => group.activeTab?.input instanceof vscode.TabInputWebview && group.activeTab.input.viewType.endsWith(this.type));
137-
const timeoutDuration = 1000 * 60 * (webview ? 1 : 5);
138-
setTimeout(async () => {
143+
const timeoutDuration = 1000 * (webview ? this.getRefreshInterval() : (5 * 60));
144+
const timeout = setTimeout(async () => {
139145
await this.refreshPanel();
140146
this.pollForUpdates();
141147
}, timeoutDuration);
148+
if (!this.refreshIntervalSetting) {
149+
this.refreshIntervalSetting = vscode.workspace.onDidChangeConfiguration(e => {
150+
if (e.affectsConfiguration(`githubPullRequests.${WEBVIEW_REFRESH_INTERVAL}`)) {
151+
clearTimeout(timeout);
152+
this.pollForUpdates(true);
153+
}
154+
});
155+
}
142156
}
143157

144158
public async refreshPanel(): Promise<void> {

0 commit comments

Comments
 (0)