Skip to content

Modern Docker Management, Designed for Everyone

fix: pre-mature pull completed message in popover (#1580)

Kyle Mendellbe29289af352
diff --git a/frontend/src/lib/components/progress-popover.svelte b/frontend/src/lib/components/progress-popover.svelte
index da2544092..9cea8dfbd 100644
--- a/frontend/src/lib/components/progress-popover.svelte
+++ b/frontend/src/lib/components/progress-popover.svelte
@@ -15,7 +15,9 @@
getPullPhase,
getLayerStats,
showImageLayersState,
- isIndeterminatePhase
+ isIndeterminatePhase,
+ getAggregatePullPhase,
+ getAggregateStatus
} from '$lib/utils/pull-progress';
import { DownloadIcon, BoxIcon, ArrowDownIcon, VerifiedCheckIcon, CloseIcon } from '$lib/icons';
import { IsMobile } from '$lib/hooks/is-mobile.svelte.js';
@@ -90,8 +92,14 @@
const isIndeterminate = $derived(isIndeterminatePhase(layers, progress));
const isIndeterminateGeneric = $derived(mode !== 'pull' && loading && !isComplete && !error);
+ // Derive aggregate status for display
+ const aggregateStatus = $derived(getAggregateStatus(layers, statusText, hasReachedComplete || isComplete));
+
// Derive the current phase from status text using utility (pull-mode only)
const currentPhase = $derived.by((): PullPhase => {
+ if (Object.keys(layers).length > 0) {
+ return getAggregatePullPhase(layers, hasReachedComplete || isComplete, !!error);
+ }
return getPullPhase(statusText, hasReachedComplete || isComplete, !!error);
});
@@ -163,14 +171,14 @@
{#if error}
{error}
{:else if mode !== 'pull'}
- {statusText || subtitle}
+ {aggregateStatus || subtitle}
{:else if layerStats.total > 0}
- {statusText || subtitle}
+ {aggregateStatus || subtitle}
<span class="text-muted-foreground">
· {m.progress_layers_status({ completed: layerStats.completed, total: layerStats.total })}</span
>
{:else}
- {hasReachedComplete ? 100 : percent}% · {statusText || subtitle}
+ {hasReachedComplete ? 100 : percent}% · {aggregateStatus || subtitle}
{/if}
</Item.Description>
</Item.Content>
diff --git a/frontend/src/lib/components/sheets/image-pull-sheet.svelte b/frontend/src/lib/components/sheets/image-pull-sheet.svelte
index 6879a9c8f..30bd4eace 100644
--- a/frontend/src/lib/components/sheets/image-pull-sheet.svelte
+++ b/frontend/src/lib/components/sheets/image-pull-sheet.svelte
@@ -20,7 +20,8 @@
getLayerStats,
getPullPhase,
showImageLayersState,
- isIndeterminatePhase
+ isIndeterminatePhase,
+ getAggregateStatus
} from '$lib/utils/pull-progress';
import { ArrowDownIcon, SuccessIcon, DownloadIcon } from '$lib/icons';
@@ -50,8 +51,8 @@
let layerProgress = $state<Record<string, LayerProgress>>({});
let hasReachedComplete = $state(false);
let currentImageName = $state('');
-
const layerStats = $derived(getLayerStats(layerProgress, hasReachedComplete));
+ const aggregateStatus = $derived(getAggregateStatus(layerProgress, pullStatusText, hasReachedComplete));
const showPullUI = $derived(isPulling || hasReachedComplete || !!pullError);
const isIndeterminate = $derived(isIndeterminatePhase(layerProgress, pullProgress));
let prevOpen = $state(false);
@@ -249,9 +250,15 @@
{#if hasReachedComplete}
{m.progress_pull_completed()}
{:else if layerStats.total > 0}
- {m.progress_layers_status({ completed: layerStats.completed, total: layerStats.total })}
+ <span class="flex items-center gap-1.5">
+ <span>{aggregateStatus}</span>
+ <span class="text-muted-foreground font-normal">•</span>
+ <span class="text-muted-foreground font-normal">
+ {m.progress_layers_status({ completed: layerStats.completed, total: layerStats.total })}
+ </span>
+ </span>
{:else}
- {pullStatusText || m.common_action_pulling()}
+ {aggregateStatus || m.common_action_pulling()}
{/if}
</p>
{#if !isIndeterminate || hasReachedComplete}
diff --git a/frontend/src/lib/utils/pull-progress.ts b/frontend/src/lib/utils/pull-progress.ts
index 93609296b..645b0e788 100644
--- a/frontend/src/lib/utils/pull-progress.ts
+++ b/frontend/src/lib/utils/pull-progress.ts
@@ -44,9 +44,8 @@ export function isLayerComplete(status: string): boolean {
return (
s.includes('pull complete') ||
s.includes('already exists') ||
- s.includes('download complete') ||
- s.includes('extracted') ||
- (s.includes('complete') && !s.includes('downloading'))
+ s.includes('downloaded newer image') ||
+ s.includes('image is up to date')
);
}
@@ -93,33 +92,34 @@ export function isDownloadingLine(data: unknown): boolean {
* Calculates overall progress from layer progress data
*/
export function calculateOverallProgress(layers: Record<string, LayerProgress>): number {
- let totalCurrentBytes = 0;
- let totalExpectedBytes = 0;
- let activeLayers = 0;
-
- for (const id in layers) {
- const layer = layers[id];
- if (layer.total > 0) {
- totalCurrentBytes += layer.current;
- totalExpectedBytes += layer.total;
- activeLayers++;
+ const entries = Object.values(layers);
+ if (entries.length === 0) return 0;
+
+ const totalLayers = entries.length;
+ let weightedSum = 0;
+
+ for (const layer of entries) {
+ const s = (layer.status || '').toLowerCase();
+ if (isLayerComplete(s)) {
+ weightedSum += 1.0;
+ } else if (s.includes('extracting')) {
+ // Extraction is the last step before completion
+ weightedSum += 0.95;
+ } else if (s.includes('verifying')) {
+ weightedSum += 0.92;
+ } else if (s.includes('download complete')) {
+ weightedSum += 0.85;
+ } else if (layer.total > 0) {
+ // Download progress is weighted up to 85%
+ const downloadProgress = (layer.current / layer.total) * 0.85;
+ weightedSum += Math.min(downloadProgress, 0.85);
+ } else if (s.includes('downloading') || s.includes('pulling')) {
+ weightedSum += 0.05;
}
}
- if (totalExpectedBytes > 0) {
- return (totalCurrentBytes / totalExpectedBytes) * 100;
- }
-
- if (activeLayers > 0 && totalCurrentBytes > 0) {
- return 5;
- }
-
- if (Object.keys(layers).length > 0 && activeLayers === 0) {
- const allDone = Object.values(layers).every((l) => l.status && isLayerComplete(l.status));
- if (allDone) return 100;
- }
-
- return 0;
+ const overallProgress = (weightedSum / totalLayers) * 100;
+ return Math.min(overallProgress, 100);
}
/**
@@ -129,13 +129,7 @@ export function areAllLayersComplete(layers: Record<string, LayerProgress>): boo
const entries = Object.values(layers);
if (entries.length === 0) return false;
- return entries.every(
- (l) =>
- l.status &&
- (l.status.toLowerCase().includes('complete') ||
- l.status.toLowerCase().includes('already exists') ||
- l.status.toLowerCase().includes('downloaded newer image'))
- );
+ return entries.every((l) => l.status && isLayerComplete(l.status));
}
/**
@@ -146,7 +140,13 @@ export function getLayerStats(layers: Record<string, LayerProgress>, forceComple
const total = entries.length;
const completed = entries.filter(([_, l]) => isLayerComplete(l.status || '')).length;
const effectiveCompleted = forceComplete ? total : completed;
- const downloading = entries.filter(([_, l]) => l.status?.toLowerCase().includes('downloading')).length;
+
+ // Downloading: status contains 'downloading' or 'pulling' explicitly
+ const downloading = entries.filter(([_, l]) => {
+ const s = (l.status || '').toLowerCase();
+ return s.includes('downloading') || s.includes('pulling');
+ }).length;
+
const extracting = entries.filter(([_, l]) => l.status?.toLowerCase().includes('extracting')).length;
return { total, completed: effectiveCompleted, downloading, extracting };
@@ -262,3 +262,64 @@ export function createPullStreamHandler(callbacks: {
callbacks.onProgressChange(progress);
};
}
+
+/**
+ * Returns a computed aggregate status string based on all layers
+ */
+export function getAggregateStatus(
+ layers: Record<string, LayerProgress>,
+ fallbackStatus = '',
+ isComplete = false
+): string {
+ if (isComplete) return 'Pull complete';
+
+ const entries = Object.values(layers);
+ if (entries.length === 0) return fallbackStatus;
+
+ if (areAllLayersComplete(layers)) return 'Pull complete';
+
+ const stats = getLayerStats(layers);
+
+ if (stats.downloading > 0 || stats.extracting > 0) return 'Pulling';
+
+ const hasVerifying = entries.some(
+ (l) => l.status?.toLowerCase().includes('verifying') || l.status?.toLowerCase().includes('digest')
+ );
+ if (hasVerifying) return 'Verifying checksum';
+
+ const hasWaiting = entries.some((l) => l.status?.toLowerCase().includes('waiting'));
+ if (hasWaiting) return 'Waiting';
+
+ return fallbackStatus || 'Preparing';
+}
+
+/**
+ * Returns an aggregate PullPhase for phase-based title system
+ */
+export function getAggregatePullPhase(
+ layers: Record<string, LayerProgress>,
+ isComplete = false,
+ hasError = false
+): PullPhase {
+ if (hasError) return 'error';
+ if (isComplete) return 'complete';
+
+ const entries = Object.values(layers);
+ if (entries.length === 0) return 'preparing';
+
+ if (areAllLayersComplete(layers)) return 'complete';
+
+ const stats = getLayerStats(layers);
+
+ if (stats.downloading > 0 || stats.extracting > 0) return 'downloading';
+
+ const hasVerifying = entries.some(
+ (l) => l.status?.toLowerCase().includes('verifying') || l.status?.toLowerCase().includes('digest')
+ );
+ if (hasVerifying) return 'verifying';
+
+ const hasWaiting = entries.some((l) => l.status?.toLowerCase().includes('waiting'));
+ if (hasWaiting) return 'waiting';
+
+ return 'preparing';
+}