fix(ui): refresh git summary while idle

This commit is contained in:
JOJO 2026-05-31 23:28:10 +08:00
parent 2f0e269788
commit f2d7d8f3b1
3 changed files with 29 additions and 0 deletions

View File

@ -42,6 +42,7 @@ export async function mounted() {
// 立即加载初始数据(并行获取状态,优先同步运行模式) // 立即加载初始数据(并行获取状态,优先同步运行模式)
const initialDataPromise = this.loadInitialData(); const initialDataPromise = this.loadInitialData();
this.refreshProjectGitSummary?.(); this.refreshProjectGitSummary?.();
this.startProjectGitSummaryIdleRefresh?.();
this.startConnectionHeartbeat(); this.startConnectionHeartbeat();
this.checkTutorialPrompt(); this.checkTutorialPrompt();
if (initialDataPromise && typeof initialDataPromise.then === 'function') { if (initialDataPromise && typeof initialDataPromise.then === 'function') {
@ -118,6 +119,7 @@ export function beforeUnmount() {
this.teardownMobileViewportWatcher(); this.teardownMobileViewportWatcher();
this.subAgentStopPolling(); this.subAgentStopPolling();
this.backgroundCommandStopPolling(); this.backgroundCommandStopPolling();
this.stopProjectGitSummaryIdleRefresh?.();
this.resourceStopContainerStatsPolling(); this.resourceStopContainerStatsPolling();
this.resourceStopProjectStoragePolling(); this.resourceStopProjectStoragePolling();
this.resourceStopUsageQuotaPolling(); this.resourceStopUsageQuotaPolling();

View File

@ -154,7 +154,30 @@ function parseSystemNoticeLabel(rawContent: any): string | null {
} }
export const uiMethods = { export const uiMethods = {
startProjectGitSummaryIdleRefresh() {
if (this.projectGitSummaryRefreshTimer) {
return;
}
this.projectGitSummaryRefreshTimer = window.setInterval(() => {
if (!this.isConnected) return;
if (typeof this.isOutputActive === 'function' && this.isOutputActive()) return;
this.refreshProjectGitSummary?.({ idleFallback: true });
}, 5000);
},
stopProjectGitSummaryIdleRefresh() {
if (!this.projectGitSummaryRefreshTimer) {
return;
}
window.clearInterval(this.projectGitSummaryRefreshTimer);
this.projectGitSummaryRefreshTimer = null;
},
async refreshProjectGitSummary() { async refreshProjectGitSummary() {
if (this.projectGitSummaryRefreshing) {
return;
}
this.projectGitSummaryRefreshing = true;
try { try {
const resp = await fetch('/api/project/git-summary'); const resp = await fetch('/api/project/git-summary');
const payload = await resp.json().catch(() => ({})); const payload = await resp.json().catch(() => ({}));
@ -170,6 +193,8 @@ export const uiMethods = {
} catch (_) { } catch (_) {
this.projectGitSummary = null; this.projectGitSummary = null;
this.gitChangesDiff = null; this.gitChangesDiff = null;
} finally {
this.projectGitSummaryRefreshing = false;
} }
}, },

View File

@ -37,6 +37,8 @@ export function dataState() {
runtimeQueueSyncLockKey: '', runtimeQueueSyncLockKey: '',
runtimeQueueSyncLockUntil: 0, runtimeQueueSyncLockUntil: 0,
projectGitSummary: null, projectGitSummary: null,
projectGitSummaryRefreshTimer: null,
projectGitSummaryRefreshing: false,
gitChangesPanelOpen: false, gitChangesPanelOpen: false,
gitChangesLoading: false, gitChangesLoading: false,
gitChangesError: '', gitChangesError: '',