Skip to content

Modern Docker Management, Designed for Everyone

refactor: update sidebar update item (#4003)

Kyle Mendell476d8b17fc4f
diff --git a/backend/api/api.go b/backend/api/api.go
index 5e292f499..3e683d631 100644
--- a/backend/api/api.go
+++ b/backend/api/api.go
@@ -449,5 +449,5 @@ func registerHandlersInternal(api huma.API, deps HandlerDeps, handlerAppCtx hand
deps.Webhook.RegisterRoutes(api)
deps.Vulnerability.RegisterRoutes(api, handlerAppCtx)
deps.Dashboard.RegisterRoutes(api)
- handlers.RegisterStream(api, deps.Dashboard.Handler(), deps.Activity.Handler(), deps.Environment.Handler(), deps.Event.Service())
+ handlers.RegisterStream(api, deps.Dashboard.Handler(), deps.Activity.Handler(), deps.Environment.Handler(), deps.Event.Service(), deps.Version)
}
diff --git a/backend/api/handlers/stream.go b/backend/api/handlers/stream.go
index 326433a82..266d37221 100644
--- a/backend/api/handlers/stream.go
+++ b/backend/api/handlers/stream.go
@@ -14,6 +14,7 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/internal/environment"
"github.com/getarcaneapp/arcane/backend/v2/internal/event"
"github.com/getarcaneapp/arcane/backend/v2/internal/middleware"
+ "github.com/getarcaneapp/arcane/backend/v2/internal/version"
"github.com/getarcaneapp/arcane/backend/v2/pkg/authz"
"github.com/getarcaneapp/arcane/backend/v2/pkg/utils/handlerutil"
"github.com/getarcaneapp/arcane/backend/v2/pkg/utils/httpx"
@@ -22,6 +23,7 @@ import (
environmenttypes "github.com/getarcaneapp/arcane/types/v2/environment"
eventtypes "github.com/getarcaneapp/arcane/types/v2/event"
streamtypes "github.com/getarcaneapp/arcane/types/v2/stream"
+ versiontypes "github.com/getarcaneapp/arcane/types/v2/version"
"go.getarcane.app/streams/agg"
)
@@ -42,10 +44,11 @@ type StreamHandler struct {
dashboard *dashboard.DashboardHandler
activity *activity.ActivityHandler
environment *environment.EnvironmentHandler
+ version *version.VersionService
}
type StreamClientInput struct {
- Channels string `query:"channels" doc:"Comma-separated channels to subscribe to: environments, dashboard, activities, events"`
+ Channels string `query:"channels" doc:"Comma-separated channels to subscribe to: environments, dashboard, activities, events, version"`
DebugAllGood bool `query:"debugAllGood" default:"false" doc:"Debug mode for the dashboard channel: force an empty action item list"`
Limit int `query:"limit" default:"0" doc:"Maximum activities to include in each activities-channel snapshot"`
}
@@ -59,12 +62,14 @@ func RegisterStream(
activityHandler *activity.ActivityHandler,
environmentHandler *environment.EnvironmentHandler,
eventService *event.EventService,
+ versionService *version.VersionService,
) {
h := &StreamHandler{
events: eventService,
dashboard: dashboardHandler,
activity: activityHandler,
environment: environmentHandler,
+ version: versionService,
}
huma.Register(api, huma.Operation{
@@ -72,7 +77,7 @@ func RegisterStream(
Method: http.MethodGet,
Path: "/stream",
Summary: "Multiplexed client stream",
- Description: "Streams the requested channels (environments, dashboard, activities, events) over a single JSON-lines connection",
+ Description: "Streams the requested channels (environments, dashboard, activities, events, version) over a single JSON-lines connection",
Tags: []string{"Stream"},
Security: handlerutil.DefaultOperationSecurity(),
// Ungated: each channel applies its own permission check below, and a
@@ -122,7 +127,7 @@ func (h *StreamHandler) streamClientInternal(ctx context.Context, ps *authz.Perm
// dropping any the caller lacks permission for.
func (h *StreamHandler) producersForInternal(ps *authz.PermissionSet, input *StreamClientInput) []agg.Producer[streamtypes.Event] {
requested := parseStreamChannelsInternal(input.Channels)
- producers := make([]agg.Producer[streamtypes.Event], 0, 4)
+ producers := make([]agg.Producer[streamtypes.Event], 0, 5)
if requested[streamtypes.ChannelEnvironments] {
// Ungated like listEnvironments; the producer filters to the caller's
@@ -191,11 +196,22 @@ func (h *StreamHandler) producersForInternal(ps *authz.PermissionSet, input *Str
h.events.RunStreamProducer,
))
}
+
+ if requested[streamtypes.ChannelVersion] {
+ // Ungated like GET /app-version.
+ producers = append(producers, forwardStreamChannelInternal(
+ streamtypes.ChannelVersion,
+ func(channel string, event versiontypes.StreamEvent) streamtypes.Event {
+ return streamtypes.Event{Channel: channel, Version: &event, Timestamp: event.Timestamp}
+ },
+ h.version.RunStreamProducer,
+ ))
+ }
return producers
}
func parseStreamChannelsInternal(raw string) map[string]bool {
- channels := make(map[string]bool, 4)
+ channels := make(map[string]bool, 5)
for name := range strings.SplitSeq(raw, ",") {
if trimmed := strings.TrimSpace(strings.ToLower(name)); trimmed != "" {
channels[trimmed] = true
diff --git a/backend/internal/version/service.go b/backend/internal/version/service.go
index f101a1750..bcd743d26 100644
--- a/backend/internal/version/service.go
+++ b/backend/internal/version/service.go
@@ -28,6 +28,7 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/pkg/utils"
"github.com/getarcaneapp/arcane/types/v2/version"
"github.com/samber/hot"
+ "go.getarcane.app/streams/agg"
"go.getarcane.app/sys/cgroup"
)
@@ -53,21 +54,23 @@ type VersionService struct {
dockerService *docker.DockerClientService
imageUpdateService *imageupdate.ImageUpdateService
settingsService *settings.SettingsService
+ streamHub *agg.Hub[version.StreamEvent]
}
-func NewVersionService(httpClient *http.Client, disabled bool, version string, revision string, containerRegistryService *registry.ContainerRegistryService, dockerService *docker.DockerClientService, imageUpdateService *imageupdate.ImageUpdateService, settingsService *settings.SettingsService) *VersionService {
+func NewVersionService(httpClient *http.Client, disabled bool, appVersion string, revision string, containerRegistryService *registry.ContainerRegistryService, dockerService *docker.DockerClientService, imageUpdateService *imageupdate.ImageUpdateService, settingsService *settings.SettingsService) *VersionService {
if httpClient == nil {
httpClient = http.DefaultClient
}
service := &VersionService{
httpClient: httpClient,
disabled: disabled,
- version: version,
+ version: appVersion,
revision: revision,
containerRegistryService: containerRegistryService,
dockerService: dockerService,
imageUpdateService: imageUpdateService,
settingsService: settingsService,
+ streamHub: agg.NewHub[version.StreamEvent](),
}
loader := func(_ []struct{}) (map[struct{}]latestRelease, error) {
ctx, cancel := context.WithTimeout(context.Background(), defaultRequestTimeout)
diff --git a/backend/internal/version/stream.go b/backend/internal/version/stream.go
new file mode 100644
index 000000000..9e281a3f2
--- /dev/null
+++ b/backend/internal/version/stream.go
@@ -0,0 +1,56 @@
+package version
+
+import (
+ "context"
+ "time"
+
+ "github.com/getarcaneapp/arcane/types/v2/version"
+ "go.getarcane.app/streams/agg"
+)
+
+const versionStreamPollInterval = 5 * time.Minute
+
+// RunStreamProducer shares one version poll loop across every connected client and emits a snapshot whenever it changes.
+func (s *VersionService) RunStreamProducer(ctx context.Context, events chan<- version.StreamEvent) {
+ s.streamHub.Subscribe(ctx, "local",
+ func(runCtx context.Context, publish func(version.StreamEvent)) {
+ var last *version.Info
+ poll := func() {
+ info := s.GetAppVersionInfo(runCtx)
+ if runCtx.Err() != nil {
+ return
+ }
+ if last != nil {
+ if last.UpdateAvailable == info.UpdateAvailable &&
+ last.NewestVersion == info.NewestVersion &&
+ last.NewestDigest == info.NewestDigest &&
+ last.CurrentTag == info.CurrentTag &&
+ last.CurrentDigest == info.CurrentDigest &&
+ last.ReleaseURL == info.ReleaseURL &&
+ last.ReleaseNotes == info.ReleaseNotes &&
+ last.ReleasedAt == info.ReleasedAt {
+ return
+ }
+ }
+ last = info
+ publish(version.StreamEvent{Type: "snapshot", Info: info, Timestamp: time.Now()})
+ }
+
+ poll()
+
+ ticker := time.NewTicker(versionStreamPollInterval)
+ defer ticker.Stop()
+
+ for {
+ select {
+ case <-runCtx.Done():
+ return
+ case <-ticker.C:
+ poll()
+ }
+ }
+ },
+ func(event version.StreamEvent) bool {
+ return agg.Send(ctx, events, event)
+ })
+}
diff --git a/frontend/src/lib/components/dialogs/update-all-dialog.svelte b/frontend/src/lib/components/dialogs/update-all-dialog.svelte
index e2388fca4..f9fc41d0d 100644
--- a/frontend/src/lib/components/dialogs/update-all-dialog.svelte
+++ b/frontend/src/lib/components/dialogs/update-all-dialog.svelte
@@ -2,7 +2,6 @@
import { tryCatch } from '#lib/utils/try-catch.js';
import * as Dialog from '#lib/components/ui/dialog/index.js';
- import * as ScrollArea from '#lib/components/ui/scroll-area/index.js';
import { Button } from '#lib/components/ui/button/index.js';
import Spinner from '#lib/components/ui/spinner/spinner.svelte';
import { cn } from '#lib/utils.js';
@@ -315,7 +314,10 @@
}}
>
<Dialog.Content
- class={cn('gap-0 overflow-hidden p-0 sm:max-w-[520px]', phase === 'running' && '[&>button]:hidden')}
+ class={cn(
+ 'flex max-h-[90dvh] flex-col gap-0 overflow-hidden p-0 sm:max-w-[520px]',
+ phase === 'running' && '[&>button]:hidden'
+ )}
onInteractOutside={(e: Event) => {
if (phase === 'running') e.preventDefault();
}}
@@ -332,7 +334,7 @@
</div>
{#if versionInformation}
- <div class="border-t border-border/60">
+ <div class="flex min-h-0 flex-1 flex-col border-t border-border/60">
<div class="flex items-center justify-between px-6 pt-4 pb-2">
<h3 class="text-sm font-semibold text-foreground">{m.update_center_whats_new()}</h3>
{#if releaseUrl}
@@ -347,13 +349,13 @@
</a>
{/if}
</div>
- <ScrollArea.Root class="h-[220px] px-6 pb-4">
+ <div class="min-h-0 flex-1 overflow-y-auto px-6 pb-4">
{#if releaseNotes}
<ReleaseNotes markdown={releaseNotes} />
{:else}
<p class="text-sm text-muted-foreground italic">{m.update_center_release_notes_unavailable()}</p>
{/if}
- </ScrollArea.Root>
+ </div>
</div>
{/if}
{:else}
diff --git a/frontend/src/lib/components/dialogs/update-center-dialog.svelte b/frontend/src/lib/components/dialogs/update-center-dialog.svelte
index a29216129..a710be112 100644
--- a/frontend/src/lib/components/dialogs/update-center-dialog.svelte
+++ b/frontend/src/lib/components/dialogs/update-center-dialog.svelte
@@ -2,7 +2,6 @@
import { tryCatch } from '#lib/utils/try-catch.js';
import * as Dialog from '#lib/components/ui/dialog/index.js';
- import * as ScrollArea from '#lib/components/ui/scroll-area/index.js';
import { ArcaneButton } from '#lib/components/arcane-button/index.js';
import Spinner from '#lib/components/ui/spinner/spinner.svelte';
import { m } from '#lib/paraglide/messages.js';
@@ -479,7 +478,7 @@
<Dialog.Root {open} onOpenChange={(nextOpen) => (open = nextOpen)}>
<Dialog.Content
- class={cn('gap-0 overflow-hidden p-0 sm:max-w-[560px]', upgrading && '[&>button]:hidden')}
+ class={cn('flex max-h-[90dvh] flex-col gap-0 overflow-hidden p-0 sm:max-w-[560px]', upgrading && '[&>button]:hidden')}
onInteractOutside={(e: Event) => {
if (upgrading) e.preventDefault();
}}
@@ -561,7 +560,7 @@
</Dialog.Header>
</div>
- <div class="border-t border-border/60">
+ <div class="flex min-h-0 flex-1 flex-col border-t border-border/60">
<div class="flex items-center justify-between px-6 pt-4 pb-2">
<h3 class="text-sm font-semibold text-foreground">{m.update_center_whats_new()}</h3>
{#if effectiveReleaseUrl}
@@ -577,7 +576,7 @@
{/if}
</div>
- <ScrollArea.Root class="h-[260px] px-6 pb-4">
+ <div class="min-h-0 flex-1 overflow-y-auto px-6 pb-4">
{#if effectiveReleaseNotes}
<ReleaseNotes markdown={effectiveReleaseNotes} />
{:else if debug && debugFetching}
@@ -594,7 +593,7 @@
{m.update_center_release_notes_unavailable()}
</p>
{/if}
- </ScrollArea.Root>
+ </div>
</div>
<div class="border-t border-border/60 bg-muted/30 px-6 py-3">
diff --git a/frontend/src/lib/components/mobile-nav/mobile-nav-sheet.svelte b/frontend/src/lib/components/mobile-nav/mobile-nav-sheet.svelte
index cd3aa9ef4..1ce4815ee 100644
--- a/frontend/src/lib/components/mobile-nav/mobile-nav-sheet.svelte
+++ b/frontend/src/lib/components/mobile-nav/mobile-nav-sheet.svelte
@@ -182,7 +182,7 @@
</div>
{#if upgradeCheck.shouldShowBanner}
<UpdateAvailableBanner
- class="mt-3 rounded-xl px-3 py-2.5"
+ class="mt-3 rounded-xl px-3 py-2"
label={m.sidebar_update_available()}
versionChip={upgradeCheck.versionChip}
disabled={upgradeCheck.checkingUpgrade}
diff --git a/frontend/src/lib/components/sidebar/sidebar-updatebanner.svelte b/frontend/src/lib/components/sidebar/sidebar-updatebanner.svelte
index ac91fda67..d1528707d 100644
--- a/frontend/src/lib/components/sidebar/sidebar-updatebanner.svelte
+++ b/frontend/src/lib/components/sidebar/sidebar-updatebanner.svelte
@@ -1,12 +1,11 @@
<script lang="ts">
import { cn } from '#lib/utils.js';
- import * as Separator from '#lib/components/ui/separator/index.js';
import * as Tooltip from '#lib/components/ui/tooltip/index.js';
import { useSidebar } from '#lib/components/ui/sidebar/index.js';
import type { AppVersionInformation } from '#lib/types/settings.js';
import { m } from '#lib/paraglide/messages.js';
import UpdateAllDialog from '#lib/components/dialogs/update-all-dialog.svelte';
- import { DownloadIcon } from '#lib/icons/index.js';
+ import { CircleArrowUpIcon } from '#lib/icons/index.js';
import { useUpgradeCheck } from '#lib/hooks/use-upgrade-check.svelte.js';
import UpdateAvailableBanner from './update-available-banner.svelte';
@@ -42,12 +41,9 @@
/>
{#if upgradeCheck.shouldShowBanner}
- <div class={cn('pb-2', isCollapsed ? 'px-1' : 'px-3')}>
- <Separator.Root class="mb-2 opacity-30" />
-
+ <div class={cn('pb-1', isCollapsed ? 'px-0' : 'px-3')}>
{#if !isCollapsed}
<UpdateAvailableBanner
- class="rounded-lg px-2.5 py-2"
label={m.sidebar_update_available()}
versionChip={upgradeCheck.versionChip}
disabled={upgradeCheck.checkingUpgrade}
@@ -60,14 +56,11 @@
<button
onclick={upgradeCheck.openDialog}
disabled={upgradeCheck.checkingUpgrade}
- class="relative mx-auto flex size-8 items-center justify-center rounded-lg transition-colors hover:bg-muted/60 focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-60"
+ class="relative mx-auto flex size-8 items-center justify-center rounded-md bg-primary/15 text-primary transition-colors hover:bg-primary/25 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-60"
{...props}
>
- <DownloadIcon class="size-4 text-foreground/80" />
- <span class="absolute top-1 right-1 flex size-2">
- <span class="absolute inline-flex size-2 animate-ping rounded-full bg-blue-500 opacity-70"></span>
- <span class="relative inline-flex size-2 rounded-full bg-blue-500 ring-2 ring-[var(--sidebar)]"></span>
- </span>
+ <CircleArrowUpIcon class="size-4 shrink-0" aria-hidden="true" />
+ <span class="absolute -top-0.5 -right-0.5 size-2 rounded-full bg-primary ring-2 ring-sidebar"></span>
</button>
{/snippet}
</Tooltip.Trigger>
diff --git a/frontend/src/lib/components/sidebar/update-available-banner.svelte b/frontend/src/lib/components/sidebar/update-available-banner.svelte
index 843a26f52..040e9ddb7 100644
--- a/frontend/src/lib/components/sidebar/update-available-banner.svelte
+++ b/frontend/src/lib/components/sidebar/update-available-banner.svelte
@@ -1,5 +1,6 @@
<script lang="ts">
import { cn } from '#lib/utils.js';
+ import { ArrowRightIcon, CircleArrowUpIcon } from '#lib/icons/index.js';
let {
label,
@@ -21,20 +22,21 @@
{onclick}
{disabled}
class={cn(
- 'group flex w-full items-center gap-2.5 text-left transition-colors hover:bg-muted/50 focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-60',
+ 'group flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-60',
className
)}
>
- <span class="relative flex size-2 shrink-0 items-center justify-center">
- <span class="absolute inline-flex size-2 animate-ping rounded-full bg-blue-500 opacity-60"></span>
- <span class="relative inline-flex size-1.5 rounded-full bg-blue-500"></span>
+ <span class="flex size-6 shrink-0 items-center justify-center rounded-md bg-primary/15 text-primary">
+ <CircleArrowUpIcon class="size-3.5 shrink-0" aria-hidden="true" />
</span>
- <span class="flex-1 text-sm font-medium text-foreground">
- {label}
+ <span class="grid min-w-0 flex-1 leading-tight">
+ <span class="truncate text-xs font-medium">{label}</span>
+ {#if versionChip}
+ <span class="truncate text-[11px] text-muted-foreground tabular-nums">{versionChip}</span>
+ {/if}
</span>
- {#if versionChip}
- <span class="rounded-md bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground">
- {versionChip}
- </span>
- {/if}
+ <ArrowRightIcon
+ class="size-3.5 shrink-0 text-muted-foreground/50 transition-colors group-hover:text-foreground"
+ aria-hidden="true"
+ />
</button>
diff --git a/frontend/src/lib/hooks/use-upgrade-check.svelte.ts b/frontend/src/lib/hooks/use-upgrade-check.svelte.ts
index 70835ba07..504222efa 100644
--- a/frontend/src/lib/hooks/use-upgrade-check.svelte.ts
+++ b/frontend/src/lib/hooks/use-upgrade-check.svelte.ts
@@ -46,6 +46,7 @@ export function useUpgradeCheck({ queryScope, getVersionInformation, getDebug =
if (!versionInformation) return '';
if (updateType === 'semver') return versionInformation.newestVersion ?? '';
if (updateType === 'digest') return versionInformation.currentTag ?? '';
+ if (getDebug()) return versionInformation.displayVersion ?? '';
return '';
});
diff --git a/frontend/src/lib/services/auth-service.ts b/frontend/src/lib/services/auth-service.ts
index 9526286fe..cd7fe19d5 100644
--- a/frontend/src/lib/services/auth-service.ts
+++ b/frontend/src/lib/services/auth-service.ts
@@ -10,6 +10,7 @@ import { activityStore } from '#lib/stores/activity.store.svelte.js';
import { dashboardStore } from '#lib/stores/dashboard.store.svelte.js';
import { environmentStatusStore } from '#lib/stores/environment-status.store.svelte.js';
import { featureStore } from '#lib/stores/features.store.svelte.js';
+import { versionStore } from '#lib/stores/version.store.svelte.js';
import { getEffectiveLandingPage } from '#lib/utils/navigation.js';
import { parseInstant } from '#lib/utils/formatting.js';
import { Temporal } from 'temporal-polyfill';
@@ -230,12 +231,14 @@ class AuthService extends BaseAPIService {
const restartActivityStore = activityStore.stop({ resetState: true });
const restartDashboardStore = dashboardStore.stop({ resetState: true });
const restartEnvironmentStatusStore = environmentStatusStore.stop();
+ const restartVersionStore = versionStore.stop();
userStore.clearUser();
if (options?.restartMountedStores) {
if (restartActivityStore) void activityStore.start();
if (restartDashboardStore) void dashboardStore.start();
if (restartEnvironmentStatusStore) void environmentStatusStore.start();
+ if (restartVersionStore) versionStore.start();
}
}
diff --git a/frontend/src/lib/services/stream-service.ts b/frontend/src/lib/services/stream-service.ts
index 1499f34c3..e22944e4a 100644
--- a/frontend/src/lib/services/stream-service.ts
+++ b/frontend/src/lib/services/stream-service.ts
@@ -7,6 +7,7 @@ export const STREAM_CHANNEL_ENVIRONMENTS = 'environments';
export const STREAM_CHANNEL_DASHBOARD = 'dashboard';
export const STREAM_CHANNEL_ACTIVITIES = 'activities';
export const STREAM_CHANNEL_EVENTS = 'events';
+export const STREAM_CHANNEL_VERSION = 'version';
class StreamService extends BaseAPIService {
getClientStreamUrl(channels: string[], params: Record<string, string> = {}): string {
diff --git a/frontend/src/lib/services/version-service.ts b/frontend/src/lib/services/version-service.ts
index efb0038e2..86ac0468d 100644
--- a/frontend/src/lib/services/version-service.ts
+++ b/frontend/src/lib/services/version-service.ts
@@ -7,53 +7,39 @@ function getCurrentVersion() {
return currentVersion;
}
+export function toAppVersionInformation(data: Partial<AppVersionInformation>): AppVersionInformation {
+ return {
+ currentVersion: data.currentVersion || getCurrentVersion(),
+ currentTag: data.currentTag,
+ currentDigest: data.currentDigest,
+ displayVersion: data.displayVersion || data.currentVersion || getCurrentVersion(),
+ revision: data.revision || 'unknown',
+ shortRevision: data.shortRevision || data.revision?.slice(0, 8) || 'unknown',
+ goVersion: data.goVersion || 'unknown',
+ nodeVersion: data.nodeVersion || 'unknown',
+ svelteKitVersion: data.svelteKitVersion || 'unknown',
+ enabledFeatures: data.enabledFeatures ?? [],
+ buildTime: data.buildTime,
+ isSemverVersion: data.isSemverVersion || false,
+ newestVersion: data.newestVersion,
+ newestDigest: data.newestDigest,
+ updateAvailable: data.updateAvailable || false,
+ releaseUrl: data.releaseUrl,
+ releaseNotes: data.releaseNotes,
+ releasedAt: data.releasedAt
+ };
+}
+
async function getVersionInformation(): Promise<AppVersionInformation> {
const operationResult = await tryCatch(
(async () => {
const res = await apiClient.get('/app-version', {
timeout: 2000
});
- const data = res.data as Partial<AppVersionInformation>;
-
- return {
- currentVersion: data.currentVersion || getCurrentVersion(),
- currentTag: data.currentTag,
- currentDigest: data.currentDigest,
- displayVersion: data.displayVersion || data.currentVersion || getCurrentVersion(),
- revision: data.revision || 'unknown',
- shortRevision: data.shortRevision || data.revision?.slice(0, 8) || 'unknown',
- goVersion: data.goVersion || 'unknown',
- nodeVersion: data.nodeVersion || 'unknown',
- svelteKitVersion: data.svelteKitVersion || 'unknown',
- enabledFeatures: data.enabledFeatures ?? [],
- buildTime: data.buildTime,
- isSemverVersion: data.isSemverVersion || false,
- newestVersion: data.newestVersion,
- newestDigest: data.newestDigest,
- updateAvailable: data.updateAvailable || false,
- releaseUrl: data.releaseUrl,
- releaseNotes: data.releaseNotes,
- releasedAt: data.releasedAt
- };
+ return toAppVersionInformation(res.data as Partial<AppVersionInformation>);
})()
);
- if (operationResult.error !== null) {
- // Fallback to basic version info if app-version endpoint fails
- return {
- currentVersion: getCurrentVersion(),
- displayVersion: getCurrentVersion(),
- revision: 'unknown',
- shortRevision: 'unknown',
- goVersion: 'unknown',
- nodeVersion: 'unknown',
- svelteKitVersion: 'unknown',
- enabledFeatures: [],
- isSemverVersion: false,
- updateAvailable: false
- };
- } else {
- return operationResult.data;
- }
+ return operationResult.error !== null ? toAppVersionInformation({}) : operationResult.data;
}
async function getNewestVersion(): Promise<string | undefined> {
diff --git a/frontend/src/lib/stores/client-stream.svelte.ts b/frontend/src/lib/stores/client-stream.svelte.ts
index 52c3dc5fc..70f555f2d 100644
--- a/frontend/src/lib/stores/client-stream.svelte.ts
+++ b/frontend/src/lib/stores/client-stream.svelte.ts
@@ -8,6 +8,7 @@ type StreamEnvelope = {
activity?: unknown;
environment?: unknown;
eventLog?: unknown;
+ version?: unknown;
};
type ChannelSubscriber = {
@@ -48,7 +49,7 @@ function createClientStreamInternal() {
}
},
onEvent: (envelope) => {
- const payload = envelope.dashboard ?? envelope.activity ?? envelope.environment ?? envelope.eventLog;
+ const payload = envelope.dashboard ?? envelope.activity ?? envelope.environment ?? envelope.eventLog ?? envelope.version;
if (!envelope.channel || payload === undefined) {
return;
}
diff --git a/frontend/src/lib/stores/version.store.svelte.ts b/frontend/src/lib/stores/version.store.svelte.ts
new file mode 100644
index 000000000..9cf26144b
--- /dev/null
+++ b/frontend/src/lib/stores/version.store.svelte.ts
@@ -0,0 +1,49 @@
+import { browser } from '$app/env';
+import { STREAM_CHANNEL_VERSION } from '#lib/services/stream-service.js';
+import { toAppVersionInformation } from '#lib/services/version-service.js';
+import { clientStream } from '#lib/stores/client-stream.svelte.js';
+import type { AppVersionInformation } from '#lib/types/settings.js';
+
+type VersionStreamEvent = {
+ type: string;
+ info?: Partial<AppVersionInformation>;
+};
+
+function createVersionStoreInternal() {
+ let current = $state.raw<AppVersionInformation | undefined>();
+ let started = false;
+ let unsubscribeChannel: (() => void) | null = null;
+
+ return {
+ get current(): AppVersionInformation | undefined {
+ return current;
+ },
+ seed(info: AppVersionInformation) {
+ current = info;
+ },
+ start() {
+ if (!browser || started) {
+ return;
+ }
+ started = true;
+ unsubscribeChannel = clientStream.subscribe(STREAM_CHANNEL_VERSION, {
+ onEvent: (payload) => {
+ const event = payload as VersionStreamEvent;
+ if (event.type !== 'snapshot' || !event.info) {
+ return;
+ }
+ current = toAppVersionInformation(event.info);
+ }
+ });
+ },
+ stop() {
+ const wasStarted = started;
+ started = false;
+ unsubscribeChannel?.();
+ unsubscribeChannel = null;
+ return wasStarted;
+ }
+ };
+}
+
+export const versionStore = createVersionStoreInternal();
diff --git a/frontend/src/routes/(app)/+layout.svelte b/frontend/src/routes/(app)/+layout.svelte
index 92f3dbf4c..8084814bc 100644
--- a/frontend/src/routes/(app)/+layout.svelte
+++ b/frontend/src/routes/(app)/+layout.svelte
@@ -17,6 +17,7 @@
import { featureStore } from '#lib/stores/features.store.svelte.js';
import { isEnvironmentOnline } from '#lib/utils/docker.js';
import { environmentStatusStore } from '#lib/stores/environment-status.store.svelte.js';
+ import { versionStore } from '#lib/stores/version.store.svelte.js';
import {
navigationItems,
getManagementItems,
@@ -28,7 +29,7 @@
import userStore, { userHasPermissionInAnyEnvironment } from '#lib/stores/user-store.svelte.js';
let { data, children }: LayoutProps = $props();
- const versionInformation = $derived(data.versionInformation);
+ const versionInformation = $derived(versionStore.current ?? data.versionInformation);
const user = $derived(data.user);
const permissionsManifest = $derived(data.permissionsManifest);
const permissionsManifestLoadFailed = $derived(data.permissionsManifestLoadFailed);
@@ -89,7 +90,11 @@
return;
}
void environmentStatusStore.start();
- return () => environmentStatusStore.stop();
+ versionStore.start();
+ return () => {
+ environmentStatusStore.stop();
+ versionStore.stop();
+ };
});
const authRedirectPath = $derived(
diff --git a/frontend/src/routes/+layout.ts b/frontend/src/routes/+layout.ts
index 819969851..65572a67d 100644
--- a/frontend/src/routes/+layout.ts
+++ b/frontend/src/routes/+layout.ts
@@ -9,7 +9,7 @@ import settingsStore from '#lib/stores/config-store.svelte.js';
import { featureStore } from '#lib/stores/features.store.svelte.js';
import { environmentStore } from '#lib/stores/environment.store.svelte.js';
import userStore from '#lib/stores/user-store.svelte.js';
-import { type AppVersionInformation } from '#lib/types/settings.js';
+import { versionStore } from '#lib/stores/version.store.svelte.js';
import type { SearchPaginationSortRequest } from '#lib/types/shared.js';
import type { PermissionsManifest } from '#lib/types/auth.js';
import { authService } from '#lib/services/auth-service.js';
@@ -138,43 +138,8 @@ export const load: LayoutLoad = async ({ url }) => {
settingsStore.set(settings);
}
- let versionInformation: AppVersionInformation = {
- currentVersion: versionService.getCurrentVersion(),
- displayVersion: versionService.getCurrentVersion(),
- revision: 'unknown',
- shortRevision: 'unknown',
- goVersion: 'unknown',
- nodeVersion: 'unknown',
- svelteKitVersion: 'unknown',
- enabledFeatures: [],
- isSemverVersion: false
- };
-
- await tryCatch(
- (async () => {
- const info = await versionInformationRequest;
- versionInformation = {
- currentVersion: info.currentVersion,
- currentTag: info.currentTag,
- currentDigest: info.currentDigest,
- displayVersion: info.displayVersion,
- revision: info.revision,
- shortRevision: info.shortRevision || 'unknown',
- goVersion: info.goVersion || 'unknown',
- nodeVersion: info.nodeVersion || 'unknown',
- svelteKitVersion: info.svelteKitVersion || 'unknown',
- enabledFeatures: info.enabledFeatures ?? [],
- buildTime: info.buildTime,
- isSemverVersion: info.isSemverVersion,
- newestVersion: info.newestVersion,
- newestDigest: info.newestDigest,
- updateAvailable: info.updateAvailable,
- releaseUrl: info.releaseUrl,
- releaseNotes: info.releaseNotes,
- releasedAt: info.releasedAt
- };
- })()
- );
+ const versionInformation = await versionInformationRequest;
+ versionStore.seed(versionInformation);
const redirectPath = getAuthRedirectPath(
url.pathname,
diff --git a/types/stream/stream.go b/types/stream/stream.go
index 13b2c704d..54a1b4ff3 100644
--- a/types/stream/stream.go
+++ b/types/stream/stream.go
@@ -14,6 +14,7 @@ import (
dashboardtypes "github.com/getarcaneapp/arcane/types/v2/dashboard"
environmenttypes "github.com/getarcaneapp/arcane/types/v2/environment"
eventtypes "github.com/getarcaneapp/arcane/types/v2/event"
+ versiontypes "github.com/getarcaneapp/arcane/types/v2/version"
)
// Channel names a subscribable feed. Callers request channels explicitly
@@ -24,6 +25,7 @@ const (
ChannelDashboard = "dashboard"
ChannelActivities = "activities"
ChannelEvents = "events"
+ ChannelVersion = "version"
)
// Event is one line of the multiplexed stream. Exactly one payload is set, and
@@ -61,6 +63,11 @@ type Event struct {
// Required: false
EventLog *eventtypes.StreamEvent `json:"eventLog,omitempty"`
+ // Version carries a ChannelVersion payload.
+ //
+ // Required: false
+ Version *versiontypes.StreamEvent `json:"version,omitempty"`
+
// Timestamp is when the envelope was produced.
//
// Required: true
diff --git a/types/version/version.go b/types/version/version.go
index e169fa899..3c5bcde83 100644
--- a/types/version/version.go
+++ b/types/version/version.go
@@ -1,5 +1,7 @@
package version
+import "time"
+
// Info contains detailed version information about the application.
type Info struct {
// CurrentVersion is the current version string.
@@ -115,3 +117,21 @@ type Check struct {
// Required: false
ReleaseURL string `json:"releaseUrl,omitempty"`
}
+
+// StreamEvent is one version-channel line on the multiplexed client stream.
+type StreamEvent struct {
+ // Type is the event kind: "snapshot".
+ //
+ // Required: true
+ Type string `json:"type"`
+
+ // Info is the app version information for a "snapshot".
+ //
+ // Required: false
+ Info *Info `json:"info,omitempty"`
+
+ // Timestamp is when the event was produced.
+ //
+ // Required: true
+ Timestamp time.Time `json:"timestamp"`
+}