From 68936125a026d2fc145e834a42bf72a5f1f608bd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 13 Jan 2026 04:34:34 +0000 Subject: [PATCH 1/4] Initial plan From 19df77bb5a341a8cfd05a72ca436603b7dccc8c3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 13 Jan 2026 04:41:28 +0000 Subject: [PATCH 2/4] Add loading animation to container action buttons Co-authored-by: JonasGao <4549584+JonasGao@users.noreply.github.com> --- webui/src/components/ContainerList.svelte | 124 +++++++++++++++++++--- webui/src/pages/Home.svelte | 23 +++- 2 files changed, 131 insertions(+), 16 deletions(-) diff --git a/webui/src/components/ContainerList.svelte b/webui/src/components/ContainerList.svelte index 0a4b139..53d7d5d 100644 --- a/webui/src/components/ContainerList.svelte +++ b/webui/src/components/ContainerList.svelte @@ -5,9 +5,10 @@ containers: Container[]; displayMode: 'compact' | 'standard'; onAction: (containerId: string, action: 'start' | 'stop' | 'restart', isSelf: boolean) => void; + loadingActions: Map; } - let { containers, displayMode, onAction }: Props = $props(); + let { containers, displayMode, onAction, loadingActions }: Props = $props(); const stateEmojis: Record = { created: '🆕', @@ -25,6 +26,16 @@ starting: '🔄', none: '' }; + + // Helper function to check if a specific action is loading for a container + function isActionLoading(containerId: string, action: 'start' | 'stop' | 'restart'): boolean { + return loadingActions.get(containerId) === action; + } + + // Helper function to check if any action is loading for a container + function isContainerLoading(containerId: string): boolean { + return loadingActions.has(containerId); + }
@@ -52,36 +63,57 @@ {#if container.state === 'running'} {:else if ['exited', 'created', 'dead'].includes(container.state)} {:else} {/if} onAction(container.id, 'stop', container.is_self ?? false)} - disabled={container.is_self} + disabled={container.is_self || isContainerLoading(container.id)} title={container.is_self ? "无法停止本应用容器" : ""} > - ⏸️ 停止 + {#if isActionLoading(container.id, 'stop')} + + {:else} + ⏸️ + {/if} + 停止 {:else if ['exited', 'created', 'dead'].includes(container.state)} {:else} {/if} (); + // Track if component has mounted to prevent reload during initial setup let isMounted = false; - let filterDebounceTimer: number | null = null; + let filterDebounceTimer: number | undefined = undefined; const FILTER_DEBOUNCE_DELAY = 500; // milliseconds to wait before reloading after filter text changes @@ -351,7 +354,14 @@ try { actionError = ''; + // Set loading state for this specific action + loadingActions = new Map(loadingActions).set(containerId, action); + await containerApi.controlContainer({ containerId, action }); + + // Wait 200ms before refreshing + await new Promise(resolve => setTimeout(resolve, 200)); + await loadContainers(); } catch (err) { const errorMessage = err instanceof Error ? err.message : '未知错误'; @@ -362,6 +372,11 @@ } console.error('Container action failed:', err); setTimeout(() => { actionError = ''; }, 3000); + } finally { + // Clear loading state for this container + const newLoadingActions = new Map(loadingActions); + newLoadingActions.delete(containerId); + loadingActions = newLoadingActions; } } @@ -503,6 +518,7 @@ containers={projectContainers} displayMode={displayMode} onAction={handleAction} + loadingActions={loadingActions} /> {/if}
@@ -528,6 +544,7 @@ containers={ungrouped} displayMode={displayMode} onAction={handleAction} + loadingActions={loadingActions} /> {/if} @@ -573,6 +590,7 @@ containers={labelContainers} displayMode={displayMode} onAction={handleAction} + loadingActions={loadingActions} /> {/if} @@ -598,6 +616,7 @@ containers={ungrouped} displayMode={displayMode} onAction={handleAction} + loadingActions={loadingActions} /> {/if} @@ -640,6 +659,7 @@ containers={groupContainers} displayMode={displayMode} onAction={handleAction} + loadingActions={loadingActions} /> {/if} @@ -651,6 +671,7 @@ containers={sortedContainers} displayMode={displayMode} onAction={handleAction} + loadingActions={loadingActions} /> {/if} {/if} From a882cec558f535fa9a5a21cf22043de91916e44a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 13 Jan 2026 04:45:47 +0000 Subject: [PATCH 3/4] Address code review feedback: extract magic numbers to constants Co-authored-by: JonasGao <4549584+JonasGao@users.noreply.github.com> --- webui/src/components/ContainerList.svelte | 8 ++++++-- webui/src/pages/Home.svelte | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/webui/src/components/ContainerList.svelte b/webui/src/components/ContainerList.svelte index 53d7d5d..ee623ad 100644 --- a/webui/src/components/ContainerList.svelte +++ b/webui/src/components/ContainerList.svelte @@ -239,6 +239,10 @@