fix(logs): stop build-log polling once build finishes

The build-logs tab kept polling every 5s and showing the auto-refresh
indicator even after the build reached a terminal state. Gate both on
the build still being in progress, and label a completed build as
"done" instead of the misleading "running" status.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
keyhan
2026-06-16 02:23:01 +03:30
parent 1ae51fb273
commit ce6813db99
3 changed files with 15 additions and 3 deletions
@@ -50,6 +50,11 @@ export function WorkloadLogsPanel({
refetchInterval: showLogs && logTab === 'pod' ? 3000 : false,
});
// Only keep polling while a build is still in progress; once it reaches a
// terminal state (running/failed/cancelled/…) the log is final, so stop.
const buildInProgress = (status?: string) =>
!status || status === 'pending' || status === 'building' || status === 'deploying';
const { data: buildLogsData } = useQuery<{
buildLog: string | null;
status: string;
@@ -58,9 +63,14 @@ export function WorkloadLogsPanel({
queryKey: ['build-logs', appId],
queryFn: () => api.get(`/deployments/applications/${appId}/build-logs`).then((r) => r.data),
enabled: showBuildLogs && showLogs && logTab === 'build',
refetchInterval: showBuildLogs && showLogs && logTab === 'build' ? 5000 : false,
refetchInterval: (query) =>
showBuildLogs && showLogs && logTab === 'build' && buildInProgress(query.state.data?.status)
? 5000
: false,
});
const buildIsLive = showBuildLogs && showLogs && logTab === 'build' && buildInProgress(buildLogsData?.status);
const podPlaceholder =
emptyPodMessage ||
(isRunning
@@ -82,7 +92,7 @@ export function WorkloadLogsPanel({
<span>{wl.liveEvery3s}</span>
</span>
)}
{showBuildLogs && showLogs && logTab === 'build' && (
{buildIsLive && (
<span className="text-xs text-gray-400 flex items-center space-x-1 rtl:space-x-reverse">
<span className="w-2 h-2 bg-blue-500 rounded-full animate-pulse" />
<span>{wl.autoEvery5s}</span>
@@ -147,7 +157,7 @@ export function WorkloadLogsPanel({
<Pin className="w-3 h-3 inline" /> {buildLogsData.version}
</span>
<span className={`badge ${statusColors[buildLogsData.status] || 'badge-gray'}`}>
{statusLabel(buildLogsData.status)}
{buildLogsData.status === 'running' ? wl.buildDone : statusLabel(buildLogsData.status)}
</span>
</div>
)}
+1
View File
@@ -233,6 +233,7 @@ const en: Dictionary = {
buildPending: 'Build is pending...',
noDeployments: 'No deployments yet. Deploy your app to see build logs.',
noBuildLogs: 'No build logs available for this deployment.',
buildDone: 'Done',
},
externalAccess: {
title: 'External access',
+1
View File
@@ -232,6 +232,7 @@ const fa = {
buildPending: 'بیلد در صف است…',
noDeployments: 'هنوز دیپلویی نیست. برای دیدن لاگ بیلد اپت را منتشر کن.',
noBuildLogs: 'لاگ بیلدی برای این دیپلوی موجود نیست.',
buildDone: 'انجام شده',
},
externalAccess: {
title: 'دسترسی خارجی',