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();
this.refreshProjectGitSummary?.();
this.startProjectGitSummaryIdleRefresh?.();
this.startConnectionHeartbeat();
this.checkTutorialPrompt();
if (initialDataPromise && typeof initialDataPromise.then === 'function') {
@ -118,6 +119,7 @@ export function beforeUnmount() {
this.teardownMobileViewportWatcher();
this.subAgentStopPolling();
this.backgroundCommandStopPolling();
this.stopProjectGitSummaryIdleRefresh?.();
this.resourceStopContainerStatsPolling();
this.resourceStopProjectStoragePolling();
this.resourceStopUsageQuotaPolling();

View File

@ -154,7 +154,30 @@ function parseSystemNoticeLabel(rawContent: any): string | null {
}
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() {
if (this.projectGitSummaryRefreshing) {
return;
}
this.projectGitSummaryRefreshing = true;
try {
const resp = await fetch('/api/project/git-summary');
const payload = await resp.json().catch(() => ({}));
@ -170,6 +193,8 @@ export const uiMethods = {
} catch (_) {
this.projectGitSummary = null;
this.gitChangesDiff = null;
} finally {
this.projectGitSummaryRefreshing = false;
}
},

View File

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