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,
|
||||
});
|
||||
|
||||
// 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>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user