Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
feat: show agent version in details overview
Kyle Mendell8377fac80e17
diff --git a/backend/internal/huma/handlers/environments.go b/backend/internal/huma/handlers/environments.goindex 0c9c61195..7d77cbf6d 100644--- a/backend/internal/huma/handlers/environments.go+++ b/backend/internal/huma/handlers/environments.go@@ -2,7 +2,12 @@ package handlersimport ("context"+ "encoding/json"+ "fmt""log/slog"+ "net/http"+ "strings"+ "time""github.com/danielgtaylor/huma/v2""github.com/getarcaneapp/arcane/backend/internal/common"@@ -15,6 +20,7 @@ import ("github.com/getarcaneapp/arcane/backend/internal/utils/pagination""github.com/getarcaneapp/arcane/types/base""github.com/getarcaneapp/arcane/types/environment"+ "github.com/getarcaneapp/arcane/types/version")const localDockerEnvironmentID = "0"@@ -144,6 +150,14 @@ type GetDeploymentSnippetsOutput struct {Body base.ApiResponse[DeploymentSnippet]}+type GetEnvironmentVersionInput struct {+ ID string `path:"id" doc:"Environment ID"`+}++type GetEnvironmentVersionOutput struct {+ Body base.ApiResponse[version.Info]+}+// ============================================================================// Registration// ============================================================================@@ -297,6 +311,19 @@ func RegisterEnvironments(api huma.API, environmentService *services.Environment{"ApiKeyAuth": {}},},}, h.GetDeploymentSnippets)++ huma.Register(api, huma.Operation{+ OperationID: "getEnvironmentVersion",+ Method: "GET",+ Path: "/environments/{id}/version",+ Summary: "Get environment version",+ Description: "Get the version of a remote environment",+ Tags: []string{"Environments"},+ Security: []map[string][]string{+ {"BearerAuth": {}},+ {"ApiKeyAuth": {}},+ },+ }, h.GetEnvironmentVersion)}// ============================================================================@@ -857,3 +884,48 @@ func (h *EnvironmentHandler) GetDeploymentSnippets(ctx context.Context, input *G},}, nil}++// GetEnvironmentVersion returns the version of a remote environment.+func (h *EnvironmentHandler) GetEnvironmentVersion(ctx context.Context, input *GetEnvironmentVersionInput) (*GetEnvironmentVersionOutput, error) {+ if h.environmentService == nil {+ return nil, huma.Error500InternalServerError("service not available")+ }++ env, err := h.environmentService.GetEnvironmentByID(ctx, input.ID)+ if err != nil {+ return nil, huma.Error404NotFound("Environment not found")+ }++ // Make HTTP request to the environment's /api/app-version endpoint+ reqCtx, cancel := context.WithTimeout(ctx, 5*time.Second)+ defer cancel()++ url := strings.TrimRight(env.ApiUrl, "/") + "/api/app-version"+ req, err := http.NewRequestWithContext(reqCtx, http.MethodGet, url, nil)+ if err != nil {+ return nil, huma.Error500InternalServerError("Failed to create request")+ }++ client := &http.Client{Timeout: 5 * time.Second}+ resp, err := client.Do(req)+ if err != nil {+ return nil, huma.Error500InternalServerError("Request failed: " + err.Error())+ }+ defer resp.Body.Close()++ if resp.StatusCode != http.StatusOK {+ return nil, huma.Error500InternalServerError(fmt.Sprintf("Unexpected status code: %d", resp.StatusCode))+ }++ var versionInfo version.Info+ if err := json.NewDecoder(resp.Body).Decode(&versionInfo); err != nil {+ return nil, huma.Error500InternalServerError("Failed to decode version response")+ }++ return &GetEnvironmentVersionOutput{+ Body: base.ApiResponse[version.Info]{+ Success: true,+ Data: versionInfo,+ },+ }, nil+}diff --git a/frontend/src/lib/services/env-mgmt-service.ts b/frontend/src/lib/services/env-mgmt-service.tsindex 254e0f8cd..cef95462e 100644--- a/frontend/src/lib/services/env-mgmt-service.ts+++ b/frontend/src/lib/services/env-mgmt-service.ts@@ -2,6 +2,7 @@ import BaseAPIService from './api-service';import type { Environment } from '$lib/types/environment.type';import type { CreateEnvironmentDTO, UpdateEnvironmentDTO } from '$lib/types/environment.type';import type { Paginated, SearchPaginationSortRequest } from '$lib/types/pagination.type';+import type { AppVersionInformation } from '$lib/types/application-configuration';import { transformPaginationParams } from '$lib/utils/params.util';export default class EnvironmentManagementService extends BaseAPIService {@@ -43,6 +44,11 @@ export default class EnvironmentManagementService extends BaseAPIService {const res = await this.api.get(`/environments/${environmentId}/deployment`);return res.data.data as { dockerRun: string; dockerCompose: string };}++ async getVersion(environmentId: string): Promise<AppVersionInformation> {+ const res = await this.api.get(`/environments/${environmentId}/version`);+ return res.data.data as AppVersionInformation;+ }}export const environmentManagementService = new EnvironmentManagementService();diff --git a/frontend/src/routes/(app)/environments/[id]/+page.svelte b/frontend/src/routes/(app)/environments/[id]/+page.svelteindex 45d665f8b..263f89d3b 100644--- a/frontend/src/routes/(app)/environments/[id]/+page.svelte+++ b/frontend/src/routes/(app)/environments/[id]/+page.svelte@@ -15,6 +15,7 @@import { environmentStore } from '$lib/stores/environment.store.svelte';import { Spinner } from '$lib/components/ui/spinner/index.js';import { CopyButton } from '$lib/components/ui/copy-button';+ import type { AppVersionInformation } from '$lib/types/application-configuration';import {ArrowLeftIcon,RefreshIcon,@@ -26,11 +27,12 @@RegistryIcon,ResetIcon,ApiKeyIcon,- DockerBrandIcon+ DockerBrandIcon,+ InfoIcon} from '$lib/icons';let { data } = $props();- let { environment, settings } = $derived(data);+ let { environment, settings, versionInformation } = $derived(data);let showSwitchDialog = $state(false);@@ -44,6 +46,10 @@let showRegenerateDialog = $state(false);let regeneratedApiKey = $state<string | null>(null);+ // Version state+ let remoteVersion = $state<AppVersionInformation | null>(null);+ let isLoadingVersion = $state(false);+// Form statelet formName = $state('');let formEnabled = $state(false);@@ -60,6 +66,24 @@currentStatus = environment.status;});+ // Fetch version when environment is online+ $effect(() => {+ if (environment.id !== '0' && currentStatus === 'online' && !remoteVersion && !isLoadingVersion) {+ fetchVersion();+ }+ });++ async function fetchVersion() {+ try {+ isLoadingVersion = true;+ remoteVersion = await environmentManagementService.getVersion(environment.id);+ } catch (err) {+ console.error('Failed to fetch environment version:', err);+ } finally {+ isLoadingVersion = false;+ }+ }+// Track changeslet hasChanges = $derived(formName !== environment.name ||@@ -77,6 +101,8 @@formEnabled = environment.enabled;formApiUrl = environment.apiUrl;currentStatus = environment.status;+ // Reset version to trigger re-fetch if online+ remoteVersion = null;} catch (err) {console.error('Failed to refresh environment:', err);toast.error(m.common_refresh_failed({ resource: m.resource_environment() }));@@ -351,7 +377,7 @@<div class="mt-1 font-mono text-sm">{environment.id}</div></div><div>- <Label class="text-muted-foreground text-xs font-medium">Status</Label>+ <Label class="text-muted-foreground text-xs font-medium">{m.common_status()}</Label><div class="mt-1"><StatusBadgetext={currentStatus === 'online' ? m.common_online() : m.common_offline()}@@ -359,6 +385,43 @@/></div></div>+ <div class="col-span-2 border-t pt-4">+ <Label class="text-muted-foreground text-xs font-medium">{m.version_info_version()}</Label>+ <div class="mt-1 flex items-center gap-2">+ {#if environment.id === '0'}+ <span class="font-mono text-sm">{versionInformation?.currentVersion || 'Unknown'}</span>+ {#if versionInformation?.updateAvailable}+ <Badge variant="secondary" class="bg-amber-500/10 text-amber-600 hover:bg-amber-500/20 dark:text-amber-400">+ {m.sidebar_update_available()}: {versionInformation.newestVersion}+ </Badge>+ {/if}+ {:else if isLoadingVersion}+ <Spinner />+ <span class="text-muted-foreground text-sm">{m.common_action_checking()}</span>+ {:else if remoteVersion}+ <span class="font-mono text-sm">{remoteVersion.currentVersion}</span>+ {#if remoteVersion.updateAvailable}+ <Badge variant="secondary" class="bg-amber-500/10 text-amber-600 hover:bg-amber-500/20 dark:text-amber-400">+ {m.sidebar_update_available()}: {remoteVersion.newestVersion}+ </Badge>+ {#if remoteVersion.releaseUrl}+ <a+ href={remoteVersion.releaseUrl}+ target="_blank"+ rel="noopener noreferrer"+ class="text-xs text-blue-500 hover:underline"+ >+ {m.version_info_view_release()}+ </a>+ {/if}+ {/if}+ {:else if currentStatus === 'online'}+ <span class="text-muted-foreground text-sm">Version information unavailable</span>+ {:else}+ <span class="text-muted-foreground text-sm">{m.common_offline()}</span>+ {/if}+ </div>+ </div></div></Card.Content></Card.Root>