Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
refactor: always pull latest updates for environment updater (#3196)
Kyle Mendell25142a7b72da
diff --git a/backend/internal/models/environment_update_job.go b/backend/internal/models/environment_update_job.goindex 81f688310..6d984aaaa 100644--- a/backend/internal/models/environment_update_job.go+++ b/backend/internal/models/environment_update_job.go@@ -41,8 +41,6 @@ const (// EnvironmentUpdateResultStatusTriggered means the upgrade was triggered but not// confirmed within the wait window (still likely succeeding in the background).EnvironmentUpdateResultStatusTriggered EnvironmentUpdateResultStatus = "triggered"- // EnvironmentUpdateResultStatusSkippedUpToDate means no update was available.- EnvironmentUpdateResultStatusSkippedUpToDate EnvironmentUpdateResultStatus = "skipped_up_to_date"// EnvironmentUpdateResultStatusSkippedOffline means the environment was unreachable.EnvironmentUpdateResultStatusSkippedOffline EnvironmentUpdateResultStatus = "skipped_offline"// EnvironmentUpdateResultStatusFailed means the upgrade trigger failed.diff --git a/backend/internal/services/system_upgrade_service.go b/backend/internal/services/system_upgrade_service.goindex 5eadbf2f7..357c938e5 100644--- a/backend/internal/services/system_upgrade_service.go+++ b/backend/internal/services/system_upgrade_service.go@@ -412,9 +412,10 @@ func (s *SystemUpgradeService) findArcaneContainerInternal(ctx context.Context,//// Remote agents upgrade first, while the manager is still up and can orchestrate// and report live progress. The manager upgrades itself LAST, which recreates its-// own container. Because the browser loses the backend across that final restart,-// the orchestration is a persisted EnvironmentUpdateJob: StartUpdateAll runs the-// agents phase and, when the manager itself has an update, triggers the manager+// own container. Updates are unconditional: every environment pulls the latest+// image whether or not it reports an update available. Because the browser loses+// the backend across that final restart, the orchestration is a persisted+// EnvironmentUpdateJob: StartUpdateAll runs the agents phase, triggers the manager// self-upgrade as the last step and leaves the job in pending_restart; on the next// boot ResumeUpdateAllOnStartup finalizes the manager result and closes the job.@@ -430,9 +431,10 @@ const ()// StartUpdateAll begins a fleet-wide update. The agents phase runs first in the-// background (while the manager is up); when the manager itself has an update, the-// agents goroutine triggers the manager self-upgrade as its final step (job left-// pending_restart, finalized at next boot).+// background (while the manager is up); the agents goroutine triggers the manager+// self-upgrade as its final step (job left pending_restart, finalized at next+// boot). Every environment pulls the latest image, whether or not it reports an+// update available.func (s *SystemUpgradeService) StartUpdateAll(ctx context.Context, user models.User, env *EnvironmentService) (*models.EnvironmentUpdateJob, error) {// Guard the check-then-create against concurrent callers (e.g. a double-click).// A dedicated flag rather than s.upgrading, because the manager branch below@@ -473,19 +475,14 @@ func (s *SystemUpgradeService) StartUpdateAll(ctx context.Context, user models.UManagerTargetVersion: updateAllTargetVersionInternal(info),}- managerHasUpdate := info.UpdateAvailable- if managerHasUpdate {- // Manager upgrades LAST. Seed its row pending; the agents-phase goroutine- // flips it to updating right before triggering the self-upgrade.- managerResult.Status = models.EnvironmentUpdateResultStatusPending- managerResult.ToVersion = job.ManagerTargetVersion- } else {- managerResult.Status = models.EnvironmentUpdateResultStatusSkippedUpToDate- }+ // Manager upgrades LAST. Seed its row pending; the agents-phase goroutine+ // flips it to updating right before triggering the self-upgrade.+ managerResult.Status = models.EnvironmentUpdateResultStatusPending+ managerResult.ToVersion = job.ManagerTargetVersion- // Running from the start in both cases: the agents phase happens first, while the- // backend is up and can report progress. The manager self-upgrade (if any) fires- // at the very end of the agents goroutine.+ // Running from the start: the agents phase happens first, while the backend is+ // up and can report progress. The manager self-upgrade fires at the very end of+ // the agents goroutine.job.Status = models.EnvironmentUpdateJobStatusRunningjob.Results = append(models.EnvironmentUpdateResults{managerResult}, remoteResults...)@@ -493,8 +490,8 @@ func (s *SystemUpgradeService) StartUpdateAll(ctx context.Context, user models.Ureturn nil, fmt.Errorf("create update-all job: %w", err)}- slog.InfoContext(ctx, "Update-all started; upgrading agents first", "jobId", job.ID, "managerHasUpdate", managerHasUpdate, "user", user.Username)- go s.runAgentsPhaseInternal(context.WithoutCancel(ctx), job.ID, env, user, managerHasUpdate)+ slog.InfoContext(ctx, "Update-all started; upgrading agents first", "jobId", job.ID, "user", user.Username)+ go s.runAgentsPhaseInternal(context.WithoutCancel(ctx), job.ID, env, user)return job, nil}@@ -551,7 +548,9 @@ type resumeActionInternal struct {// resolveResumeActionInternal is the pure decision for a resumed pending_restart// job: stale if it has waited too long, otherwise the manager upgrade is considered// successful when either the version or the digest changed from the at-start values-// (digest covers non-semver, digest-pinned installs).+// (digest covers non-semver, digest-pinned installs), or when the manager is already+// on the recorded target — a force-update of an up-to-date manager recreates the+// container without changing either.func resolveResumeActionInternal(job *models.EnvironmentUpdateJob, currentVersion, currentDigest string, now time.Time) resumeActionInternal {if now.Sub(job.CreatedAt) > updateAllStaleThresholdInternal {return resumeActionInternal{markStale: true}@@ -559,16 +558,20 @@ func resolveResumeActionInternal(job *models.EnvironmentUpdateJob, currentVersioversionChanged := job.ManagerVersionAtStart != "" && currentVersion != job.ManagerVersionAtStartdigestChanged := job.ManagerDigestAtStart != "" && currentDigest != job.ManagerDigestAtStart+ // ManagerTargetVersion holds the newest version tag when known, otherwise the+ // newest digest — compare against both current identifiers.+ onTarget := job.ManagerTargetVersion != "" &&+ (strings.TrimPrefix(currentVersion, "v") == strings.TrimPrefix(job.ManagerTargetVersion, "v") ||+ currentDigest == job.ManagerTargetVersion)- return resumeActionInternal{managerSucceeded: versionChanged || digestChanged}+ return resumeActionInternal{managerSucceeded: versionChanged || digestChanged || onTarget}}-// runAgentsPhaseInternal upgrades every online remote environment that has an update-// available, sequentially, persisting progress after each one so the status endpoint-// can report live progress. When managerHasUpdate is set, it triggers the manager's-// own self-upgrade as the final step (leaving the job pending_restart for the next-// boot to finalize); otherwise it marks the job completed in-process.-func (s *SystemUpgradeService) runAgentsPhaseInternal(ctx context.Context, jobID string, env *EnvironmentService, user models.User, managerHasUpdate bool) {+// runAgentsPhaseInternal upgrades every online remote environment sequentially,+// persisting progress after each one so the status endpoint can report live+// progress, then triggers the manager's own self-upgrade as the final step+// (leaving the job pending_restart for the next boot to finalize).+func (s *SystemUpgradeService) runAgentsPhaseInternal(ctx context.Context, jobID string, env *EnvironmentService, user models.User) {job, err := s.getUpdateAllJobByIDInternal(ctx, jobID)if err != nil || job == nil {slog.WarnContext(ctx, "update-all: failed to reload job for agents phase", "jobId", jobID, "error", err)@@ -600,41 +603,29 @@ func (s *SystemUpgradeService) runAgentsPhaseInternal(ctx context.Context, jobID}}- // All remote agents processed. Handle the manager LAST.- if managerHasUpdate {- // Flip the manager row pending -> updating and move the job to pending_restart,- // persisting BEFORE the trigger so that if the manager dies the instant the- // upgrader starts, the next boot sees pending_restart and finalizes it.- for i := range job.Results {- if job.Results[i].EnvironmentID == localEnvironmentIDInternal {- job.Results[i].Status = models.EnvironmentUpdateResultStatusUpdating- break- }- }- job.Status = models.EnvironmentUpdateJobStatusPendingRestart- if err := s.persistUpdateAllJobInternal(ctx, job); err != nil {- slog.WarnContext(ctx, "update-all: failed to persist pending_restart before manager upgrade", "jobId", job.ID, "error", err)- }-- if err := s.TriggerUpgradeViaCLI(ctx, user, updatertypes.SelfUpdateTarget{}); err != nil {- // Agents already ran and no restart is coming, so finalize now. This flips- // the manager's updating row to failed with the reason.- s.markUpdateAllFailedInternal(ctx, job, fmt.Sprintf("manager upgrade trigger failed: %v", err))- return+ // All remote agents processed. Handle the manager LAST: flip its row pending ->+ // updating and move the job to pending_restart, persisting BEFORE the trigger so+ // that if the manager dies the instant the upgrader starts, the next boot sees+ // pending_restart and finalizes it.+ for i := range job.Results {+ if job.Results[i].EnvironmentID == localEnvironmentIDInternal {+ job.Results[i].Status = models.EnvironmentUpdateResultStatusUpdating+ break}-- slog.InfoContext(ctx, "Update-all: agents done, manager self-upgrade triggered; finalizing on next boot", "jobId", job.ID)- return}-- job.Status = models.EnvironmentUpdateJobStatusCompleted- job.CompletedAt = new(time.Now())+ job.Status = models.EnvironmentUpdateJobStatusPendingRestartif err := s.persistUpdateAllJobInternal(ctx, job); err != nil {- slog.WarnContext(ctx, "update-all: failed to mark job completed", "jobId", job.ID, "error", err)+ slog.WarnContext(ctx, "update-all: failed to persist pending_restart before manager upgrade", "jobId", job.ID, "error", err)}- s.logUpdateAllEventInternal(ctx, job)- slog.InfoContext(ctx, "Update-all job completed", "jobId", job.ID, "environments", len(job.Results))+ if err := s.TriggerUpgradeViaCLI(ctx, user, updatertypes.SelfUpdateTarget{}); err != nil {+ // Agents already ran and no restart is coming, so finalize now. This flips+ // the manager's updating row to failed with the reason.+ s.markUpdateAllFailedInternal(ctx, job, fmt.Sprintf("manager upgrade trigger failed: %v", err))+ return+ }++ slog.InfoContext(ctx, "Update-all: agents done, manager self-upgrade triggered; finalizing on next boot", "jobId", job.ID)}// seedRemoteResultsInternal builds a pending result row for every remote environment@@ -674,8 +665,9 @@ func upsertPendingResultInternal(job *models.EnvironmentUpdateJob, envID, envNamreturn len(job.Results) - 1}-// upgradeAgentInternal checks, triggers, and confirms a single remote environment's-// self-upgrade, recording the outcome on result.+// upgradeAgentInternal triggers and confirms a single remote environment's+// self-upgrade, recording the outcome on result. The upgrade always runs — the+// agent pulls the latest image even when it reports no update available.func (s *SystemUpgradeService) upgradeAgentInternal(ctx context.Context, env *EnvironmentService, envID string, result *models.EnvironmentUpdateResult) {versionCtx, cancel := context.WithTimeout(ctx, updateAllAgentRequestTimeoutInternal)var info version.Info@@ -687,11 +679,6 @@ func (s *SystemUpgradeService) upgradeAgentInternal(ctx context.Context, env *Enreturn}result.FromVersion = info.CurrentVersion-- if !info.UpdateAvailable {- result.Status = models.EnvironmentUpdateResultStatusSkippedUpToDate- return- }result.ToVersion = updateAllTargetVersionInternal(&info)triggerCtx, cancel := context.WithTimeout(ctx, updateAllAgentRequestTimeoutInternal)@@ -708,7 +695,7 @@ func (s *SystemUpgradeService) upgradeAgentInternal(ctx context.Context, env *Enreturn}- if s.confirmAgentUpgradedInternal(ctx, env, envID, info.CurrentVersion, info.CurrentDigest) {+ if s.confirmAgentUpgradedInternal(ctx, env, envID, info) {result.Status = models.EnvironmentUpdateResultStatusUpdated} else {// Upgrade fired but the new version was not confirmed within the wait window.@@ -735,9 +722,14 @@ func updateAllAgentFailureStatusInternal(err error) models.EnvironmentUpdateResureturn models.EnvironmentUpdateResultStatusSkippedOffline}-// confirmAgentUpgradedInternal polls the agent's version until it changes from the-// pre-upgrade baseline or the wait window elapses.-func (s *SystemUpgradeService) confirmAgentUpgradedInternal(ctx context.Context, env *EnvironmentService, envID, baselineVersion, baselineDigest string) bool {+// confirmAgentUpgradedInternal polls the agent's version until it moves off the+// pre-upgrade baseline or reports the upgrade target, or the wait window elapses.+// The target is the same fallback-resolved identifier recorded in ToVersion, so a+// force-update of an already-latest agent — including one whose version check+// could not determine the latest release — confirms on a same-image recreation+// instead of timing out to triggered.+func (s *SystemUpgradeService) confirmAgentUpgradedInternal(ctx context.Context, env *EnvironmentService, envID string, baseline version.Info) bool {+ target := updateAllTargetVersionInternal(&baseline)deadline := time.Now().Add(updateAllConfirmTimeoutInternal)ticker := time.NewTicker(updateAllConfirmPollIntervalInternal)defer ticker.Stop()@@ -752,9 +744,12 @@ func (s *SystemUpgradeService) confirmAgentUpgradedInternal(ctx context.Context,err := env.ProxyJSONRequest(reqCtx, envID, http.MethodGet, "/api/app-version", nil, &info)cancel()if err == nil {- versionChanged := baselineVersion != "" && info.CurrentVersion != baselineVersion- digestChanged := baselineDigest != "" && info.CurrentDigest != baselineDigest- if versionChanged || digestChanged {+ versionChanged := baseline.CurrentVersion != "" && info.CurrentVersion != baseline.CurrentVersion+ digestChanged := baseline.CurrentDigest != "" && info.CurrentDigest != baseline.CurrentDigest+ onTarget := target != "" &&+ (strings.TrimPrefix(info.CurrentVersion, "v") == strings.TrimPrefix(target, "v") ||+ info.CurrentDigest == target)+ if versionChanged || digestChanged || onTarget {return true}}@@ -909,7 +904,12 @@ func (s *SystemUpgradeService) logUpdateAllEventInternal(ctx context.Context, jo}// updateAllTargetVersionInternal picks the best human-readable target identifier:-// the newest version tag if known, otherwise the newest digest.+// the newest version tag if known, otherwise the newest digest. When the version+// check could not determine the latest release (offline, rate-limited) it falls+// back to the current identifiers: updates run unconditionally, so the target of a+// force-update with an unknown latest is wherever the pull lands — recording the+// current version keeps the resume check able to recognize a same-image recreation+// as success instead of finalizing it as failed.func updateAllTargetVersionInternal(info *version.Info) string {if info == nil {return ""@@ -917,7 +917,13 @@ func updateAllTargetVersionInternal(info *version.Info) string {if info.NewestVersion != "" {return info.NewestVersion}- return info.NewestDigest+ if info.NewestDigest != "" {+ return info.NewestDigest+ }+ if info.CurrentVersion != "" {+ return info.CurrentVersion+ }+ return info.CurrentDigest}func truncateUpdateAllErrorInternal(err error) string {diff --git a/backend/internal/services/system_upgrade_update_all_test.go b/backend/internal/services/system_upgrade_update_all_test.goindex 84c115188..675f5ebab 100644--- a/backend/internal/services/system_upgrade_update_all_test.go+++ b/backend/internal/services/system_upgrade_update_all_test.go@@ -7,6 +7,7 @@ import ("github.com/getarcaneapp/arcane/backend/v2/internal/database""github.com/getarcaneapp/arcane/backend/v2/internal/models"+ "github.com/getarcaneapp/arcane/types/v2/version"sqlite "github.com/libtnb/sqlite""github.com/stretchr/testify/require""gorm.io/gorm"@@ -60,6 +61,17 @@ func TestUpdateAllResolveResumeAction(t *testing.T) {currentDigest: "sha256:a",wantManagerOK: false,},+ {+ name: "unchanged but already on target means force-update succeeded",+ job: func() *models.EnvironmentUpdateJob {+ job := newJob(now.Add(-5*time.Minute), "1.0.0", "sha256:a")+ job.ManagerTargetVersion = "v1.0.0"+ return job+ }(),+ currentVersion: "1.0.0",+ currentDigest: "sha256:a",+ wantManagerOK: true,+ },}for _, tt := range tests {@@ -75,6 +87,15 @@ func TestUpdateAllResolveResumeAction(t *testing.T) {}}+// A force-update with an unknown latest (offline or rate-limited version check)+// must still record a target — the current identifiers — so the resume check can+// recognize a same-image recreation as success instead of finalizing it as failed.+func TestUpdateAllTargetVersionFallsBackToCurrent(t *testing.T) {+ require.Equal(t, "v2.0.0", updateAllTargetVersionInternal(&version.Info{NewestVersion: "v2.0.0", CurrentVersion: "v1.2.3"}))+ require.Equal(t, "v1.2.3", updateAllTargetVersionInternal(&version.Info{CurrentVersion: "v1.2.3", CurrentDigest: "sha256:a"}))+ require.Equal(t, "sha256:a", updateAllTargetVersionInternal(&version.Info{CurrentDigest: "sha256:a"}))+}+func TestUpsertPendingResult(t *testing.T) {job := &models.EnvironmentUpdateJob{Results: models.EnvironmentUpdateResults{@@ -123,7 +144,7 @@ func TestUpdateAllFailedJobMarksUpdatingResultsFailed(t *testing.T) {UserID: "user-1",Username: "arcane",Results: models.EnvironmentUpdateResults{- {EnvironmentID: "0", EnvironmentName: "Local", Status: models.EnvironmentUpdateResultStatusSkippedUpToDate},+ {EnvironmentID: "0", EnvironmentName: "Local", Status: models.EnvironmentUpdateResultStatusUpdated},{EnvironmentID: "remote-1", EnvironmentName: "palladium", Status: models.EnvironmentUpdateResultStatusUpdating},{EnvironmentID: "remote-2", EnvironmentName: "oracle-cloud", Status: models.EnvironmentUpdateResultStatusPending},{EnvironmentID: "remote-3", EnvironmentName: "parquetide", Status: models.EnvironmentUpdateResultStatusFailed, Error: "already failed"},@@ -142,7 +163,7 @@ func TestUpdateAllFailedJobMarksUpdatingResultsFailed(t *testing.T) {require.NotNil(t, got.CompletedAt)require.Len(t, got.Results, 4)- require.Equal(t, models.EnvironmentUpdateResultStatusSkippedUpToDate, got.Results[0].Status)+ require.Equal(t, models.EnvironmentUpdateResultStatusUpdated, got.Results[0].Status)require.Empty(t, got.Results[0].Error)require.Equal(t, models.EnvironmentUpdateResultStatusFailed, got.Results[1].Status)@@ -180,7 +201,7 @@ func TestResumeUpdateAllFinalizesManagerWithoutRerunningAgents(t *testing.T) {Results: models.EnvironmentUpdateResults{{EnvironmentID: "0", EnvironmentName: "Local", Status: models.EnvironmentUpdateResultStatusUpdating},{EnvironmentID: "remote-1", EnvironmentName: "palladium", Status: models.EnvironmentUpdateResultStatusUpdated},- {EnvironmentID: "remote-2", EnvironmentName: "oracle-cloud", Status: models.EnvironmentUpdateResultStatusSkippedUpToDate},+ {EnvironmentID: "remote-2", EnvironmentName: "oracle-cloud", Status: models.EnvironmentUpdateResultStatusSkippedOffline},},}require.NoError(t, db.WithContext(ctx).Create(job).Error)@@ -202,5 +223,5 @@ func TestResumeUpdateAllFinalizesManagerWithoutRerunningAgents(t *testing.T) {// Remote rows are untouched — proving the agents phase was NOT re-run on resume.require.Equal(t, models.EnvironmentUpdateResultStatusUpdated, got.Results[1].Status)- require.Equal(t, models.EnvironmentUpdateResultStatusSkippedUpToDate, got.Results[2].Status)+ require.Equal(t, models.EnvironmentUpdateResultStatusSkippedOffline, got.Results[2].Status)}diff --git a/frontend/messages/en.json b/frontend/messages/en.jsonindex 5a8c3dde9..eb52d7d7a 100644--- a/frontend/messages/en.json+++ b/frontend/messages/en.json@@ -1429,7 +1429,7 @@"environments_download_edge_ca_failed": "Failed to download Edge CA","environments_update_all_button": "Update All","environments_update_all_title": "Update all environments",- "environments_update_all_message": "This upgrades Arcane itself on every environment, starting with this manager. The manager will restart if an update is available; environments that are offline or already up to date are skipped.",+ "environments_update_all_message": "This pulls the latest Arcane image and updates every environment, whether or not an update is reported. Agents update first, then this manager, which will restart. Offline environments are skipped.","environments_update_all_confirm": "Update All","environments_update_all_manager_restarting": "Manager is restarting, reconnecting…","environments_update_all_in_progress": "Updating environments…",@@ -1441,7 +1441,6 @@"environments_update_all_status_updating": "Updating…","environments_update_all_status_updated": "Updated","environments_update_all_status_triggered": "Update triggered",- "environments_update_all_status_skipped_up_to_date": "Already up to date","environments_update_all_status_skipped_offline": "Offline — skipped","environments_update_all_status_failed": "Failed","environments_edge_control_plane_label": "Control Plane",diff --git a/frontend/src/routes/(app)/environments/update-all-dialog.svelte b/frontend/src/lib/components/dialogs/update-all-dialog.sveltesimilarity index 65%rename from frontend/src/routes/(app)/environments/update-all-dialog.svelterename to frontend/src/lib/components/dialogs/update-all-dialog.svelteindex 97b61ff5e..10d671879 100644--- a/frontend/src/routes/(app)/environments/update-all-dialog.svelte+++ b/frontend/src/lib/components/dialogs/update-all-dialog.svelte@@ -11,12 +11,25 @@type UpdateAllJob,type UpdateAllEnvironmentStatus} from '$lib/services/api/system-upgrade-service';- import { SuccessIcon, CheckIcon, ClockIcon, AlertIcon, AlertTriangleIcon } from '$lib/icons';+ import { SuccessIcon, ClockIcon, AlertIcon, AlertTriangleIcon, ExternalLinkIcon } from '$lib/icons';import BaseAPIService from '$lib/services/api-service';+ import ReleaseNotes from '$lib/components/release-notes.svelte';+ import type { AppVersionInformation } from '$lib/types/settings';+ import { formatDistanceToNow } from 'date-fns';// open has no $bindable fallback: upstream binds can start out undefined, and// binding undefined to a $bindable with a fallback throws props_invalid_value.- let { open = $bindable(undefined), onFinished }: { open?: boolean; onFinished?: () => void | Promise<void> } = $props();+ let {+ open = $bindable(undefined),+ versionInformation,+ canConfirm = true,+ onFinished+ }: {+ open?: boolean;+ versionInformation?: AppVersionInformation;+ canConfirm?: boolean;+ onFinished?: () => void | Promise<void>;+ } = $props();type Phase = 'confirm' | 'running' | 'finished';@@ -116,6 +129,24 @@BaseAPIService.setUpgradeInProgress(false);});+ // Version/release presentation for the confirm step, rendered when the caller+ // has the manager's version information at hand (sidebar / mobile nav).+ const isSemver = $derived(!!versionInformation?.isSemverVersion);+ const trackingTag = $derived(versionInformation?.currentTag ?? '');+ const currentDigest = $derived(versionInformation?.currentDigest ?? '');+ const newDigest = $derived(versionInformation?.newestDigest ?? '');+ const semverCurrent = $derived(versionInformation?.displayVersion || versionInformation?.currentVersion || '');+ const semverNew = $derived(versionInformation?.newestVersion ?? '');+ const releaseNotes = $derived(versionInformation?.releaseNotes?.trim() ?? '');+ const releaseUrl = $derived(versionInformation?.releaseUrl ?? '');+ const releasedAgo = $derived.by(() => {+ const at = versionInformation?.releasedAt;+ if (!at) return '';+ const date = new Date(at);+ if (Number.isNaN(date.getTime())) return '';+ return formatDistanceToNow(date, { addSuffix: true });+ });+const title = $derived.by(() => {if (phase === 'confirm') return m.environments_update_all_title();if (phase === 'finished') {@@ -138,8 +169,6 @@return m.environments_update_all_status_updated();case 'triggered':return m.environments_update_all_status_triggered();- case 'skipped_up_to_date':- return m.environments_update_all_status_skipped_up_to_date();case 'skipped_offline':return m.environments_update_all_status_skipped_offline();case 'failed':@@ -172,6 +201,93 @@{/if}</Dialog.Header>+ {#if phase === 'confirm' && versionInformation}+ <div class="space-y-4">+ {#if isSemver && (semverCurrent || semverNew)}+ <div class="flex flex-wrap items-center gap-2 text-sm">+ {#if semverCurrent}+ <span class="bg-muted text-muted-foreground inline-flex items-center rounded-md px-2 py-0.5 font-mono text-xs">+ {semverCurrent}+ </span>+ {/if}+ {#if semverCurrent && semverNew}+ <span class="text-muted-foreground/60">→</span>+ {/if}+ {#if semverNew}+ <span+ class="bg-primary/10 text-primary inline-flex items-center rounded-md px-2 py-0.5 font-mono text-xs font-medium"+ >+ {semverNew}+ </span>+ {/if}+ {#if releasedAgo}+ <span class="text-muted-foreground/70 text-xs">· {m.update_center_released_at({ date: releasedAgo })}</span>+ {/if}+ </div>+ {:else if !isSemver && (trackingTag || currentDigest || newDigest)}+ <div class="space-y-1.5 text-xs">+ {#if trackingTag}+ <div class="flex items-baseline gap-2">+ <span class="text-muted-foreground/70 w-16 shrink-0 tracking-wide uppercase">{m.update_center_tag_label()}</span>+ <span class="bg-muted text-foreground inline-flex items-center rounded-md px-2 py-0.5 font-mono">+ {trackingTag}+ </span>+ </div>+ {/if}+ {#if currentDigest}+ <div class="flex items-baseline gap-2">+ <span class="text-muted-foreground/70 w-16 shrink-0 tracking-wide uppercase"+ >{m.update_center_current_label()}</span+ >+ <code+ class="text-muted-foreground bg-muted/50 min-w-0 flex-1 rounded-md px-2 py-1 font-mono text-[11px] break-all"+ >+ {currentDigest}+ </code>+ </div>+ {/if}+ {#if newDigest}+ <div class="flex items-baseline gap-2">+ <span class="text-primary/80 w-16 shrink-0 tracking-wide uppercase">{m.update_center_new_label()}</span>+ <code+ class="text-primary bg-primary/10 min-w-0 flex-1 rounded-md px-2 py-1 font-mono text-[11px] font-medium break-all"+ >+ {newDigest}+ </code>+ </div>+ {/if}+ {#if releasedAgo}+ <p class="text-muted-foreground/70 pt-1">{m.update_center_released_at({ date: releasedAgo })}</p>+ {/if}+ </div>+ {/if}++ <div class="border-border/60 border-t pt-3">+ <div class="flex items-center justify-between pb-2">+ <h3 class="text-foreground text-sm font-semibold">{m.update_center_whats_new()}</h3>+ {#if releaseUrl}+ <a+ href={releaseUrl}+ target="_blank"+ rel="noopener noreferrer"+ class="text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors"+ >+ {m.update_center_view_full_release()}+ <ExternalLinkIcon class="size-3" />+ </a>+ {/if}+ </div>+ <ScrollArea.Root class="h-[220px]">+ {#if releaseNotes}+ <ReleaseNotes markdown={releaseNotes} />+ {:else}+ <p class="text-muted-foreground text-sm italic">{m.update_center_release_notes_unavailable()}</p>+ {/if}+ </ScrollArea.Root>+ </div>+ </div>+ {/if}+{#if phase !== 'confirm'}<div class="space-y-3">{#if reconnecting}@@ -203,7 +319,6 @@(result.status === 'updated' || result.status === 'triggered') &&'border-green-500/40 bg-green-500/10 text-green-600 dark:text-green-400',result.status === 'updating' && 'border-primary/40 bg-primary/10 text-primary',- result.status === 'skipped_up_to_date' && 'border-border bg-muted/40 text-muted-foreground',result.status === 'skipped_offline' &&'border-amber-500/40 bg-amber-500/10 text-amber-600 dark:text-amber-400',result.status === 'failed' && 'border-destructive/40 bg-destructive/10 text-destructive',@@ -214,8 +329,6 @@<SuccessIcon class="size-3.5" />{:else if result.status === 'updating'}<Spinner class="size-3.5" />- {:else if result.status === 'skipped_up_to_date'}- <CheckIcon class="size-3.5" />{:else if result.status === 'skipped_offline'}<AlertIcon class="size-3.5" />{:else if result.status === 'failed'}@@ -262,7 +375,9 @@<Dialog.Footer>{#if phase === 'confirm'}<Button variant="outline" onclick={() => (open = false)}>{m.common_cancel()}</Button>- <Button onclick={handleConfirm}>{m.environments_update_all_confirm()}</Button>+ {#if canConfirm}+ <Button onclick={handleConfirm}>{m.environments_update_all_confirm()}</Button>+ {/if}{:else}<Button variant="outline" onclick={handleClose}>{m.common_close()}</Button>{/if}diff --git a/frontend/src/lib/components/dialogs/update-center-dialog.svelte b/frontend/src/lib/components/dialogs/update-center-dialog.svelteindex f548e8929..3a3e9a236 100644--- a/frontend/src/lib/components/dialogs/update-center-dialog.svelte+++ b/frontend/src/lib/components/dialogs/update-center-dialog.svelte@@ -12,9 +12,8 @@import { ExternalLinkIcon, SuccessIcon } from '$lib/icons';import type { AppVersionInformation } from '$lib/types/settings';import { createQuery, useQueryClient } from '@tanstack/svelte-query';- import { marked } from 'marked';- import DOMPurify from 'isomorphic-dompurify';import { formatDistanceToNow } from 'date-fns';+ import ReleaseNotes from '$lib/components/release-notes.svelte';// open/upgrading have no $bindable fallback: upstream binds can start out// undefined, and binding undefined to a $bindable with a fallback throws@@ -97,19 +96,6 @@const effectiveReleasedAt = $derived(versionInformation?.releasedAt || debugRelease?.publishedAt || '');const effectiveReleaseUrl = $derived(versionInformation?.releaseUrl || debugRelease?.url || '');- const releaseNotesHtml = $derived.by(() => {- const raw = effectiveReleaseNotes;- if (!raw) return '';- try {- const html = marked.parse(raw, { async: false }) as string;- return DOMPurify.sanitize(html, {- ADD_ATTR: ['target', 'rel']- });- } catch {- return '';- }- });-const releasedAgo = $derived.by(() => {const at = effectiveReleasedAt;if (!at) return '';@@ -654,11 +640,8 @@</div><ScrollArea.Root class="h-[260px] px-6 pb-4">- {#if releaseNotesHtml}- <div class="release-notes text-sm leading-relaxed">- <!-- eslint-disable-next-line svelte/no-at-html-tags -->- {@html releaseNotesHtml}- </div>+ {#if effectiveReleaseNotes}+ <ReleaseNotes markdown={effectiveReleaseNotes} />{:else if debug && debugFetching}<div class="text-muted-foreground flex items-center gap-2 text-sm"><Spinner class="size-3.5" />@@ -691,89 +674,3 @@{/if}</Dialog.Content></Dialog.Root>--<style>- .release-notes :global(h1),- .release-notes :global(h2),- .release-notes :global(h3) {- font-weight: 600;- margin-top: 1rem;- margin-bottom: 0.5rem;- color: var(--foreground);- }- .release-notes :global(h1) {- font-size: 1rem;- }- .release-notes :global(h2) {- font-size: 0.95rem;- }- .release-notes :global(h3) {- font-size: 0.9rem;- }- .release-notes :global(h1:first-child),- .release-notes :global(h2:first-child),- .release-notes :global(h3:first-child) {- margin-top: 0;- }- .release-notes :global(p) {- margin: 0.5rem 0;- }- .release-notes :global(ul),- .release-notes :global(ol) {- margin: 0.5rem 0;- padding-left: 1.25rem;- }- .release-notes :global(ul) {- list-style: disc;- }- .release-notes :global(ol) {- list-style: decimal;- }- .release-notes :global(li) {- margin: 0.25rem 0;- }- .release-notes :global(li > p) {- margin: 0;- }- .release-notes :global(a) {- color: var(--primary);- text-decoration: underline;- text-underline-offset: 2px;- }- .release-notes :global(a:hover) {- opacity: 0.85;- }- .release-notes :global(code) {- background: var(--muted);- color: var(--foreground);- padding: 0.1em 0.35em;- border-radius: 0.25rem;- font-size: 0.85em;- font-family: ui-monospace, SFMono-Regular, monospace;- }- .release-notes :global(pre) {- background: var(--muted);- padding: 0.75rem;- border-radius: 0.5rem;- overflow-x: auto;- margin: 0.5rem 0;- }- .release-notes :global(pre code) {- background: transparent;- padding: 0;- }- .release-notes :global(blockquote) {- border-left: 2px solid var(--border);- padding-left: 0.75rem;- color: var(--muted-foreground);- margin: 0.5rem 0;- }- .release-notes :global(hr) {- border: 0;- border-top: 1px solid var(--border);- margin: 1rem 0;- }- .release-notes :global(strong) {- font-weight: 600;- }-</style>diff --git a/frontend/src/lib/components/mobile-nav/mobile-nav-sheet.svelte b/frontend/src/lib/components/mobile-nav/mobile-nav-sheet.svelteindex 96c27d460..b2f1e9903 100644--- a/frontend/src/lib/components/mobile-nav/mobile-nav-sheet.svelte+++ b/frontend/src/lib/components/mobile-nav/mobile-nav-sheet.svelte@@ -9,7 +9,7 @@import MobileUserCard from './mobile-user-card.svelte';import ActivityCenterTrigger from '$lib/components/activity/activity-center-trigger.svelte';import * as Drawer from '$lib/components/ui/drawer/index.js';- import UpdateCenterDialog from '$lib/components/dialogs/update-center-dialog.svelte';+ import UpdateAllDialog from '$lib/components/dialogs/update-all-dialog.svelte';import { useUpgradeCheck } from '$lib/hooks/use-upgrade-check.svelte';import UpdateAvailableBanner from '$lib/components/sidebar/update-available-banner.svelte';import type { AppVersionInformation } from '$lib/types/settings';@@ -192,7 +192,7 @@class="mt-3 rounded-xl px-3 py-2.5"label={m.sidebar_update_available()}versionChip={upgradeCheck.versionChip}- disabled={upgradeCheck.upgrading || upgradeCheck.checkingUpgrade}+ disabled={upgradeCheck.checkingUpgrade}onclick={upgradeCheck.openDialog}/>{/if}@@ -201,14 +201,7 @@</Drawer.Content></Drawer.Root>-<UpdateCenterDialog- bind:open={upgradeCheck.showConfirmDialog}- bind:upgrading={upgradeCheck.upgrading}- {versionInformation}- canInstall={upgradeCheck.shouldShowUpgrade}- {debug}- onConfirm={upgradeCheck.confirmUpgrade}-/>+<UpdateAllDialog bind:open={upgradeCheck.showConfirmDialog} {versionInformation} canConfirm={upgradeCheck.shouldShowUpgrade} /><style>:global(.scrollbar-hide) {diff --git a/frontend/src/lib/components/release-notes.svelte b/frontend/src/lib/components/release-notes.sveltenew file mode 100644index 000000000..4de01d854--- /dev/null+++ b/frontend/src/lib/components/release-notes.svelte@@ -0,0 +1,111 @@+<script lang="ts">+ import { marked } from 'marked';+ import DOMPurify from 'isomorphic-dompurify';++ let { markdown }: { markdown: string } = $props();++ const html = $derived.by(() => {+ if (!markdown) return '';+ try {+ const parsed = marked.parse(markdown, { async: false }) as string;+ return DOMPurify.sanitize(parsed, {+ ADD_ATTR: ['target', 'rel']+ });+ } catch {+ return '';+ }+ });+</script>++{#if html}+ <div class="release-notes text-sm leading-relaxed">+ <!-- eslint-disable-next-line svelte/no-at-html-tags -->+ {@html html}+ </div>+{/if}++<style>+ .release-notes :global(h1),+ .release-notes :global(h2),+ .release-notes :global(h3) {+ font-weight: 600;+ margin-top: 1rem;+ margin-bottom: 0.5rem;+ color: var(--foreground);+ }+ .release-notes :global(h1) {+ font-size: 1rem;+ }+ .release-notes :global(h2) {+ font-size: 0.95rem;+ }+ .release-notes :global(h3) {+ font-size: 0.9rem;+ }+ .release-notes :global(h1:first-child),+ .release-notes :global(h2:first-child),+ .release-notes :global(h3:first-child) {+ margin-top: 0;+ }+ .release-notes :global(p) {+ margin: 0.5rem 0;+ }+ .release-notes :global(ul),+ .release-notes :global(ol) {+ margin: 0.5rem 0;+ padding-left: 1.25rem;+ }+ .release-notes :global(ul) {+ list-style: disc;+ }+ .release-notes :global(ol) {+ list-style: decimal;+ }+ .release-notes :global(li) {+ margin: 0.25rem 0;+ }+ .release-notes :global(li > p) {+ margin: 0;+ }+ .release-notes :global(a) {+ color: var(--primary);+ text-decoration: underline;+ text-underline-offset: 2px;+ }+ .release-notes :global(a:hover) {+ opacity: 0.85;+ }+ .release-notes :global(code) {+ background: var(--muted);+ color: var(--foreground);+ padding: 0.1em 0.35em;+ border-radius: 0.25rem;+ font-size: 0.85em;+ font-family: ui-monospace, SFMono-Regular, monospace;+ }+ .release-notes :global(pre) {+ background: var(--muted);+ padding: 0.75rem;+ border-radius: 0.5rem;+ overflow-x: auto;+ margin: 0.5rem 0;+ }+ .release-notes :global(pre code) {+ background: transparent;+ padding: 0;+ }+ .release-notes :global(blockquote) {+ border-left: 2px solid var(--border);+ padding-left: 0.75rem;+ color: var(--muted-foreground);+ margin: 0.5rem 0;+ }+ .release-notes :global(hr) {+ border: 0;+ border-top: 1px solid var(--border);+ margin: 1rem 0;+ }+ .release-notes :global(strong) {+ font-weight: 600;+ }+</style>diff --git a/frontend/src/lib/components/sidebar/sidebar-updatebanner.svelte b/frontend/src/lib/components/sidebar/sidebar-updatebanner.svelteindex 911fdfa26..5b827537b 100644--- a/frontend/src/lib/components/sidebar/sidebar-updatebanner.svelte+++ b/frontend/src/lib/components/sidebar/sidebar-updatebanner.svelte@@ -5,7 +5,7 @@import { useSidebar } from '$lib/components/ui/sidebar/index.js';import type { AppVersionInformation } from '$lib/types/settings';import { m } from '$lib/paraglide/messages';- import UpdateCenterDialog from '$lib/components/dialogs/update-center-dialog.svelte';+ import UpdateAllDialog from '$lib/components/dialogs/update-all-dialog.svelte';import { DownloadIcon } from '$lib/icons';import { useUpgradeCheck } from '$lib/hooks/use-upgrade-check.svelte';import UpdateAvailableBanner from './update-available-banner.svelte';@@ -34,14 +34,7 @@);</script>-<UpdateCenterDialog- bind:open={upgradeCheck.showConfirmDialog}- bind:upgrading={upgradeCheck.upgrading}- {versionInformation}- canInstall={upgradeCheck.shouldShowUpgrade}- {debug}- onConfirm={upgradeCheck.confirmUpgrade}-/>+<UpdateAllDialog bind:open={upgradeCheck.showConfirmDialog} {versionInformation} canConfirm={upgradeCheck.shouldShowUpgrade} />{#if upgradeCheck.shouldShowBanner}<div class={cn('pb-2', isCollapsed ? 'px-1' : 'px-3')}>@@ -52,7 +45,7 @@class="rounded-lg px-2.5 py-2"label={m.sidebar_update_available()}versionChip={upgradeCheck.versionChip}- disabled={upgradeCheck.upgrading || upgradeCheck.checkingUpgrade}+ disabled={upgradeCheck.checkingUpgrade}onclick={upgradeCheck.openDialog}/>{:else}@@ -61,7 +54,7 @@{#snippet child({ props })}<buttononclick={upgradeCheck.openDialog}- disabled={upgradeCheck.upgrading || upgradeCheck.checkingUpgrade}+ disabled={upgradeCheck.checkingUpgrade}class="hover:bg-muted/60 focus-visible:ring-primary/40 relative mx-auto flex size-8 items-center justify-center rounded-lg transition-colors focus-visible:ring-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-60"{...props}>diff --git a/frontend/src/lib/hooks/use-upgrade-check.svelte.ts b/frontend/src/lib/hooks/use-upgrade-check.svelte.tsindex 41c2d0009..0eb5c1bc4 100644--- a/frontend/src/lib/hooks/use-upgrade-check.svelte.ts+++ b/frontend/src/lib/hooks/use-upgrade-check.svelte.ts@@ -1,11 +1,8 @@-import { m } from '$lib/paraglide/messages';import { queryKeys } from '$lib/query/query-keys';import systemUpgradeService from '$lib/services/api/system-upgrade-service';import type { AppVersionInformation } from '$lib/types/settings';-import { extractApiErrorMessage } from '$lib/utils/api';import { hasPermission } from '$lib/utils/auth';-import { createMutation, createQuery } from '@tanstack/svelte-query';-import { toast } from 'svelte-sonner';+import { createQuery } from '@tanstack/svelte-query';type UseUpgradeCheckOptions = {queryScope: 'mobile-nav' | 'sidebar';@@ -14,10 +11,10 @@ type UseUpgradeCheckOptions = {};export function useUpgradeCheck({ queryScope, getVersionInformation, getDebug = () => false }: UseUpgradeCheckOptions) {- let upgrading = $state(false);let showConfirmDialog = $state(false);- const canInstallUpdates = $derived(hasPermission('environments:update'));+ // Same permission the update-all endpoint enforces (PermSystemUpgrade).+ const canInstallUpdates = $derived(hasPermission('system:upgrade'));const shouldCheckUpgrade = $derived(!!(getVersionInformation()?.updateAvailable && canInstallUpdates && !getDebug()));const upgradeAvailabilityQuery = createQuery(() => ({queryKey: queryKeys.system.upgradeAvailable(queryScope),@@ -53,31 +50,12 @@ export function useUpgradeCheck({ queryScope, getVersionInformation, getDebug =});const shouldShowBanner = $derived(getVersionInformation()?.updateAvailable || getDebug());- const triggerUpgradeMutation = createMutation(() => ({- mutationFn: () => systemUpgradeService.triggerUpgrade(),- onError: (error: unknown) => {- const errorMessage = extractApiErrorMessage(error);- const wrappedPrefix = m.upgrade_failed({ error: '' });- toast.error(errorMessage.startsWith(wrappedPrefix) ? errorMessage : m.upgrade_failed({ error: errorMessage }));- upgrading = false;- }- }));function openDialog() {showConfirmDialog = true;}- function confirmUpgrade() {- triggerUpgradeMutation.mutate();- }-return {- get upgrading() {- return upgrading;- },- set upgrading(value: boolean) {- upgrading = value;- },get showConfirmDialog() {return showConfirmDialog;},@@ -99,7 +77,6 @@ export function useUpgradeCheck({ queryScope, getVersionInformation, getDebug =get shouldShowBanner() {return shouldShowBanner;},- openDialog,- confirmUpgrade+ openDialog};}diff --git a/frontend/src/lib/services/api/system-upgrade-service.ts b/frontend/src/lib/services/api/system-upgrade-service.tsindex cc7feaf75..6c931e616 100644--- a/frontend/src/lib/services/api/system-upgrade-service.ts+++ b/frontend/src/lib/services/api/system-upgrade-service.ts@@ -17,8 +17,7 @@ export interface HealthCheckResult {healthy: boolean;}-export type UpdateAllEnvironmentStatus =- 'pending' | 'updating' | 'updated' | 'triggered' | 'skipped_up_to_date' | 'skipped_offline' | 'failed';+export type UpdateAllEnvironmentStatus = 'pending' | 'updating' | 'updated' | 'triggered' | 'skipped_offline' | 'failed';export interface UpdateAllEnvironmentResult {environmentId: string;diff --git a/frontend/src/routes/(app)/environments/+page.svelte b/frontend/src/routes/(app)/environments/+page.svelteindex 1a22a5e40..646b2a4f4 100644--- a/frontend/src/routes/(app)/environments/+page.svelte+++ b/frontend/src/routes/(app)/environments/+page.svelte@@ -13,7 +13,7 @@import { simpleRefresh } from '$lib/utils/api';import { hasPermission } from '$lib/utils/auth';import { DownloadIcon, UpdateIcon } from '$lib/icons';- import UpdateAllDialog from './update-all-dialog.svelte';+ import UpdateAllDialog from '$lib/components/dialogs/update-all-dialog.svelte';let { data } = $props();