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:
@@ -50,6 +50,11 @@ export function WorkloadLogsPanel({
|
|||||||
refetchInterval: showLogs && logTab === 'pod' ? 3000 : false,
|
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<{
|
const { data: buildLogsData } = useQuery<{
|
||||||
buildLog: string | null;
|
buildLog: string | null;
|
||||||
status: string;
|
status: string;
|
||||||
@@ -58,9 +63,14 @@ export function WorkloadLogsPanel({
|
|||||||
queryKey: ['build-logs', appId],
|
queryKey: ['build-logs', appId],
|
||||||
queryFn: () => api.get(`/deployments/applications/${appId}/build-logs`).then((r) => r.data),
|
queryFn: () => api.get(`/deployments/applications/${appId}/build-logs`).then((r) => r.data),
|
||||||
enabled: showBuildLogs && showLogs && logTab === 'build',
|
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 =
|
const podPlaceholder =
|
||||||
emptyPodMessage ||
|
emptyPodMessage ||
|
||||||
(isRunning
|
(isRunning
|
||||||
@@ -82,7 +92,7 @@ export function WorkloadLogsPanel({
|
|||||||
<span>{wl.liveEvery3s}</span>
|
<span>{wl.liveEvery3s}</span>
|
||||||
</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="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 className="w-2 h-2 bg-blue-500 rounded-full animate-pulse" />
|
||||||
<span>{wl.autoEvery5s}</span>
|
<span>{wl.autoEvery5s}</span>
|
||||||
@@ -147,7 +157,7 @@ export function WorkloadLogsPanel({
|
|||||||
<Pin className="w-3 h-3 inline" /> {buildLogsData.version}
|
<Pin className="w-3 h-3 inline" /> {buildLogsData.version}
|
||||||
</span>
|
</span>
|
||||||
<span className={`badge ${statusColors[buildLogsData.status] || 'badge-gray'}`}>
|
<span className={`badge ${statusColors[buildLogsData.status] || 'badge-gray'}`}>
|
||||||
{statusLabel(buildLogsData.status)}
|
{buildLogsData.status === 'running' ? wl.buildDone : statusLabel(buildLogsData.status)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -233,6 +233,7 @@ const en: Dictionary = {
|
|||||||
buildPending: 'Build is pending...',
|
buildPending: 'Build is pending...',
|
||||||
noDeployments: 'No deployments yet. Deploy your app to see build logs.',
|
noDeployments: 'No deployments yet. Deploy your app to see build logs.',
|
||||||
noBuildLogs: 'No build logs available for this deployment.',
|
noBuildLogs: 'No build logs available for this deployment.',
|
||||||
|
buildDone: 'Done',
|
||||||
},
|
},
|
||||||
externalAccess: {
|
externalAccess: {
|
||||||
title: 'External access',
|
title: 'External access',
|
||||||
|
|||||||
@@ -232,6 +232,7 @@ const fa = {
|
|||||||
buildPending: 'بیلد در صف است…',
|
buildPending: 'بیلد در صف است…',
|
||||||
noDeployments: 'هنوز دیپلویی نیست. برای دیدن لاگ بیلد اپت را منتشر کن.',
|
noDeployments: 'هنوز دیپلویی نیست. برای دیدن لاگ بیلد اپت را منتشر کن.',
|
||||||
noBuildLogs: 'لاگ بیلدی برای این دیپلوی موجود نیست.',
|
noBuildLogs: 'لاگ بیلدی برای این دیپلوی موجود نیست.',
|
||||||
|
buildDone: 'انجام شده',
|
||||||
},
|
},
|
||||||
externalAccess: {
|
externalAccess: {
|
||||||
title: 'دسترسی خارجی',
|
title: 'دسترسی خارجی',
|
||||||
|
|||||||
Reference in New Issue
Block a user