Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: show swarm cluster management if when swarm is disabled
Kyle Mendellb4b17aeb471e
diff --git a/backend/internal/bootstrap/bootstrap.go b/backend/internal/bootstrap/bootstrap.goindex 1edab2e06..45959d9c5 100644--- a/backend/internal/bootstrap/bootstrap.go+++ b/backend/internal/bootstrap/bootstrap.go@@ -175,6 +175,11 @@ func initializeStartupState(appCtx context.Context, cfg *config.Config, appServislog.InfoContext(ctx, "Docker API versions detected", "client_api_version", dockerClient.ClientVersion(), "server_api_version", version.APIVersion, "effective_api_version", effectiveAPIVersion)return nil})+ if appServices.Swarm != nil {+ if err := appServices.Swarm.SyncSwarmEnabledState(appCtx); err != nil {+ slog.WarnContext(appCtx, "Failed to persist swarm enabled state", "error", err)+ }+ }startup.InitializeNonAgentFeatures(appCtx, runtimeCfg,appServices.User.CreateDefaultAdmin,diff --git a/backend/internal/bootstrap/services_bootstrap.go b/backend/internal/bootstrap/services_bootstrap.goindex 602651c8d..732d090d7 100644--- a/backend/internal/bootstrap/services_bootstrap.go+++ b/backend/internal/bootstrap/services_bootstrap.go@@ -84,7 +84,7 @@ func initializeServices(ctx context.Context, db *database.DB, cfg *config.Configsvcs.Dashboard = services.NewDashboardService(db, svcs.Docker, svcs.Container, svcs.Settings, svcs.Vulnerability)svcs.Volume = services.NewVolumeService(db, svcs.Docker, svcs.Event, svcs.Settings, svcs.Container, svcs.Image, cfg.BackupVolumeName)svcs.Network = services.NewNetworkService(db, svcs.Docker, svcs.Event)- svcs.Swarm = services.NewSwarmService(svcs.Docker, svcs.Settings, svcs.ContainerRegistry, svcs.Environment)+ svcs.Swarm = services.NewSwarmService(svcs.Docker, svcs.Settings, svcs.KV, svcs.ContainerRegistry, svcs.Environment)svcs.Template = services.NewTemplateService(ctx, db, httpClient, svcs.Settings)svcs.Auth = services.NewAuthService(svcs.User, svcs.Settings, svcs.Event, cfg.JWTSecret, cfg)svcs.Oidc = services.NewOidcService(svcs.Auth, cfg, httpClient)diff --git a/backend/internal/huma/handlers/settings.go b/backend/internal/huma/handlers/settings.goindex 7a3285102..7330b533f 100644--- a/backend/internal/huma/handlers/settings.go+++ b/backend/internal/huma/handlers/settings.go@@ -212,36 +212,7 @@ func (h *SettingsHandler) GetPublicSettings(ctx context.Context, input *GetPublireturn nil, huma.Error500InternalServerError((&common.SettingsMappingError{Err: err}).Error())}- // Add UI config disabled setting- uiConfigDisabled := false- if h.cfg != nil {- uiConfigDisabled = h.cfg.UIConfigurationDisabled- }- settingsDto = append(settingsDto, settings.PublicSetting{- Key: "uiConfigDisabled",- Value: strconv.FormatBool(uiConfigDisabled),- Type: "boolean",- })- backupVolumeName := "arcane-backups"- if h.cfg != nil && strings.TrimSpace(h.cfg.BackupVolumeName) != "" {- backupVolumeName = h.cfg.BackupVolumeName- }- settingsDto = append(settingsDto, settings.PublicSetting{- Key: "backupVolumeName",- Value: backupVolumeName,- Type: "string",- })- if h.settingsService != nil {- cfg := h.settingsService.GetSettingsConfig()- depotConfigured := strings.TrimSpace(cfg.DepotProjectId.Value) != "" && strings.TrimSpace(cfg.DepotToken.Value) != ""- settingsDto = append(settingsDto, settings.PublicSetting{- Key: "depotConfigured",- Value: strconv.FormatBool(depotConfigured),- Type: "boolean",- })- }-- return &GetPublicSettingsOutput{Body: settingsDto}, nil+ return &GetPublicSettingsOutput{Body: h.appendRuntimeSettings(settingsDto)}, nil}// GetSettings returns all settings for an environment.@@ -278,7 +249,10 @@ func (h *SettingsHandler) GetSettings(ctx context.Context, input *GetSettingsInpreturn nil, huma.Error500InternalServerError((&common.SettingsMappingError{Err: err}).Error())}- // Add UI config disabled setting+ return &GetSettingsOutput{Body: h.appendRuntimeSettings(settingsDto)}, nil+}++func (h *SettingsHandler) appendRuntimeSettings(settingsDto []settings.PublicSetting) []settings.PublicSetting {uiConfigDisabled := falseif h.cfg != nil {uiConfigDisabled = h.cfg.UIConfigurationDisabled@@ -288,6 +262,7 @@ func (h *SettingsHandler) GetSettings(ctx context.Context, input *GetSettingsInpValue: strconv.FormatBool(uiConfigDisabled),Type: "boolean",})+backupVolumeName := "arcane-backups"if h.cfg != nil && strings.TrimSpace(h.cfg.BackupVolumeName) != "" {backupVolumeName = h.cfg.BackupVolumeName@@ -297,6 +272,7 @@ func (h *SettingsHandler) GetSettings(ctx context.Context, input *GetSettingsInpValue: backupVolumeName,Type: "string",})+if h.settingsService != nil {cfg := h.settingsService.GetSettingsConfig()depotConfigured := strings.TrimSpace(cfg.DepotProjectId.Value) != "" && strings.TrimSpace(cfg.DepotToken.Value) != ""@@ -307,7 +283,7 @@ func (h *SettingsHandler) GetSettings(ctx context.Context, input *GetSettingsInp})}- return &GetSettingsOutput{Body: settingsDto}, nil+ return settingsDto}// UpdateSettings updates settings for an environment.diff --git a/backend/internal/huma/handlers/swarm.go b/backend/internal/huma/handlers/swarm.goindex f4730d3e9..e5ef500d5 100644--- a/backend/internal/huma/handlers/swarm.go+++ b/backend/internal/huma/handlers/swarm.go@@ -321,6 +321,14 @@ type GetSwarmInfoOutput struct {Body base.ApiResponse[swarmtypes.SwarmInfo]}+type GetSwarmStatusInput struct {+ EnvironmentID string `path:"id" doc:"Environment ID"`+}++type GetSwarmStatusOutput struct {+ Body base.ApiResponse[swarmtypes.RuntimeStatus]+}+type InitSwarmInput struct {EnvironmentID string `path:"id" doc:"Environment ID"`Body swarmtypes.SwarmInitRequest@@ -530,6 +538,7 @@ func RegisterSwarm(api huma.API, swarmSvc *services.SwarmService, environmentSvchuma.Register(api, huma.Operation{OperationID: "list-swarm-stack-tasks", Method: http.MethodGet, Path: "/environments/{id}/swarm/stacks/{name}/tasks", Summary: "List swarm stack tasks", Tags: []string{"Swarm"}, Security: []map[string][]string{{"BearerAuth": {}}, {"ApiKeyAuth": {}}}}, h.ListStackTasks)huma.Register(api, huma.Operation{OperationID: "render-swarm-stack-config", Method: http.MethodPost, Path: "/environments/{id}/swarm/stacks/config/render", Summary: "Render/validate swarm stack config", Tags: []string{"Swarm"}, Security: []map[string][]string{{"BearerAuth": {}}, {"ApiKeyAuth": {}}}}, h.RenderStackConfig)+ huma.Register(api, huma.Operation{OperationID: "get-swarm-status", Method: http.MethodGet, Path: "/environments/{id}/swarm/status", Summary: "Get swarm status", Tags: []string{"Swarm"}, Security: []map[string][]string{{"BearerAuth": {}}, {"ApiKeyAuth": {}}}}, h.GetSwarmStatus)huma.Register(api, huma.Operation{OperationID: "get-swarm-info", Method: http.MethodGet, Path: "/environments/{id}/swarm/info", Summary: "Get swarm info", Tags: []string{"Swarm"}, Security: []map[string][]string{{"BearerAuth": {}}, {"ApiKeyAuth": {}}}}, h.GetSwarmInfo)huma.Register(api, huma.Operation{OperationID: "init-swarm", Method: http.MethodPost, Path: "/environments/{id}/swarm/init", Summary: "Initialize swarm", Tags: []string{"Swarm"}, Security: []map[string][]string{{"BearerAuth": {}}, {"ApiKeyAuth": {}}}}, h.InitSwarm)huma.Register(api, huma.Operation{OperationID: "join-swarm", Method: http.MethodPost, Path: "/environments/{id}/swarm/join", Summary: "Join swarm", Tags: []string{"Swarm"}, Security: []map[string][]string{{"BearerAuth": {}}, {"ApiKeyAuth": {}}}}, h.JoinSwarm)@@ -1338,6 +1347,34 @@ func (h *SwarmHandler) RenderStackConfig(ctx context.Context, input *RenderSwarmreturn &RenderSwarmStackConfigOutput{Body: base.ApiResponse[swarmtypes.StackRenderConfigResponse]{Success: true, Data: *resp}}, nil}+// GetSwarmInfo returns the current swarm cluster metadata for an environment.+//+// It delegates to the swarm service to inspect the local swarm state and maps+// service-layer failures to the API's HTTP error model.+//+// ctx carries request-scoped cancellation and auth context.+// input identifies the environment whose swarm metadata should be returned.+//+// Returns the current swarm information when swarm mode is available.+// Returns a mapped HTTP error when swarm inspection fails.+func (h *SwarmHandler) GetSwarmStatus(ctx context.Context, input *GetSwarmStatusInput) (*GetSwarmStatusOutput, error) {+ if h.swarmService == nil {+ return nil, huma.Error500InternalServerError("service not available")+ }++ enabled, err := h.swarmService.IsEnabled(ctx)+ if err != nil {+ return nil, huma.Error500InternalServerError("failed to read swarm status")+ }++ return &GetSwarmStatusOutput{+ Body: base.ApiResponse[swarmtypes.RuntimeStatus]{+ Success: true,+ Data: swarmtypes.RuntimeStatus{Enabled: enabled},+ },+ }, nil+}+// GetSwarmInfo returns the current swarm cluster metadata for an environment.//// It delegates to the swarm service to inspect the local swarm state and mapsdiff --git a/backend/internal/services/kv_service.go b/backend/internal/services/kv_service.goindex 3962be1cc..ffac00227 100644--- a/backend/internal/services/kv_service.go+++ b/backend/internal/services/kv_service.go@@ -4,6 +4,7 @@ import ("context""errors""fmt"+ "strconv""github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"@@ -47,3 +48,24 @@ func (s *KVService) Set(ctx context.Context, key, value string) error {return nil}++func (s *KVService) GetBool(ctx context.Context, key string, defaultValue bool) (bool, error) {+ rawValue, ok, err := s.Get(ctx, key)+ if err != nil {+ return defaultValue, err+ }+ if !ok {+ return defaultValue, nil+ }++ parsedValue, err := strconv.ParseBool(rawValue)+ if err != nil {+ return defaultValue, fmt.Errorf("failed to parse kv entry %q as bool: %w", key, err)+ }++ return parsedValue, nil+}++func (s *KVService) SetBool(ctx context.Context, key string, value bool) error {+ return s.Set(ctx, key, strconv.FormatBool(value))+}diff --git a/backend/internal/services/swarm_service.go b/backend/internal/services/swarm_service.goindex 382e3395d..29fa360cd 100644--- a/backend/internal/services/swarm_service.go+++ b/backend/internal/services/swarm_service.go@@ -35,11 +35,13 @@ var ErrSwarmNotEnabled = errors.New("swarm mode is not enabled")var ErrSwarmManagerRequired = errors.New("swarm manager access required")const swarmNodeIdentityProbeConcurrency = 5+const KVKeySwarmEnabled = "swarm.enabled"// SwarmService provides Docker Swarm related operations.type SwarmService struct {dockerService *DockerClientServicesettingsService *SettingsService+ kvService *KVServiceregistryService *ContainerRegistryServiceenvironmentService *EnvironmentService}@@ -47,12 +49,14 @@ type SwarmService struct {func NewSwarmService(dockerService *DockerClientService,settingsService *SettingsService,+ kvService *KVService,registryService *ContainerRegistryService,environmentService *EnvironmentService,) *SwarmService {return &SwarmService{dockerService: dockerService,settingsService: settingsService,+ kvService: kvService,registryService: registryService,environmentService: environmentService,}@@ -73,6 +77,19 @@ type swarmNodeAgentRuntime struct {identity *SwarmNodeIdentity}+func (s *SwarmService) IsEnabled(ctx context.Context) (bool, error) {+ if s.kvService == nil {+ return false, nil+ }++ enabled, err := s.kvService.GetBool(ctx, KVKeySwarmEnabled, false)+ if err != nil {+ return false, fmt.Errorf("failed to read swarm enabled state: %w", err)+ }++ return enabled, nil+}+func (s *SwarmService) ListServicesPaginated(ctx context.Context, params pagination.QueryParams) ([]swarmtypes.ServiceSummary, pagination.Response, error) {if err := s.ensureSwarmManagerInternal(ctx); err != nil {return nil, pagination.Response{}, err@@ -875,6 +892,8 @@ func (s *SwarmService) InitSwarm(ctx context.Context, req swarmtypes.SwarmInitRereturn nil, fmt.Errorf("failed to initialize swarm: %w", err)}+ s.persistSwarmEnabledStateInternal(ctx, true)+return &swarmtypes.SwarmInitResponse{NodeID: initResult.NodeID}, nil}@@ -895,6 +914,8 @@ func (s *SwarmService) JoinSwarm(ctx context.Context, req swarmtypes.SwarmJoinRereturn fmt.Errorf("failed to join swarm: %w", err)}+ s.persistSwarmEnabledStateInternal(ctx, true)+return nil}@@ -912,6 +933,8 @@ func (s *SwarmService) LeaveSwarm(ctx context.Context, req swarmtypes.SwarmLeavereturn fmt.Errorf("failed to leave swarm: %w", err)}+ s.persistSwarmEnabledStateInternal(ctx, false)+return nil}@@ -1978,6 +2001,34 @@ func (s *SwarmService) getDockerInfoInternal(ctx context.Context) (system.Info,return infoResult.Info, nil}+func (s *SwarmService) SyncSwarmEnabledState(ctx context.Context) error {+ info, err := s.getDockerInfoInternal(ctx)+ if err != nil {+ return err+ }++ enabled := info.Swarm.LocalNodeState == swarm.LocalNodeStateActive && strings.TrimSpace(info.Swarm.NodeID) != ""+ if s.kvService == nil {+ return nil+ }++ if err := s.kvService.SetBool(ctx, KVKeySwarmEnabled, enabled); err != nil {+ return fmt.Errorf("persist swarm enabled state: %w", err)+ }++ return nil+}++func (s *SwarmService) persistSwarmEnabledStateInternal(ctx context.Context, enabled bool) {+ if s.kvService == nil {+ return+ }++ if err := s.kvService.SetBool(ctx, KVKeySwarmEnabled, enabled); err != nil {+ slog.WarnContext(ctx, "Failed to persist swarm enabled state", "enabled", enabled, "error", err)+ }+}+func (s *SwarmService) buildServicePaginationConfigInternal() pagination.Config[swarmtypes.ServiceSummary] {return pagination.Config[swarmtypes.ServiceSummary]{SearchAccessors: []pagination.SearchAccessor[swarmtypes.ServiceSummary]{diff --git a/frontend/src/lib/components/mobile-nav/mobile-nav-sheet.svelte b/frontend/src/lib/components/mobile-nav/mobile-nav-sheet.svelteindex 7d247545e..7441d9450 100644--- a/frontend/src/lib/components/mobile-nav/mobile-nav-sheet.svelte+++ b/frontend/src/lib/components/mobile-nav/mobile-nav-sheet.svelte@@ -22,13 +22,13 @@open = $bindable(false),user = null,versionInformation,- swarmEnabled = false,+ swarmItems = [],debug = false}: {open: boolean;user?: any;versionInformation?: AppVersionInformation;- swarmEnabled?: boolean;+ swarmItems?: NavigationItem[];debug?: boolean;} = $props();@@ -250,13 +250,13 @@</div></section>- {#if swarmEnabled}+ {#if swarmItems.length > 0}<section><h4 class="text-muted-foreground/70 mb-4 px-3 text-[11px] font-bold tracking-widest uppercase">{m.swarm_title()}</h4><div class="space-y-2">- {#each navigationItems.swarmItems as item}+ {#each swarmItems as item}{@const IconComponent = item.icon}<ahref={item.url}diff --git a/frontend/src/lib/components/mobile-nav/mobile-nav.svelte b/frontend/src/lib/components/mobile-nav/mobile-nav.svelteindex 73957cf98..5c2f18e9f 100644--- a/frontend/src/lib/components/mobile-nav/mobile-nav.svelte+++ b/frontend/src/lib/components/mobile-nav/mobile-nav.svelte@@ -1,14 +1,13 @@<script lang="ts">import { page } from '$app/state';import type { MobileNavigationSettings } from '$lib/config/navigation-config';- import { getAvailableMobileNavItems } from '$lib/config/navigation-config';+ import { getAvailableMobileNavItems, getSwarmNavigationItems } from '$lib/config/navigation-config';import MobileNavItem from './mobile-nav-item.svelte';import MobileNavMenuButton from './mobile-nav-menu-button.svelte';import { cn } from '$lib/utils';import MobileNavSheet from './mobile-nav-sheet.svelte';import { m } from '$lib/paraglide/messages';import { MobileNavGestures } from './gestures.svelte';- import type { DockerInfo } from '$lib/types/docker-info.type';import './styles.css';import type { AppVersionInformation } from '$lib/types/application-configuration';@@ -16,21 +15,21 @@navigationSettings,user = null,versionInformation,- dockerInfo = null,+ swarmEnabled = false,class: className = ''}: {navigationSettings: MobileNavigationSettings;user?: any;versionInformation?: AppVersionInformation;- dockerInfo?: DockerInfo | null;+ swarmEnabled?: boolean;class?: string;} = $props();- const swarmEnabled = $derived(dockerInfo?.Swarm?.LocalNodeState === 'active');+ const swarmItems = $derived(getSwarmNavigationItems(swarmEnabled));const pinnedItems = $derived.by(() => {if (!navigationSettings?.pinnedItems) return [];- const availableItems = getAvailableMobileNavItems({ includeSwarm: swarmEnabled });+ const availableItems = getAvailableMobileNavItems({ swarmEnabled });return navigationSettings.pinnedItems.map((url) => availableItems.find((item) => item.url === url)).filter((item) => item !== undefined);@@ -189,4 +188,4 @@{/if}</nav>-<MobileNavSheet bind:open={menuOpen} {user} {versionInformation} {swarmEnabled} />+<MobileNavSheet bind:open={menuOpen} {user} {versionInformation} {swarmItems} />diff --git a/frontend/src/lib/components/sidebar/sidebar.svelte b/frontend/src/lib/components/sidebar/sidebar.svelteindex fdd4d3da1..51abc4ce5 100644--- a/frontend/src/lib/components/sidebar/sidebar.svelte+++ b/frontend/src/lib/components/sidebar/sidebar.svelte@@ -1,5 +1,5 @@<script lang="ts" module>- import { navigationItems, getBuildAndDeploymentItems } from '$lib/config/navigation-config';+ import { navigationItems, getBuildAndDeploymentItems, getSwarmNavigationItems } from '$lib/config/navigation-config';</script><script lang="ts">@@ -12,7 +12,6 @@import type { ComponentProps } from 'svelte';import type { User } from '$lib/types/user.type';import type { AppVersionInformation } from '$lib/types/application-configuration';- import type { DockerInfo } from '$lib/types/docker-info.type';import SidebarLogo from './sidebar-logo.svelte';import SidebarUpdatebanner from './sidebar-updatebanner.svelte';import SidebarPinButton from './sidebar-pin-button.svelte';@@ -31,12 +30,12 @@variant = 'floating',user,versionInformation,- dockerInfo = null,+ swarmEnabled = false,...restProps}: ComponentProps<typeof Sidebar.Root> & {versionInformation: AppVersionInformation;user?: User | null;- dockerInfo?: DockerInfo | null;+ swarmEnabled?: boolean;} = $props();let autoLoginEnabled = $state(false);@@ -67,7 +66,7 @@const currentEnvId = $derived(environmentStore.selected?.id || '0');const buildDeploymentItems = $derived(getBuildAndDeploymentItems(currentEnvId));- const swarmEnabled = $derived(dockerInfo?.Swarm?.LocalNodeState === 'active');+ const swarmItems = $derived(getSwarmNavigationItems(swarmEnabled));</script><VersionInfoDialog@@ -105,8 +104,8 @@<SidebarItemGroup label={m.sidebar_management()} items={navigationItems.managementItems} /><SidebarItemGroup label={m.sidebar_resources()} items={navigationItems.resourceItems} /><SidebarItemGroup label={m.builds_and_deployments()} items={buildDeploymentItems} />- {#if swarmEnabled}- <SidebarItemGroup label={m.swarm_title()} items={navigationItems.swarmItems} />+ {#if swarmItems.length > 0}+ <SidebarItemGroup label={m.swarm_title()} items={swarmItems} />{/if}<SidebarItemGroup label={m.security_title()} items={navigationItems.securityItems} />{#if isAdmin}diff --git a/frontend/src/lib/config/navigation-config.ts b/frontend/src/lib/config/navigation-config.tsindex ef5573bb4..6c8c96b38 100644--- a/frontend/src/lib/config/navigation-config.ts+++ b/frontend/src/lib/config/navigation-config.ts@@ -108,6 +108,14 @@ export const defaultMobilePinnedItems: NavigationItem[] = [navigationItems.resourceItems[1]!];+export function getSwarmNavigationItems(swarmEnabled: boolean): NavigationItem[] {+ if (swarmEnabled) {+ return navigationItems.swarmItems;+ }++ return navigationItems.swarmItems.filter((item) => item.url === '/swarm/cluster');+}+export type MobileNavigationSettings = {pinnedItems: string[];mode: 'floating' | 'docked';@@ -115,7 +123,7 @@ export type MobileNavigationSettings = {scrollToHide: boolean;};-export function getAvailableMobileNavItems(options?: { includeSwarm?: boolean }): NavigationItem[] {+export function getAvailableMobileNavItems(options?: { swarmEnabled?: boolean }): NavigationItem[] {const flatItems: NavigationItem[] = [];if (navigationItems.managementItems) {flatItems.push(...navigationItems.managementItems);@@ -129,8 +137,9 @@ export function getAvailableMobileNavItems(options?: { includeSwarm?: boolean })flatItems.push(...navigationItems.deploymentItems);}- if (options?.includeSwarm && navigationItems.swarmItems) {- flatItems.push(...navigationItems.swarmItems);+ const swarmItems = getSwarmNavigationItems(!!options?.swarmEnabled);+ if (swarmItems.length > 0) {+ flatItems.push(...swarmItems);}if (navigationItems.securityItems) {diff --git a/frontend/src/lib/services/swarm-service.ts b/frontend/src/lib/services/swarm-service.tsindex a7c11bdfb..cc2734336 100644--- a/frontend/src/lib/services/swarm-service.ts+++ b/frontend/src/lib/services/swarm-service.ts@@ -8,6 +8,7 @@ import type {SwarmTaskSummary,SwarmStackSummary,SwarmInfo,+ SwarmRuntimeStatus,SwarmNodeAgentDeployment,SwarmServiceCreateRequest,SwarmServiceUpdateRequest,@@ -191,6 +192,11 @@ export class SwarmService extends BaseAPIService {return this.handleResponse(this.api.get(`/environments/${envId}/swarm/info`));}+ async getSwarmStatus(): Promise<SwarmRuntimeStatus> {+ const envId = await environmentStore.getCurrentEnvironmentId();+ return this.handleResponse(this.api.get(`/environments/${envId}/swarm/status`));+ }+async initSwarm(request: SwarmInitRequest): Promise<SwarmInitResponse> {const envId = await environmentStore.getCurrentEnvironmentId();return this.handleResponse(this.api.post(`/environments/${envId}/swarm/init`, request));diff --git a/frontend/src/lib/types/swarm.type.ts b/frontend/src/lib/types/swarm.type.tsindex e39e4af0e..b9a6197a8 100644--- a/frontend/src/lib/types/swarm.type.ts+++ b/frontend/src/lib/types/swarm.type.ts@@ -60,6 +60,10 @@ export interface ServiceVirtualIP {addr: string;}+export interface SwarmRuntimeStatus {+ enabled: boolean;+}+export interface RawServiceVirtualIP {NetworkID?: string;networkID?: string;diff --git a/frontend/src/routes/(app)/+layout.svelte b/frontend/src/routes/(app)/+layout.svelteindex 636713671..0dd9c7882 100644--- a/frontend/src/routes/(app)/+layout.svelte+++ b/frontend/src/routes/(app)/+layout.svelte@@ -27,7 +27,7 @@const versionInformation = $derived(data.versionInformation);const user = $derived(data.user);const settings = $derived(data.settings);- const dockerInfo = $derived(data.dockerInfo);+ const swarmEnabled = $derived(data.swarmEnabled === true);const isMobile = new IsMobile();const isTablet = new IsTablet();@@ -109,10 +109,10 @@{@render children()}</section></main>- <MobileNav {navigationSettings} {user} {versionInformation} {dockerInfo} />+ <MobileNav {navigationSettings} {user} {versionInformation} {swarmEnabled} />{:else}<Sidebar.Provider>- <AppSidebar {versionInformation} {user} {dockerInfo} />+ <AppSidebar {versionInformation} {user} {swarmEnabled} /><main class="h-dvh flex-1"><section class="h-full p-3 sm:p-5">{@render children()}diff --git a/frontend/src/routes/(app)/swarm/nodes/swarm-node-agent-dialog.svelte b/frontend/src/routes/(app)/swarm/nodes/swarm-node-agent-dialog.svelteindex c6cadc427..6e25054f3 100644--- a/frontend/src/routes/(app)/swarm/nodes/swarm-node-agent-dialog.svelte+++ b/frontend/src/routes/(app)/swarm/nodes/swarm-node-agent-dialog.svelte@@ -1,8 +1,8 @@<script lang="ts">import * as Alert from '$lib/components/ui/alert';import { ArcaneButton } from '$lib/components/arcane-button';+ import { CopyButton } from '$lib/components/ui/copy-button';import * as ResponsiveDialog from '$lib/components/ui/responsive-dialog';- import { Snippet } from '$lib/components/ui/snippet';import { Spinner } from '$lib/components/ui/spinner';import StatusBadge from '$lib/components/badges/status-badge.svelte';import { AlertTriangleIcon, EdgeConnectionIcon } from '$lib/icons';@@ -37,61 +37,70 @@<ResponsiveDialog.Rootbind:open+ variant="sheet"title={node ? m.swarm_node_agent_dialog_title({ name: node.hostname }) : m.swarm_node_agent_deploy()}description={m.swarm_node_agent_dialog_description()}contentClass="sm:max-w-3xl">- {#snippet children()}- <div class="space-y-5 py-6">- <Alert.Root class="border-primary/20 bg-primary/5">- <EdgeConnectionIcon class="size-4" />- <Alert.Title>{m.swarm_node_agent_dialog_blurb_title()}</Alert.Title>- <Alert.Description>{m.swarm_node_agent_dialog_blurb_description()}</Alert.Description>- </Alert.Root>+ <div class="space-y-5 px-6 py-6">+ <Alert.Root class="border-primary/20 bg-primary/5">+ <EdgeConnectionIcon class="size-4" />+ <Alert.Title>{m.swarm_node_agent_dialog_blurb_title()}</Alert.Title>+ <Alert.Description>{m.swarm_node_agent_dialog_blurb_description()}</Alert.Description>+ </Alert.Root>- <div class="grid gap-3 sm:grid-cols-2">- <div class="bg-muted/40 rounded-lg border p-4">- <div class="text-muted-foreground text-xs font-medium tracking-wide uppercase">{m.common_status()}</div>- <div class="mt-2 flex items-center gap-2">- <StatusBadge text={agentStatusLabel} variant={getSwarmNodeAgentVariant(agentStatus.state)} />- </div>+ <div class="grid gap-3 sm:grid-cols-2">+ <div class="bg-muted/40 rounded-lg border p-4">+ <div class="text-muted-foreground text-xs font-medium tracking-wide uppercase">{m.common_status()}</div>+ <div class="mt-2 flex items-center gap-2">+ <StatusBadge text={agentStatusLabel} variant={getSwarmNodeAgentVariant(agentStatus.state)} /></div>+ </div>- <div class="bg-muted/40 rounded-lg border p-4">- <div class="text-muted-foreground text-xs font-medium tracking-wide uppercase">- {m.swarm_node_agent_environment_id()}- </div>- <div class="mt-2 font-mono text-sm break-all">{deployment?.environmentId ?? agentStatus.environmentId ?? '—'}</div>+ <div class="bg-muted/40 rounded-lg border p-4">+ <div class="text-muted-foreground text-xs font-medium tracking-wide uppercase">+ {m.swarm_node_agent_environment_id()}</div>+ <div class="mt-2 font-mono text-sm break-all">{deployment?.environmentId ?? agentStatus.environmentId ?? '—'}</div></div>+ </div>- {#if errorMessage}- <Alert.Root variant="destructive">- <AlertTriangleIcon class="size-4" />- <Alert.Title>{m.common_action_failed()}</Alert.Title>- <Alert.Description>{errorMessage}</Alert.Description>- </Alert.Root>- {/if}+ {#if errorMessage}+ <Alert.Root variant="destructive">+ <AlertTriangleIcon class="size-4" />+ <Alert.Title>{m.common_action_failed()}</Alert.Title>+ <Alert.Description>{errorMessage}</Alert.Description>+ </Alert.Root>+ {/if}- {#if isLoading && !deployment}- <div class="flex items-center justify-center py-10">- <Spinner class="size-6" />- </div>- {:else if isReady && deployment}- <div class="space-y-4">- <div class="space-y-2">- <div class="text-sm font-medium">{m.environments_docker_run_command()}</div>- <Snippet text={deployment.dockerRun} />+ {#if isLoading && !deployment}+ <div class="flex items-center justify-center py-10">+ <Spinner class="size-6" />+ </div>+ {:else if isReady && deployment}+ <div class="space-y-4">+ <div class="space-y-2">+ <div class="text-sm font-medium">{m.environments_docker_run_command()}</div>+ <div class="relative">+ <pre class="bg-muted overflow-x-auto rounded-md p-3 pr-12 text-xs"><code>{deployment.dockerRun}</code></pre>+ <div class="absolute top-2 right-2">+ <CopyButton text={deployment.dockerRun} size="icon" class="size-7" />+ </div></div>+ </div>- <div class="space-y-2">- <div class="text-sm font-medium">{m.environments_docker_compose()}</div>- <Snippet text={deployment.dockerCompose} />+ <div class="space-y-2">+ <div class="text-sm font-medium">{m.environments_docker_compose()}</div>+ <div class="relative">+ <pre class="bg-muted overflow-x-auto rounded-md p-3 pr-12 text-xs"><code>{deployment.dockerCompose}</code></pre>+ <div class="absolute top-2 right-2">+ <CopyButton text={deployment.dockerCompose} size="icon" class="size-7" />+ </div></div></div>- {/if}- </div>- {/snippet}+ </div>+ {/if}+ </div>{#snippet footer()}<div class="flex w-full flex-col gap-2 sm:flex-row sm:justify-end">diff --git a/frontend/src/routes/+layout.ts b/frontend/src/routes/+layout.tsindex bd1a556ba..9c2fc1577 100644--- a/frontend/src/routes/+layout.ts+++ b/frontend/src/routes/+layout.ts@@ -1,6 +1,7 @@import { browser } from '$app/environment';import { environmentManagementService } from '$lib/services/env-mgmt-service';import { settingsService } from '$lib/services/settings-service';+import { swarmService } from '$lib/services/swarm-service';import { userService } from '$lib/services/user-service';import versionService from '$lib/services/version-service';import settingsStore from '$lib/stores/config-store';@@ -12,8 +13,6 @@ import { authService } from '$lib/services/auth-service';import { tryCatch } from '$lib/utils/try-catch';import { QueryClient } from '@tanstack/svelte-query';import { queryKeys } from '$lib/query/query-keys';-import { systemService } from '$lib/services/system-service';-import type { DockerInfo } from '$lib/types/docker-info.type';export const ssr = false;@@ -63,8 +62,7 @@ export const load = async () => {// Step 2: Only fetch authenticated data if user is logged inlet settings = null;- let dockerInfo: DockerInfo | null = null;-+ let swarmEnabled = false;if (user) {// Initialize environment store (required for settings service)const environmentRequestOptions: SearchPaginationSortRequest = {@@ -83,8 +81,12 @@ export const load = async () => {// Fetch settings after environment store is initialized// Settings service depends on environmentStore.getCurrentEnvironmentId()- settings = await settingsService.getSettings().catch(() => null);- dockerInfo = await systemService.getDockerInfo().catch(() => null);+ const [loadedSettings, loadedSwarmStatus] = await Promise.all([+ settingsService.getSettings().catch(() => null),+ swarmService.getSwarmStatus().catch(() => null)+ ]);+ settings = loadedSettings;+ swarmEnabled = loadedSwarmStatus?.enabled === true;} else {// Initialize empty environment store for unauthenticated usersawait environmentStore.initialize([]);@@ -138,6 +140,6 @@ export const load = async () => {settings,versionInformation,queryClient,- dockerInfo+ swarmEnabled};};diff --git a/tests/spec/dashboard-system-stats.spec.ts b/tests/spec/dashboard-system-stats.spec.tsindex f3b41141f..024157606 100644--- a/tests/spec/dashboard-system-stats.spec.ts+++ b/tests/spec/dashboard-system-stats.spec.ts@@ -129,6 +129,7 @@ test.describe('Dashboard system stats websocket', () => {await expect(page.getByText('7 CPUs', { exact: true })).toBeVisible();await expect(page.getByText('512 MB / 1 GB', { exact: true })).toBeVisible();await expect(page.getByText('256 MB / 1 GB', { exact: true })).toBeVisible();+ await expect(page.locator('a[href="/swarm/cluster"]').first()).toBeVisible();});test('loads dashboard content from the snapshot endpoint without dashboard REST fan-out', async ({@@ -149,11 +150,14 @@ test.describe('Dashboard system stats websocket', () => {/\/api\/environments\/[^/]+\/containers\/counts$/,/\/api\/environments\/[^/]+\/images$/,/\/api\/environments\/[^/]+\/images\/counts$/,- /\/api\/environments\/[^/]+\/dashboard\/action-items$/,- /\/api\/environments\/[^/]+\/system\/docker\/info$/+ /\/api\/environments\/[^/]+\/dashboard\/action-items$/]) {expect(countMatchingRequests(requestPaths, blockedPattern)).toBe(0);}++ expect(+ countMatchingRequests(requestPaths, /\/api\/environments\/[^/]+\/system\/docker\/info$/)+ ).toBe(0);});test('lazy loads docker info when the inspect dialog opens and reuses the cached result', async ({@@ -169,14 +173,10 @@ test.describe('Dashboard system stats websocket', () => {countMatchingRequests(requestPaths, /\/api\/environments\/[^/]+\/system\/docker\/info$/)).toBe(0);- const dockerInfoRequest = page.waitForRequest((request) =>- /\/api\/environments\/[^/]+\/system\/docker\/info$/.test(new URL(request.url()).pathname)- );await page.getByRole('button', { name: /^Inspect$/ }).first().click();- await dockerInfoRequest;await expect(page.getByRole('dialog')).toBeVisible();await expect.poll(() =>diff --git a/tests/spec/swarm-ui.spec.ts b/tests/spec/swarm-ui.spec.tsindex 733009f2d..94fbe058d 100644--- a/tests/spec/swarm-ui.spec.ts+++ b/tests/spec/swarm-ui.spec.ts@@ -35,14 +35,18 @@ test.describe('Swarm UI', () => {await expect(page.getByRole('heading', { name: 'Cluster', level: 1 })).toBeVisible();- const initializedBanner = page.getByText('Cluster Already Initialized');- if ((await initializedBanner.count()) > 0) {- await expect(initializedBanner).toBeVisible();- await expect(page.getByRole('button', { name: 'Leave Cluster' })).toBeVisible();+ const initializeCard = page+ .locator('[data-slot="card-title"]')+ .filter({ hasText: 'Initialize Cluster' });+ if ((await initializeCard.count()) === 0) {+ await expect(page.getByRole('button', { name: 'Actions' })).toBeVisible();await expect(page.getByText('Initialize Cluster')).toHaveCount(0);await expect(page.getByText('Join Existing Cluster')).toHaveCount(0);+ await page.getByRole('button', { name: 'Actions' }).click();+ await expect(page.getByText('Unlock / Leave')).toBeVisible();+ await expect(page.getByRole('button', { name: 'Leave Cluster' })).toBeVisible();} else {- await expect(page.getByText('Initialize Cluster')).toBeVisible();+ await expect(initializeCard).toBeVisible();await expect(page.getByText('Join Existing Cluster')).toBeVisible();await expect(page.getByPlaceholder('Listen address (optional)').first()).toBeVisible();await expect(page.getByRole('button', { name: 'Initialize' })).toBeVisible();diff --git a/tests/spec/token-refresh.spec.ts b/tests/spec/token-refresh.spec.tsindex 0e5affe33..fed083f61 100644--- a/tests/spec/token-refresh.spec.ts+++ b/tests/spec/token-refresh.spec.ts@@ -125,11 +125,16 @@ test.describe('Token refresh behaviour', () => {});// Force a protected data endpoint to 401 so the axios interceptor always runs refresh logic.- await injectExpired401Always(page, /\/api\/environments\/0\/containers/);+ await injectExpired401Always(page, /\/api\/environments\/[^/]+\/containers(?:\/.*)?$/);+ // Keep /auth/me unauthenticated too so the login page does not immediately bounce back.+ await injectExpired401Always(page, /\/api\/auth\/me$/);await page.goto('/containers');await expect.poll(() => refreshCalled).toBe(true);await page.waitForURL(/\/login(\?|$)/, { timeout: 15_000 });+ await expect(+ page.getByRole('button', { name: 'Sign in to Arcane', exact: true })+ ).toBeVisible();});test('unauthenticated users are redirected to /login', async ({ page }) => {diff --git a/types/swarm/swarm.go b/types/swarm/swarm.goindex 7801766f8..3630157e1 100644--- a/types/swarm/swarm.go+++ b/types/swarm/swarm.go@@ -6,6 +6,10 @@ import ("github.com/moby/moby/api/types/swarm")+type RuntimeStatus struct {+ Enabled bool `json:"enabled"`+}+type SwarmInfo struct {// ID is the swarm ID.//