Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
feat: remember last-used shell per compose service (#4348)
Kyle Mendell8176ee5b136e
diff --git a/frontend/src/lib/utils/docker.ts b/frontend/src/lib/utils/docker.tsindex 198c2b8a2..6debb68b0 100644--- a/frontend/src/lib/utils/docker.ts+++ b/frontend/src/lib/utils/docker.ts@@ -13,6 +13,7 @@ import { tryCatch } from '#lib/utils/try-catch.js';// --- Compose / Swarm management labels ---export const COMPOSE_PROJECT_LABEL = 'com.docker.compose.project';+export const COMPOSE_SERVICE_LABEL = 'com.docker.compose.service';export const SWARM_STACK_LABEL = 'com.docker.stack.namespace';export function getManagedByLabel(labels?: Record<string, string> | null): string | undefined {diff --git a/frontend/src/routes/(app)/containers/[containerId]/+page.svelte b/frontend/src/routes/(app)/containers/[containerId]/+page.svelteindex 50161a086..eb2a20732 100644--- a/frontend/src/routes/(app)/containers/[containerId]/+page.svelte+++ b/frontend/src/routes/(app)/containers/[containerId]/+page.svelte@@ -549,7 +549,7 @@{#if showShell}<Tabs.Content value="shell" class="h-full">{#if activeTab === 'shell'}- <ContainerShell containerId={container?.id} />+ <ContainerShell containerId={container?.id} labels={container?.labels} name={container?.name} />{/if}</Tabs.Content>{/if}diff --git a/frontend/src/routes/(app)/containers/components/container-shell.svelte b/frontend/src/routes/(app)/containers/components/container-shell.svelteindex 2397be9c6..6adeb3547 100644--- a/frontend/src/routes/(app)/containers/components/container-shell.svelte+++ b/frontend/src/routes/(app)/containers/components/container-shell.svelte@@ -1,5 +1,6 @@<script lang="ts">import { page } from '$app/state';+ import { PersistedState } from 'runed';import TerminalControls from '#lib/components/terminal/terminal-controls.svelte';import Terminal from '#lib/components/terminal/terminal.svelte';@@ -8,15 +9,32 @@import { m } from '#lib/paraglide/messages.js';import settingsStore from '#lib/stores/config-store.svelte.js';import { environmentStore } from '#lib/stores/environment.store.svelte.js';+ import { COMPOSE_PROJECT_LABEL, COMPOSE_SERVICE_LABEL } from '#lib/utils/docker.js';let {- containerId+ containerId,+ labels,+ name}: {containerId: string | undefined;+ labels: Record<string, string> | null | undefined;+ name: string | undefined;} = $props();+ const savedShells = new PersistedState<Record<string, string>>('arcane_terminal_shells', {});++ // Keyed by compose service (or container name) so the choice survives container recreation.+ const shellKey = $derived.by(() => {+ const envId = environmentStore.selected?.id ?? '0';+ const project = labels?.[COMPOSE_PROJECT_LABEL];+ const service = labels?.[COMPOSE_SERVICE_LABEL];+ if (project && service) return `${envId}:${project}/${service}`;+ if (name) return `${envId}:${name}`;+ return undefined;+ });+let isConnected = $state(false);- let selectedShell = $derived(settingsStore.current?.defaultShell || '/bin/sh');+ let selectedShell = $derived((shellKey && savedShells.current[shellKey]) || settingsStore.current?.defaultShell || '/bin/sh');let reconnectKey = $state(0);const websocketUrl = $derived.by(() => {if (!containerId || !selectedShell) return '';@@ -27,6 +45,7 @@function handleShellChange(shell: string) {selectedShell = shell;+ if (shellKey) savedShells.current = { ...savedShells.current, [shellKey]: shell };}function handleConnected() {