Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
feat: interactive shell access to containers (#611)
Copilotf9b18f141b14
diff --git a/.vscode/settings.json b/.vscode/settings.jsonindex 55b8dc0ce..a4cf87ef4 100644--- a/.vscode/settings.json+++ b/.vscode/settings.json@@ -10,5 +10,5 @@"go.buildTags": "playwright","prettier.documentSelectors": ["**/*.svelte"],"tasks.statusbar.default.hide": true,- "tasks.statusbar.limit": 8,+ "tasks.statusbar.limit": 8}diff --git a/backend/internal/api/container_handler.go b/backend/internal/api/container_handler.goindex dd35e6aeb..714463677 100644--- a/backend/internal/api/container_handler.go+++ b/backend/internal/api/container_handler.go@@ -4,6 +4,7 @@ import ("context""fmt""io"+ "log/slog""net/http""strings""sync"@@ -14,22 +15,36 @@ import ("github.com/docker/docker/api/types/network""github.com/docker/go-connections/nat""github.com/gin-gonic/gin"+ "github.com/gorilla/websocket"+ "github.com/ofkm/arcane-backend/internal/config""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware""github.com/ofkm/arcane-backend/internal/services"+ httputil "github.com/ofkm/arcane-backend/internal/utils/http""github.com/ofkm/arcane-backend/internal/utils/pagination"ws "github.com/ofkm/arcane-backend/internal/utils/ws")type ContainerHandler struct {- containerService *services.ContainerService- imageService *services.ImageService- dockerService *services.DockerClientService- logStreams sync.Map // map[string]*logStream+ containerService *services.ContainerService+ imageService *services.ImageService+ dockerService *services.DockerClientService+ logStreams sync.Map+ containerWSUpgrader websocket.Upgrader}-func NewContainerHandler(group *gin.RouterGroup, dockerService *services.DockerClientService, containerService *services.ContainerService, imageService *services.ImageService, authMiddleware *middleware.AuthMiddleware) {- handler := &ContainerHandler{dockerService: dockerService, containerService: containerService, imageService: imageService}+func NewContainerHandler(group *gin.RouterGroup, dockerService *services.DockerClientService, containerService *services.ContainerService, imageService *services.ImageService, authMiddleware *middleware.AuthMiddleware, cfg *config.Config) {+ handler := &ContainerHandler{+ dockerService: dockerService,+ containerService: containerService,+ imageService: imageService,+ containerWSUpgrader: websocket.Upgrader{+ CheckOrigin: httputil.ValidateWebSocketOrigin(cfg.AppUrl),+ ReadBufferSize: 32 * 1024,+ WriteBufferSize: 32 * 1024,+ EnableCompression: true,+ },+ }apiGroup := group.Group("/environments/:id/containers")apiGroup.Use(authMiddleware.WithAdminNotRequired().Add())@@ -44,6 +59,7 @@ func NewContainerHandler(group *gin.RouterGroup, dockerService *services.DockerCapiGroup.POST("/:containerId/stop", handler.Stop)apiGroup.POST("/:containerId/restart", handler.Restart)apiGroup.GET("/:containerId/logs/ws", handler.GetLogsWS)+ apiGroup.GET("/:containerId/exec/ws", handler.GetExecWS)apiGroup.DELETE("/:containerId", handler.Delete)}@@ -70,18 +86,30 @@ func (h *ContainerHandler) getOrStartContainerLogHub(containerID, format string,ls.cancel = cancelgo ls.hub.Run(ctx)- // Always pull raw lines first+ slog.Debug("starting log stream pipeline", "containerID", containerID, "format", format, "batched", batched)+lines := make(chan string, 256)go func() {- defer close(lines)- _ = h.containerService.StreamLogs(ctx, containerID, lines, follow, tail, since, timestamps)+ defer func() {+ close(lines)+ slog.Debug("lines channel closed", "containerID", containerID)+ }()++ if err := h.containerService.StreamLogs(ctx, containerID, lines, follow, tail, since, timestamps); err != nil {+ slog.Error("StreamLogs failed", "containerID", containerID, "err", err)+ }}()if format == "json" {msgs := make(chan ws.LogMessage, 256)go func() {- defer close(msgs)+ defer func() {+ close(msgs)+ slog.Debug("msgs channel closed", "containerID", containerID)+ }()+ lineCount := 0for line := range lines {+ lineCount++level, msg, ts := ws.NormalizeContainerLine(line)seq := ls.seq.Add(1)timestamp := ts@@ -102,7 +130,6 @@ func (h *ContainerHandler) getOrStartContainerLogHub(containerID, format string,go ws.ForwardLogJSON(ctx, ls.hub, msgs)}} else {- // Plain text mode still strips ANSI & timestamps for consistencycleanChan := make(chan string, 256)go func() {defer close(cleanChan)@@ -137,12 +164,135 @@ func (h *ContainerHandler) GetLogsWS(c *gin.Context) {format := c.DefaultQuery("format", "text")batched := c.DefaultQuery("batched", "false") == "true"- conn, err := wsUpgrader.Upgrade(c.Writer, c.Request, nil)+ conn, err := h.containerWSUpgrader.Upgrade(c.Writer, c.Request, nil)if err != nil {+ slog.Error("Failed to upgrade websocket connection", "err", err)return}++ slog.Debug("websocket connection upgraded", "containerID", containerID)+hub := h.getOrStartContainerLogHub(containerID, format, batched, follow, tail, since, timestamps)ws.ServeClient(context.Background(), hub, conn)+ slog.Debug("websocket connection closed", "containerID", containerID)+}++// GET /api/environments/:id/containers/:containerId/exec/ws+func (h *ContainerHandler) GetExecWS(c *gin.Context) {+ containerID := c.Param("containerId")+ if strings.TrimSpace(containerID) == "" {+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": "Container ID is required"}})+ return+ }++ shell := c.DefaultQuery("shell", "/bin/sh")++ conn, err := h.containerWSUpgrader.Upgrade(c.Writer, c.Request, nil)+ if err != nil {+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": "Failed to upgrade connection: " + err.Error()}})+ return+ }+ defer conn.Close()++ ctx, cancel := context.WithCancel(c.Request.Context())+ defer cancel()++ execID, err := h.containerService.CreateExec(ctx, containerID, []string{shell})+ if err != nil {+ _ = conn.WriteMessage(websocket.TextMessage, []byte(fmt.Sprintf("Error creating exec: %v\r\n", err)))+ return+ }++ stdin, stdout, err := h.containerService.AttachExec(ctx, execID)+ if err != nil {+ _ = conn.WriteMessage(websocket.TextMessage, []byte(fmt.Sprintf("Error attaching to exec: %v\r\n", err)))+ return+ }+ defer func() {+ if closeErr := stdin.Close(); closeErr != nil {+ _ = conn.WriteMessage(websocket.TextMessage, []byte(fmt.Sprintf("Error closing stdin: %v\r\n", closeErr)))+ }+ }()++ done := make(chan struct{})+ readErr := make(chan error, 1)+ writeErr := make(chan error, 1)++ go h.execOutputPump(ctx, stdout, conn, done, writeErr)+ go h.execInputPump(stdin, conn, cancel, readErr, writeErr)++ h.waitForExecCompletion(conn, done, readErr, writeErr, ctx)+}++func (h *ContainerHandler) execOutputPump(ctx context.Context, stdout io.Reader, conn *websocket.Conn, done chan struct{}, writeErr chan error) {+ defer close(done)+ buf := make([]byte, 8192)+ for {+ select {+ case <-ctx.Done():+ return+ default:+ n, err := stdout.Read(buf)+ if n > 0 {+ if err := conn.WriteMessage(websocket.BinaryMessage, buf[:n]); err != nil {+ select {+ case writeErr <- err:+ default:+ }+ return+ }+ }+ if err != nil {+ if err != io.EOF {+ select {+ case writeErr <- err:+ default:+ }+ }+ return+ }+ }+ }+}++func (h *ContainerHandler) execInputPump(stdin io.WriteCloser, conn *websocket.Conn, cancel context.CancelFunc, readErr, writeErr chan error) {+ for {+ messageType, data, err := conn.ReadMessage()+ if err != nil {+ if !websocket.IsCloseError(err, websocket.CloseNormalClosure, websocket.CloseGoingAway) {+ select {+ case readErr <- fmt.Errorf("read message error: %w", err):+ default:+ }+ }+ cancel()+ return+ }+ if messageType == websocket.BinaryMessage || messageType == websocket.TextMessage {+ if _, err := stdin.Write(data); err != nil {+ select {+ case writeErr <- fmt.Errorf("stdin write error: %w", err):+ default:+ }+ return+ }+ }+ }+}++func (h *ContainerHandler) waitForExecCompletion(conn *websocket.Conn, done chan struct{}, readErr, writeErr chan error, ctx context.Context) {+ select {+ case <-done:+ case err := <-readErr:+ if err != nil {+ _ = conn.WriteMessage(websocket.TextMessage, []byte(fmt.Sprintf("\r\nRead error: %v\r\n", err)))+ }+ case err := <-writeErr:+ if err != nil {+ _ = conn.WriteMessage(websocket.TextMessage, []byte(fmt.Sprintf("\r\nWrite error: %v\r\n", err)))+ }+ case <-ctx.Done():+ }}func (h *ContainerHandler) PullImage(c *gin.Context) {diff --git a/backend/internal/api/project_handler.go b/backend/internal/api/project_handler.goindex c258a802a..add870c33 100644--- a/backend/internal/api/project_handler.go+++ b/backend/internal/api/project_handler.go@@ -12,10 +12,12 @@ import ("github.com/gin-gonic/gin""github.com/gorilla/websocket"+ "github.com/ofkm/arcane-backend/internal/config""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware""github.com/ofkm/arcane-backend/internal/services""github.com/ofkm/arcane-backend/internal/utils"+ httputil "github.com/ofkm/arcane-backend/internal/utils/http""github.com/ofkm/arcane-backend/internal/utils/pagination"ws "github.com/ofkm/arcane-backend/internal/utils/ws")@@ -23,13 +25,7 @@ import (type ProjectHandler struct {projectService *services.ProjectServicelogStreams sync.Map-}--var wsUpgrader = websocket.Upgrader{- CheckOrigin: func(r *http.Request) bool { return true },- ReadBufferSize: 32 * 1024,- WriteBufferSize: 32 * 1024,- EnableCompression: true,+ wsUpgrader websocket.Upgrader}type projectLogStream struct {@@ -40,9 +36,17 @@ type projectLogStream struct {seq atomic.Uint64}-func NewProjectHandler(group *gin.RouterGroup, projectService *services.ProjectService, authMiddleware *middleware.AuthMiddleware) {+func NewProjectHandler(group *gin.RouterGroup, projectService *services.ProjectService, authMiddleware *middleware.AuthMiddleware, cfg *config.Config) {- handler := &ProjectHandler{projectService: projectService}+ handler := &ProjectHandler{+ projectService: projectService,+ wsUpgrader: websocket.Upgrader{+ CheckOrigin: httputil.ValidateWebSocketOrigin(cfg.AppUrl),+ ReadBufferSize: 32 * 1024,+ WriteBufferSize: 32 * 1024,+ EnableCompression: true,+ },+ }apiGroup := group.Group("/environments/:id/projects")apiGroup.Use(authMiddleware.WithAdminNotRequired().Add())@@ -383,7 +387,7 @@ func (h *ProjectHandler) GetProjectLogsWS(c *gin.Context) {format := c.DefaultQuery("format", "text")batched := c.DefaultQuery("batched", "false") == "true"- conn, err := wsUpgrader.Upgrade(c.Writer, c.Request, nil)+ conn, err := h.wsUpgrader.Upgrade(c.Writer, c.Request, nil)if err != nil {return}diff --git a/backend/internal/api/system_handler.go b/backend/internal/api/system_handler.goindex 9bc322c45..df75e014c 100644--- a/backend/internal/api/system_handler.go+++ b/backend/internal/api/system_handler.go@@ -10,27 +10,32 @@ import ("github.com/docker/docker/api/types/image""github.com/gin-gonic/gin""github.com/gorilla/websocket"+ "github.com/ofkm/arcane-backend/internal/config""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware""github.com/ofkm/arcane-backend/internal/models""github.com/ofkm/arcane-backend/internal/services"+ httputil "github.com/ofkm/arcane-backend/internal/utils/http""github.com/shirou/gopsutil/v3/cpu""github.com/shirou/gopsutil/v3/disk""github.com/shirou/gopsutil/v3/host""github.com/shirou/gopsutil/v3/mem")-var sysWsUpgrader = websocket.Upgrader{- CheckOrigin: func(r *http.Request) bool { return true },-}-type SystemHandler struct {dockerService *services.DockerClientServicesystemService *services.SystemService+ sysWsUpgrader websocket.Upgrader}-func NewSystemHandler(group *gin.RouterGroup, dockerService *services.DockerClientService, systemService *services.SystemService, authMiddleware *middleware.AuthMiddleware) {- handler := &SystemHandler{dockerService: dockerService, systemService: systemService}+func NewSystemHandler(group *gin.RouterGroup, dockerService *services.DockerClientService, systemService *services.SystemService, authMiddleware *middleware.AuthMiddleware, cfg *config.Config) {+ handler := &SystemHandler{+ dockerService: dockerService,+ systemService: systemService,+ sysWsUpgrader: websocket.Upgrader{+ CheckOrigin: httputil.ValidateWebSocketOrigin(cfg.AppUrl),+ },+ }apiGroup := group.Group("/environments/:id/system")apiGroup.Use(authMiddleware.WithAdminNotRequired().Add())@@ -242,7 +247,7 @@ func (h *SystemHandler) StopAllContainers(c *gin.Context) {//nolint:gocognitfunc (h *SystemHandler) Stats(c *gin.Context) {- conn, err := sysWsUpgrader.Upgrade(c.Writer, c.Request, nil)+ conn, err := h.sysWsUpgrader.Upgrade(c.Writer, c.Request, nil)if err != nil {return}diff --git a/backend/internal/bootstrap/router_bootstrap.go b/backend/internal/bootstrap/router_bootstrap.goindex d85baa277..f2a9422e6 100644--- a/backend/internal/bootstrap/router_bootstrap.go+++ b/backend/internal/bootstrap/router_bootstrap.go@@ -28,9 +28,11 @@ func setupRouter(cfg *config.Config, appServices *Services) *gin.Engine {router.Use(gin.Recovery())loggerSkipPatterns := []string{- "GET /api/*/*/stats/ws",- "GET /api/system/stats/ws",- "GET /api/*/*/logs/ws",+ // "GET /api/environments/*/containers/*/logs/ws",+ "GET /api/environments/*/containers/*/stats/ws",+ "GET /api/environments/*/system/stats/ws",+ "GET /api/environments/*/projects/*/logs/ws",+ "GET /api/environments/*/containers/*/exec/ws","GET /_app/*","GET /img","GET /fonts",@@ -89,12 +91,12 @@ func setupRouter(cfg *config.Config, appServices *Services) *gin.Engine {apiGroup.Use(envMiddleware)api.NewHealthHandler(apiGroup)- api.NewContainerHandler(apiGroup, appServices.Docker, appServices.Container, appServices.Image, authMiddleware)+ api.NewContainerHandler(apiGroup, appServices.Docker, appServices.Container, appServices.Image, authMiddleware, cfg)api.NewImageHandler(apiGroup, appServices.Docker, appServices.Image, appServices.ImageUpdate, authMiddleware)api.NewImageUpdateHandler(apiGroup, appServices.ImageUpdate, authMiddleware)api.NewNetworkHandler(apiGroup, appServices.Docker, appServices.Network, authMiddleware)- api.NewProjectHandler(apiGroup, appServices.Project, authMiddleware)- api.NewSystemHandler(apiGroup, appServices.Docker, appServices.System, authMiddleware)+ api.NewProjectHandler(apiGroup, appServices.Project, authMiddleware, cfg)+ api.NewSystemHandler(apiGroup, appServices.Docker, appServices.System, authMiddleware, cfg)api.NewUpdaterHandler(apiGroup, appServices.Updater, authMiddleware)api.NewVolumeHandler(apiGroup, appServices.Docker, appServices.Volume, authMiddleware)diff --git a/backend/internal/dto/settings_dto.go b/backend/internal/dto/settings_dto.goindex d8228f2ad..52bd45d6b 100644--- a/backend/internal/dto/settings_dto.go+++ b/backend/internal/dto/settings_dto.go@@ -21,6 +21,7 @@ type UpdateSettingsDto struct {PruneMode *string `json:"dockerPruneMode,omitempty" binding:"omitempty,oneof=all dangling"`BaseServerURL *string `json:"baseServerUrl,omitempty"`EnableGravatar *string `json:"enableGravatar,omitempty"`+ DefaultShell *string `json:"defaultShell,omitempty"`// Authentication settingsAuthLocalEnabled *string `json:"authLocalEnabled,omitempty"`diff --git a/backend/internal/models/settings.go b/backend/internal/models/settings.goindex 54e6bb8e7..65c669791 100644--- a/backend/internal/models/settings.go+++ b/backend/internal/models/settings.go@@ -52,6 +52,7 @@ type Settings struct {PruneMode SettingVariable `key:"dockerPruneMode"`BaseServerURL SettingVariable `key:"baseServerUrl"`EnableGravatar SettingVariable `key:"enableGravatar"`+ DefaultShell SettingVariable `key:"defaultShell"`// AuthenticationAuthLocalEnabled SettingVariable `key:"authLocalEnabled,public"`diff --git a/backend/internal/services/container_service.go b/backend/internal/services/container_service.goindex ee8d35118..f19c0524a 100644--- a/backend/internal/services/container_service.go+++ b/backend/internal/services/container_service.go@@ -504,3 +504,45 @@ func (s *ContainerService) ListContainersPaginated(ctx context.Context, params preturn result.Items, paginationResp, nil}++// CreateExec creates an exec instance in the container+func (s *ContainerService) CreateExec(ctx context.Context, containerID string, cmd []string) (string, error) {+ dockerClient, err := s.dockerService.CreateConnection(ctx)+ if err != nil {+ return "", fmt.Errorf("failed to connect to Docker: %w", err)+ }+ defer dockerClient.Close()++ execConfig := container.ExecOptions{+ AttachStdin: true,+ AttachStdout: true,+ AttachStderr: true,+ Tty: true,+ Cmd: cmd,+ }++ execResp, err := dockerClient.ContainerExecCreate(ctx, containerID, execConfig)+ if err != nil {+ return "", fmt.Errorf("failed to create exec: %w", err)+ }++ return execResp.ID, nil+}++// AttachExec attaches to an exec instance and returns stdin, stdout/stderr streams+func (s *ContainerService) AttachExec(ctx context.Context, execID string) (io.WriteCloser, io.Reader, error) {+ dockerClient, err := s.dockerService.CreateConnection(ctx)+ if err != nil {+ return nil, nil, fmt.Errorf("failed to connect to Docker: %w", err)+ }+ defer dockerClient.Close()++ execAttach, err := dockerClient.ContainerExecAttach(ctx, execID, container.ExecAttachOptions{+ Tty: true,+ })+ if err != nil {+ return nil, nil, fmt.Errorf("failed to attach to exec: %w", err)+ }++ return execAttach.Conn, execAttach.Reader, nil+}diff --git a/backend/internal/services/settings_service.go b/backend/internal/services/settings_service.goindex 0eb147d9d..a786bd30a 100644--- a/backend/internal/services/settings_service.go+++ b/backend/internal/services/settings_service.go@@ -84,6 +84,7 @@ func (s *SettingsService) getDefaultSettings() *models.Settings {PruneMode: models.SettingVariable{Value: "dangling"},BaseServerURL: models.SettingVariable{Value: "http://localhost"},EnableGravatar: models.SettingVariable{Value: "true"},+ DefaultShell: models.SettingVariable{Value: "/bin/sh"},AuthLocalEnabled: models.SettingVariable{Value: "true"},AuthOidcEnabled: models.SettingVariable{Value: "false"},AuthSessionTimeout: models.SettingVariable{Value: "1440"},diff --git a/backend/internal/utils/http/request.go b/backend/internal/utils/http/request.goindex 5519cc492..220a42182 100644--- a/backend/internal/utils/http/request.go+++ b/backend/internal/utils/http/request.go@@ -2,11 +2,65 @@ package httpimport ("fmt"+ "net/http"+ "net/url""strconv"+ "strings""github.com/gin-gonic/gin")+// ValidateWebSocketOrigin validates the Origin header for WebSocket connections+// to prevent CSRF attacks. It checks:+// 1. Same-origin requests (Origin matches Host)+// 2. Allowed origins from appURL+// 3. Handles empty Origin headers (some clients don't send it)+func ValidateWebSocketOrigin(appURL string) func(r *http.Request) bool {+ return func(r *http.Request) bool {+ origin := r.Header.Get("Origin")++ if origin == "" {+ return true+ }++ originURL, err := url.Parse(origin)+ if err != nil {+ return false+ }++ if originURL.Host == r.Host {+ return true+ }++ appURLParsed, err := url.Parse(appURL)+ if err != nil {+ return false+ }+ if originURL.Host == appURLParsed.Host {+ return true+ }++ if isLocalhost(originURL.Host) && isLocalhost(r.Host) {+ return true+ }++ return false+ }+}++func isLocalhost(host string) bool {+ hostOnly := host+ if idx := strings.LastIndex(host, ":"); idx != -1 {+ hostOnly = host[:idx]+ }++ return hostOnly == "localhost" ||+ hostOnly == "127.0.0.1" ||+ hostOnly == "::1" ||+ strings.HasPrefix(hostOnly, "127.") ||+ hostOnly == "[::1]"+}+// GetQueryParam reads a string query parameter from the Gin context.// If `required` is true and the parameter is missing or empty, an error is returned.func GetQueryParam(c *gin.Context, name string, required bool) (string, error) {diff --git a/backend/internal/utils/ws/client.go b/backend/internal/utils/ws/client.goindex 8725c9da5..13e8f9a52 100644--- a/backend/internal/utils/ws/client.go+++ b/backend/internal/utils/ws/client.go@@ -3,6 +3,7 @@ package wsimport ("context""log/slog"+ "strings""sync""time"@@ -68,7 +69,9 @@ func (c *Client) readPump(ctx context.Context, hub *Hub) {default:// We ignore application messages; reads are only for control frames (close/pong).if _, _, err := c.conn.ReadMessage(); err != nil {- slog.Debug("websocket readPump end", "err", err)+ if !isExpectedCloseError(err) {+ slog.Debug("websocket readPump end", "err", err)+ }return}}@@ -95,7 +98,9 @@ func (c *Client) writePump(ctx context.Context, hub *Hub) {return}if err := c.conn.WriteMessage(websocket.TextMessage, msg); err != nil {- slog.Debug("websocket write error", "err", err)+ if !isExpectedCloseError(err) {+ slog.Debug("websocket write error", "err", err)+ }return}case <-ticker.C:@@ -106,3 +111,21 @@ func (c *Client) writePump(ctx context.Context, hub *Hub) {}}}++func isExpectedCloseError(err error) bool {+ if err == nil {+ return true+ }++ if websocket.IsCloseError(err,+ websocket.CloseNormalClosure,+ websocket.CloseGoingAway,+ websocket.CloseNoStatusReceived) {+ return true+ }++ errStr := err.Error()+ return strings.Contains(errStr, "use of closed network connection") ||+ strings.Contains(errStr, "connection reset by peer") ||+ strings.Contains(errStr, "broken pipe")+}diff --git a/frontend/messages/en.json b/frontend/messages/en.jsonindex 91944b923..7bfe1e78e 100644--- a/frontend/messages/en.json+++ b/frontend/messages/en.json@@ -134,8 +134,11 @@"general_save_instructions": "Save your updated settings.","docker_enable_polling_label": "Enable Image Polling","docker_enable_polling_description": "Periodically check registries for newer image versions",+ "docker_image_polling_title": "Image Polling",+ "docker_image_polling_description": "Configure automatic image update checking","docker_polling_interval_label": "Polling Interval","docker_polling_interval_placeholder": "60",+ "docker_polling_interval_placeholder_select": "Select interval","docker_polling_interval_description": "How often to check for new images (5-10080 minutes)","docker_auto_update_label": "Auto-update Containers","docker_auto_update_description": "Automatically update containers when newer images are found",@@ -156,6 +159,22 @@"docker_prune_group_label": "Prune Modes","docker_title": "Docker","docker_description": "Configure Docker automation behavior and settings.",+ "docker_terminal_settings_title": "Terminal Settings",+ "docker_terminal_settings_description": "Configure default shell for container terminals",+ "docker_default_shell_label": "Default Shell",+ "docker_default_shell_description": "The default shell to use when opening a terminal in a container",+ "docker_default_shell_placeholder": "Select shell",+ "docker_shell_sh_description": "/bin/sh",+ "docker_shell_bash_description": "/bin/bash",+ "docker_shell_ash_description": "/bin/ash",+ "docker_shell_zsh_description": "/bin/zsh",+ "docker_shell_custom_description": "Specify a custom shell path",+ "docker_shell_custom_path_placeholder": "/bin/sh",+ "docker_shell_custom_path_help": "Enter the full path to the shell executable",+ "docker_cleanup_settings_title": "Cleanup Settings",+ "docker_cleanup_settings_description": "Configure how Docker images are pruned",+ "docker_auto_updates_title": "Auto Updates",+ "docker_auto_updates_description": "Automatically update containers when new images are available","networks_delete_title": "Delete Network","networks_delete_confirm_message": "Are you sure you want to delete network \"{name}\"? This action cannot be undone.","networks_delete_failed": "Failed to Remove Network \"{name}\"",@@ -1141,5 +1160,13 @@"dashboard_meter_disk_used": "Used","dashboard_meter_disk_free": "Free","dashboard_meter_disk_total": "Total",- "dashboard_docker_overview": "Docker Overview"+ "dashboard_docker_overview": "Docker Overview",+ "shell_title": "Shell",+ "shell_interactive_access": "Interactive shell access to container",+ "shell_select_placeholder": "Select shell",+ "shell_custom_placeholder": "/usr/bin/fish",+ "apply": "Apply",+ "terminal_websocket_error": "WebSocket error occurred",+ "terminal_connection_closed": "Connection closed",+ "shell": "Shell"}diff --git a/frontend/package.json b/frontend/package.jsonindex cd5afcf0c..76cb8d5d0 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -26,6 +26,8 @@"@tanstack/table-core": "^8.21.3","@uiw/codemirror-theme-github": "^4.25.2","@uiw/codemirror-themes": "^4.25.2",+ "@xterm/addon-fit": "^0.10.0",+ "@xterm/xterm": "^5.5.0","axios": "^1.12.2","codemirror": "^6.0.2","date-fns": "^4.1.0",diff --git a/frontend/src/lib/components/log-viewer.svelte b/frontend/src/lib/components/log-viewer.svelteindex af1a68dd7..16e51f1d7 100644--- a/frontend/src/lib/components/log-viewer.svelte+++ b/frontend/src/lib/components/log-viewer.svelte@@ -5,6 +5,7 @@import { m } from '$lib/paraglide/messages';import { ReconnectingWebSocket } from '$lib/utils/ws';import { cn } from '$lib/utils';+ import { onDestroy } from 'svelte';interface LogEntry {id: number;@@ -123,6 +124,7 @@let logContainer: HTMLElement | undefined = $state();let isStreaming = $state(false);+ let shouldBeStreaming = $state(false);let error: string | null = $state(null);let eventSource: EventSource | null = null;let wsClient: ReconnectingWebSocket<string> | null = null;@@ -154,6 +156,7 @@if (!targetId) return;try {+ shouldBeStreaming = true;isStreaming = true;error = null;onStart?.();@@ -163,6 +166,7 @@console.error('Failed to start log stream:', err);error = m.log_stream_failed_connect({ type: humanType });isStreaming = false;+ shouldBeStreaming = false;}}@@ -198,10 +202,11 @@},onClose: () => {isStreaming = false;- if (!error) {+ if (!error && shouldBeStreaming) {error = m.log_stream_closed_by_server({ type: humanType });}},+ shouldReconnect: () => shouldBeStreaming,maxBackoff: 10000});@@ -222,6 +227,8 @@}export function stopLogStream() {+ shouldBeStreaming = false;+if (eventSource) {if (dev) console.log(m.log_viewer_stopping({ type: humanType }));eventSource.close();@@ -250,6 +257,10 @@scheduleFlush();}+ onDestroy(() => {+ stopLogStream();+ });+export function toggleAutoScroll() {autoScroll = !autoScroll;onToggleAutoScroll?.();@@ -292,7 +303,7 @@});</script>-<div class={cn('log-viewer rounded-t-none rounded-b-xl border bg-black text-white', className)}>+<div class={cn('log-viewer rounded-b-xl rounded-t-none border bg-black text-white', className)}>{#if error}<div class="border-b border-red-700 bg-red-900/20 p-3 text-sm text-red-200">{error}@@ -301,7 +312,7 @@<divbind:this={logContainer}- class="log-viewer overflow-y-auto rounded-t-none rounded-b-xl border bg-black font-mono text-xs text-white sm:text-sm"+ class="log-viewer overflow-y-auto rounded-b-xl rounded-t-none border bg-black font-mono text-xs text-white sm:text-sm"style="height: {height}; min-height: 300px;"role="log"aria-live={isStreaming ? 'polite' : 'off'}@@ -341,7 +352,7 @@</span>{/if}</div>- <div class="text-sm break-words whitespace-pre-wrap text-gray-300">+ <div class="whitespace-pre-wrap break-words text-sm text-gray-300">{log.message}</div></div>@@ -362,7 +373,7 @@{log.service}</span>{/if}- <span class="flex-1 break-words whitespace-pre-wrap text-gray-300">+ <span class="flex-1 whitespace-pre-wrap break-words text-gray-300">{log.message}</span></div>diff --git a/frontend/src/lib/components/terminal/terminal-header.svelte b/frontend/src/lib/components/terminal/terminal-header.sveltenew file mode 100644index 000000000..f274448b0--- /dev/null+++ b/frontend/src/lib/components/terminal/terminal-header.svelte@@ -0,0 +1,108 @@+<script lang="ts">+ import * as Select from '$lib/components/ui/select/index.js';+ import { Button } from '$lib/components/ui/button/index.js';+ import { Input } from '$lib/components/ui/input/index.js';+ import TerminalIcon from '@lucide/svelte/icons/terminal';+ import RefreshCwIcon from '@lucide/svelte/icons/refresh-cw';+ import { m } from '$lib/paraglide/messages';++ let {+ isConnected = false,+ selectedShell = $bindable(),+ onShellChange,+ onReconnect+ }: {+ isConnected?: boolean;+ selectedShell: string;+ onShellChange?: (shell: string) => void;+ onReconnect?: () => void;+ } = $props();++ let customShell = $state('');+ let useCustomShell = $state(false);++ const commonShells = [+ { value: '/bin/sh', label: 'sh' },+ { value: '/bin/bash', label: 'bash' },+ { value: '/bin/ash', label: 'ash' },+ { value: '/bin/zsh', label: 'zsh' },+ { value: 'custom', label: m.custom() }+ ];++ const shellLabels: Record<string, string> = {+ '/bin/sh': 'sh',+ '/bin/bash': 'bash',+ '/bin/ash': 'ash',+ '/bin/zsh': 'zsh',+ custom: m.custom()+ };++ function handleShellChange(value: string | undefined) {+ if (!value) return;++ if (value === 'custom') {+ useCustomShell = true;+ selectedShell = value;+ } else {+ useCustomShell = false;+ selectedShell = value;+ onShellChange?.(value);+ }+ }++ function handleCustomShellSubmit() {+ if (customShell.trim()) {+ onShellChange?.(customShell);+ }+ }+</script>++<div class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">+ <div class="flex items-center gap-2">+ <TerminalIcon class="text-primary size-5" />+ <h2 class="text-lg font-semibold">{m.shell_title()}</h2>+ {#if isConnected}+ <div class="flex items-center gap-2">+ <div class="size-2 animate-pulse rounded-full bg-green-500"></div>+ <span class="text-xs font-semibold text-green-600 sm:text-sm">{m.common_live()}</span>+ </div>+ {/if}+ </div>++ <div class="flex items-center gap-2">+ <Select.Root bind:value={selectedShell} type="single" onValueChange={handleShellChange}>+ <Select.Trigger class="h-8 w-[140px]">+ {shellLabels[selectedShell] ?? m.shell_select_placeholder()}+ </Select.Trigger>+ <Select.Content>+ {#each commonShells as shell}+ <Select.Item value={shell.value}>+ {shell.label}+ </Select.Item>+ {/each}+ </Select.Content>+ </Select.Root>++ {#if useCustomShell}+ <Input+ type="text"+ bind:value={customShell}+ placeholder={m.shell_custom_placeholder()}+ class="h-8 w-[180px]"+ onkeydown={(e) => {+ if (e.key === 'Enter') {+ handleCustomShellSubmit();+ }+ }}+ />+ <Button size="sm" variant="outline" onclick={handleCustomShellSubmit} class="h-8">+ {m.apply()}+ </Button>+ {/if}++ <!-- Reconnect Button -->+ <Button size="icon" variant="ghost" onclick={onReconnect} class="size-8" title="Reconnect shell">+ <RefreshCwIcon class="size-4" />+ </Button>+ </div>+</div>diff --git a/frontend/src/lib/components/terminal/terminal.svelte b/frontend/src/lib/components/terminal/terminal.sveltenew file mode 100644index 000000000..d2a1f250a--- /dev/null+++ b/frontend/src/lib/components/terminal/terminal.svelte@@ -0,0 +1,176 @@+<script lang="ts">+ import { onMount, onDestroy } from 'svelte';+ import { Terminal } from '@xterm/xterm';+ import { FitAddon } from '@xterm/addon-fit';+ import '@xterm/xterm/css/xterm.css';+ import { m } from '$lib/paraglide/messages';++ let {+ websocketUrl,+ height = '100%',+ onConnected,+ onDisconnected+ }: {+ websocketUrl: string;+ height?: string;+ onConnected?: () => void;+ onDisconnected?: () => void;+ } = $props();++ let container: HTMLDivElement;+ let terminal: Terminal | null = null;+ let fitAddon: FitAddon | null = null;+ let ws: WebSocket | null = null;+ let isReconnecting = false;+ let resizeObserver: ResizeObserver | null = null;++ function initializeTerminal() {+ if (!container) return;++ if (terminal) {+ terminal.dispose();+ }++ terminal = new Terminal({+ cursorBlink: true,+ cursorStyle: 'underline',+ fontSize: 14,+ fontFamily: 'Geist Mono, monospace',+ theme: {+ background: '#09090b',+ foreground: '#e4e4e7',+ cursor: '#e4e4e7',+ black: '#18181b',+ red: '#f87171',+ green: '#4ade80',+ yellow: '#facc15',+ blue: '#60a5fa',+ magenta: '#c084fc',+ cyan: '#22d3ee',+ white: '#e4e4e7',+ brightBlack: '#52525b',+ brightRed: '#fca5a5',+ brightGreen: '#86efac',+ brightYellow: '#fde047',+ brightBlue: '#93c5fd',+ brightMagenta: '#d8b4fe',+ brightCyan: '#67e8f9',+ brightWhite: '#fafafa'+ }+ });++ fitAddon = new FitAddon();+ terminal.loadAddon(fitAddon);+ terminal.open(container);++ requestAnimationFrame(() => {+ if (fitAddon && container.offsetParent !== null) {+ fitAddon.fit();+ }+ });++ terminal.onData((data) => {+ if (ws && ws.readyState === WebSocket.OPEN) {+ ws.send(data);+ }+ });++ resizeObserver = new ResizeObserver(() => {+ handleResize();+ });+ resizeObserver.observe(container);+ }++ function connectWebSocket() {+ if (ws) {+ isReconnecting = true;+ ws.onclose = null;+ ws.onerror = null;+ ws.onmessage = null;+ ws.close();+ ws = null;+ }++ isReconnecting = false;+ ws = new WebSocket(websocketUrl);+ ws.binaryType = 'arraybuffer';++ ws.onopen = () => {+ onConnected?.();+ };++ ws.onmessage = (event) => {+ if (!terminal) return;+ if (event.data instanceof ArrayBuffer) {+ const uint8Array = new Uint8Array(event.data);+ const text = new TextDecoder().decode(uint8Array);+ terminal.write(text);+ } else {+ terminal.write(event.data);+ }+ };++ ws.onerror = () => {+ if (!isReconnecting && terminal) {+ terminal.writeln(`\r\n\x1b[31m${m.terminal_websocket_error()}\x1b[0m`);+ }+ };++ ws.onclose = () => {+ if (!isReconnecting && terminal) {+ terminal.writeln(`\r\n\x1b[33m${m.terminal_connection_closed()}\x1b[0m`);+ onDisconnected?.();+ }+ };+ }++ function handleResize() {+ if (fitAddon && container && container.offsetParent !== null) {+ try {+ fitAddon.fit();+ } catch (e) {+ console.warn('Terminal resize failed:', e);+ }+ }+ }++ onMount(() => {+ initializeTerminal();+ connectWebSocket();+ window.addEventListener('resize', handleResize);++ return () => {+ window.removeEventListener('resize', handleResize);+ resizeObserver?.disconnect();+ isReconnecting = true;+ ws?.close();+ terminal?.dispose();+ };+ });++ $effect(() => {+ if (websocketUrl && terminal) {+ terminal.clear();+ connectWebSocket();+ }+ });++ onDestroy(() => {+ resizeObserver?.disconnect();+ isReconnecting = true;+ ws?.close();+ terminal?.dispose();+ });+</script>++<div bind:this={container} class="terminal-container h-full w-full" style="height: {height}"></div>++<style>+ :global(.terminal-container .xterm) {+ padding: 8px 12px;+ }++ :global(.terminal-container .xterm-viewport) {+ background-color: transparent !important;+ }+</style>diff --git a/frontend/src/lib/types/settings.type.ts b/frontend/src/lib/types/settings.type.tsindex 47cfadcb4..74a79f0b2 100644--- a/frontend/src/lib/types/settings.type.ts+++ b/frontend/src/lib/types/settings.type.ts@@ -17,6 +17,7 @@ export type Settings = {baseServerUrl: string;enableGravatar: boolean;uiConfigDisabled: boolean;+ defaultShell: string;authLocalEnabled: boolean;authOidcEnabled: boolean;diff --git a/frontend/src/lib/utils/ws.ts b/frontend/src/lib/utils/ws.tsindex fb3603695..19564d969 100644--- a/frontend/src/lib/utils/ws.ts+++ b/frontend/src/lib/utils/ws.ts@@ -9,6 +9,7 @@ export interface ReconnectWSOptions<T> {onError?: (err: Event | Error) => void;maxBackoff?: number;autoConnect?: boolean;+ shouldReconnect?: () => boolean;}export class ReconnectingWebSocket<T = unknown> {@@ -18,6 +19,7 @@ export class ReconnectingWebSocket<T = unknown> {private readonly maxBackoff: number;private opts: ReconnectWSOptions<T>;private connecting = false;+ private reconnectTimer: ReturnType<typeof setTimeout> | null = null;constructor(opts: ReconnectWSOptions<T>) {this.opts = opts;@@ -64,7 +66,6 @@ export class ReconnectingWebSocket<T = unknown> {const parser =this.opts.parseMessage ??((e: MessageEvent) => {- // default: try JSON.parse for string payloads, else return raw dataif (typeof e.data === 'string') return JSON.parse(e.data) as unknown as T;return e.data as unknown as T;});@@ -87,11 +88,21 @@ export class ReconnectingWebSocket<T = unknown> {}private scheduleReconnect() {+ if (this.opts.shouldReconnect && !this.opts.shouldReconnect()) {+ return;+ }++ if (this.reconnectTimer) {+ clearTimeout(this.reconnectTimer);+ }+this.attempt++;const exp = Math.min(1000 * Math.pow(1.5, this.attempt), this.maxBackoff);const jitter = Math.random() * 0.3 * exp;const backoff = exp - jitter;- setTimeout(() => {++ this.reconnectTimer = setTimeout(() => {+ this.reconnectTimer = null;if (!this.closed) this.connectOnce();}, backoff);}@@ -111,11 +122,16 @@ export class ReconnectingWebSocket<T = unknown> {close() {this.closed = true;this.attempt = 0;++ if (this.reconnectTimer) {+ clearTimeout(this.reconnectTimer);+ this.reconnectTimer = null;+ }+try {this.ws?.close();- } catch {- // ignore- }+ } catch {}+this.ws = null;this.connecting = false;}@@ -125,7 +141,6 @@ export class ReconnectingWebSocket<T = unknown> {}}-/* small convenience wrapper for the dashboard stats (keeps existing shape) */export function createStatsWebSocket(opts: {getEnvId: () => string;onMessage: (data: SystemStats) => void;diff --git a/frontend/src/routes/containers/[containerId]/+page.svelte b/frontend/src/routes/containers/[containerId]/+page.svelteindex f56dfdca9..e4b80e28b 100644--- a/frontend/src/routes/containers/[containerId]/+page.svelte+++ b/frontend/src/routes/containers/[containerId]/+page.svelte@@ -9,6 +9,7 @@import SettingsIcon from '@lucide/svelte/icons/settings';import NetworkIcon from '@lucide/svelte/icons/network';import DatabaseIcon from '@lucide/svelte/icons/database';+ import TerminalIcon from '@lucide/svelte/icons/terminal';import { invalidateAll } from '$app/navigation';import ActionButtons from '$lib/components/action-buttons.svelte';import StatusBadge from '$lib/components/badges/status-badge.svelte';@@ -27,6 +28,7 @@import ContainerNetwork from '../components/ContainerNetwork.svelte';import ContainerStorage from '../components/ContainerStorage.svelte';import ContainerLogsPanel from '../components/ContainerLogsPanel.svelte';+ import ContainerShell from '../components/ContainerShell.svelte';interface NetworkConfig {IPAddress?: string;@@ -189,11 +191,13 @@);const hasMounts = $derived(!!(container?.mounts && container.mounts.length > 0));const showStats = $derived(!!(container?.state?.running && stats));+ const showShell = $derived(!!container?.state?.running);const tabItems = $derived<TabItem[]>([{ value: 'overview', label: m.containers_nav_overview(), icon: HardDriveIcon },...(showStats ? [{ value: 'stats', label: m.containers_nav_metrics(), icon: ActivityIcon }] : []),{ value: 'logs', label: m.containers_nav_logs(), icon: FileTextIcon },+ ...(showShell ? [{ value: 'shell', label: m.shell(), icon: TerminalIcon }] : []),...(showConfiguration ? [{ value: 'config', label: m.containers_nav_config(), icon: SettingsIcon }] : []),...(hasNetworks ? [{ value: 'network', label: m.containers_nav_networks(), icon: NetworkIcon }] : []),...(hasMounts ? [{ value: 'storage', label: m.containers_nav_storage(), icon: DatabaseIcon }] : [])@@ -266,50 +270,56 @@{#snippet tabContent(activeTab)}<Tabs.Content value="overview" class="h-full">- <ContainerOverview {container} {primaryIpAddress} />+ <ContainerOverview {container} {primaryIpAddress} /></Tabs.Content>{#if showStats}<Tabs.Content value="stats" class="h-full">- <ContainerStats- {container}- {stats}- {cpuUsagePercent}- {memoryUsageBytes}- {memoryLimitBytes}- {memoryUsageFormatted}- {memoryLimitFormatted}- {memoryUsagePercent}- />+ <ContainerStats+ {container}+ {stats}+ {cpuUsagePercent}+ {memoryUsageBytes}+ {memoryLimitBytes}+ {memoryUsageFormatted}+ {memoryLimitFormatted}+ {memoryUsagePercent}+ /></Tabs.Content>{/if}<Tabs.Content value="logs" class="h-full">- <ContainerLogsPanel- containerId={container?.id}- bind:autoScroll={autoScrollLogs}- onStart={handleLogStart}- onStop={handleLogStop}- onClear={handleLogClear}- onToggleAutoScroll={handleToggleAutoScroll}- />+ <ContainerLogsPanel+ containerId={container?.id}+ bind:autoScroll={autoScrollLogs}+ onStart={handleLogStart}+ onStop={handleLogStop}+ onClear={handleLogClear}+ onToggleAutoScroll={handleToggleAutoScroll}+ /></Tabs.Content>+ {#if showShell}+ <Tabs.Content value="shell" class="h-full">+ <ContainerShell containerId={container?.id} />+ </Tabs.Content>+ {/if}+{#if showConfiguration}<Tabs.Content value="config" class="h-full">- <ContainerConfiguration {container} {hasEnvVars} {hasPorts} {hasLabels} {baseServerUrl} />+ <ContainerConfiguration {container} {hasEnvVars} {hasPorts} {hasLabels} {baseServerUrl} /></Tabs.Content>{/if}{#if hasNetworks}<Tabs.Content value="network" class="h-full">- <ContainerNetwork {container} />+ <ContainerNetwork {container} /></Tabs.Content>{/if}{#if hasMounts}<Tabs.Content value="storage" class="h-full">- <ContainerStorage {container} />+ <ContainerStorage {container} /></Tabs.Content>{/if}{/snippet}diff --git a/frontend/src/routes/containers/components/ContainerShell.svelte b/frontend/src/routes/containers/components/ContainerShell.sveltenew file mode 100644index 000000000..cf772b6af--- /dev/null+++ b/frontend/src/routes/containers/components/ContainerShell.svelte@@ -0,0 +1,77 @@+<script lang="ts">+ import * as Card from '$lib/components/ui/card/index.js';+ import Terminal from '$lib/components/terminal/terminal.svelte';+ import TerminalHeader from '$lib/components/terminal/terminal-header.svelte';+ import { m } from '$lib/paraglide/messages';+ import { environmentStore } from '$lib/stores/environment.store';+ import settingsStore from '$lib/stores/config-store';++ let {+ containerId+ }: {+ containerId: string | undefined;+ } = $props();++ let isConnected = $state(false);+ let websocketUrl = $state('');+ let selectedShell = $state($settingsStore.defaultShell || '/bin/sh');+ let reconnectKey = $state(0);++ $effect(() => {+ if ($settingsStore.defaultShell) {+ selectedShell = $settingsStore.defaultShell;+ }++ if (containerId && selectedShell) {+ updateWebSocketUrl();+ }+ });++ function updateWebSocketUrl() {+ (async () => {+ const envId = await environmentStore.getCurrentEnvironmentId();+ const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';+ const host = window.location.host;+ websocketUrl = `${protocol}//${host}/api/environments/${envId}/containers/${containerId}/exec/ws?shell=${encodeURIComponent(selectedShell)}`;+ })();+ }++ function handleShellChange(shell: string) {+ selectedShell = shell;+ updateWebSocketUrl();+ }++ function handleConnected() {+ isConnected = true;+ }++ function handleDisconnected() {+ isConnected = false;+ }++ function handleReconnect() {+ reconnectKey += 1;+ isConnected = false;+ }+</script>++<Card.Root class="flex flex-col gap-0 p-0">+ <Card.Header class="bg-muted rounded-t-xl p-4">+ <TerminalHeader {isConnected} bind:selectedShell onShellChange={handleShellChange} onReconnect={handleReconnect} />+ <Card.Description class="mt-4">{m.shell_interactive_access()}</Card.Description>+ </Card.Header>+ <Card.Content class="overflow-hidden p-2">+ <div class="h-full overflow-hidden rounded-lg border">+ {#if websocketUrl}+ {#key reconnectKey}+ <Terminal+ {websocketUrl}+ height="calc(100vh - 320px)"+ onConnected={handleConnected}+ onDisconnected={handleDisconnected}+ />+ {/key}+ {/if}+ </div>+ </Card.Content>+</Card.Root>diff --git a/frontend/src/routes/settings/docker/+page.svelte b/frontend/src/routes/settings/docker/+page.svelteindex f88b7adc2..d979aa9c4 100644--- a/frontend/src/routes/settings/docker/+page.svelte+++ b/frontend/src/routes/settings/docker/+page.svelte@@ -13,6 +13,7 @@import ActivityIcon from '@lucide/svelte/icons/activity';import RefreshCwIcon from '@lucide/svelte/icons/refresh-cw';import TrashIcon from '@lucide/svelte/icons/trash';+ import TerminalIcon from '@lucide/svelte/icons/terminal';import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';import settingsStore from '$lib/stores/config-store';import BoxesIcon from '@lucide/svelte/icons/boxes';@@ -31,7 +32,8 @@pollingInterval: z.number().int().min(5).max(10080),autoUpdate: z.boolean(),autoUpdateInterval: z.number().int(),- dockerPruneMode: z.enum(['all', 'dangling'])+ dockerPruneMode: z.enum(['all', 'dangling']),+ defaultShell: z.string()});let pruneMode = $derived(currentSettings.dockerPruneMode);@@ -94,6 +96,15 @@pruneModeOptions.find((o) => o.value === pruneMode)?.description ?? m.docker_prune_mode_description());+ const shellOptions = [+ { value: '/bin/sh', label: '/bin/sh', description: m.docker_shell_sh_description() },+ { value: '/bin/bash', label: '/bin/bash', description: m.docker_shell_bash_description() },+ { value: '/bin/ash', label: '/bin/ash', description: m.docker_shell_ash_description() },+ { value: '/bin/zsh', label: '/bin/zsh', description: m.docker_shell_zsh_description() }+ ];++ let shellSelectValue = $state<string>(shellOptions.find((o) => o.value === currentSettings.defaultShell)?.value ?? 'custom');+let { inputs: formInputs, ...form } = $derived(createForm<typeof formSchema>(formSchema, currentSettings));const formHasChanges = $derived.by(@@ -102,7 +113,8 @@$formInputs.pollingInterval.value !== currentSettings.pollingInterval ||$formInputs.autoUpdate.value !== currentSettings.autoUpdate ||$formInputs.autoUpdateInterval.value != currentSettings.autoUpdateInterval ||- $formInputs.dockerPruneMode.value != currentSettings.dockerPruneMode+ $formInputs.dockerPruneMode.value != currentSettings.dockerPruneMode ||+ $formInputs.defaultShell.value != currentSettings.defaultShell);$effect(() => {@@ -113,13 +125,18 @@}});- // Keep form value in sync with preset selection unless "custom"$effect(() => {if (pollingIntervalMode !== 'custom') {$formInputs.pollingInterval.value = presetToMinutes[pollingIntervalMode];}});+ $effect(() => {+ if (shellSelectValue !== 'custom') {+ $formInputs.defaultShell.value = shellSelectValue;+ }+ });+async function updateSettingsConfig(updatedSettings: Partial<Settings>) {try {await settingsService.updateSettings(updatedSettings as any);@@ -155,6 +172,7 @@$formInputs.autoUpdate.value = currentSettings.autoUpdate;$formInputs.autoUpdateInterval.value = currentSettings.autoUpdateInterval;$formInputs.dockerPruneMode.value = currentSettings.dockerPruneMode;+ $formInputs.defaultShell.value = currentSettings.defaultShell;}onMount(() => {@@ -182,8 +200,8 @@<ActivityIcon class="size-4" /></div><div>- <Card.Title class="text-base">Image Polling</Card.Title>- <Card.Description class="text-xs">Configure automatic image update checking</Card.Description>+ <Card.Title class="text-base">{m.docker_image_polling_title()}</Card.Title>+ <Card.Description class="text-xs">{m.docker_image_polling_description()}</Card.Description></div></div></Card.Header>@@ -203,7 +221,7 @@name="pollingIntervalMode"bind:value={pollingIntervalMode}label={m.docker_polling_interval_label()}- placeholder="Select interval"+ placeholder={m.docker_polling_interval_placeholder_select()}options={imagePollingOptions.map(({ value, label, description }) => ({ value, label, description }))}/>@@ -238,10 +256,8 @@<RefreshCwIcon class="size-4" /></div><div>- <Card.Title class="text-base">Auto Updates</Card.Title>- <Card.Description class="text-xs"- >Automatically update containers when new images are available</Card.Description- >+ <Card.Title class="text-base">{m.docker_auto_updates_title()}</Card.Title>+ <Card.Description class="text-xs">{m.docker_auto_updates_description()}</Card.Description></div></div></Card.Header>@@ -277,8 +293,8 @@<TrashIcon class="size-4" /></div><div>- <Card.Title class="text-base">Cleanup Settings</Card.Title>- <Card.Description class="text-xs">Configure how Docker images are pruned</Card.Description>+ <Card.Title class="text-base">{m.docker_cleanup_settings_title()}</Card.Title>+ <Card.Description class="text-xs">{m.docker_cleanup_settings_description()}</Card.Description></div></div></Card.Header>@@ -295,6 +311,48 @@/></Card.Content></Card.Root>++ <Card.Root class="overflow-hidden pt-0">+ <Card.Header class="bg-muted/20 border-b !py-4">+ <div class="flex items-center gap-3">+ <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">+ <TerminalIcon class="size-4" />+ </div>+ <div>+ <Card.Title class="text-base">{m.docker_terminal_settings_title()}</Card.Title>+ <Card.Description class="text-xs">{m.docker_terminal_settings_description()}</Card.Description>+ </div>+ </div>+ </Card.Header>+ <Card.Content class="px-3 py-4 sm:px-6">+ <div class="space-y-3">+ <SelectWithLabel+ id="shellSelectValue"+ name="shellSelectValue"+ bind:value={shellSelectValue}+ label={m.docker_default_shell_label()}+ description={m.docker_default_shell_description()}+ placeholder={m.docker_default_shell_placeholder()}+ options={[+ ...shellOptions,+ { value: 'custom', label: m.custom(), description: m.docker_shell_custom_description() }+ ]}+ />++ {#if shellSelectValue === 'custom'}+ <div class="border-primary/20 border-l-2 pl-3">+ <TextInputWithLabel+ bind:value={$formInputs.defaultShell.value}+ label={m.custom()}+ placeholder={m.docker_shell_custom_path_placeholder()}+ helpText={m.docker_shell_custom_path_help()}+ type="text"+ />+ </div>+ {/if}+ </div>+ </Card.Content>+ </Card.Root></div></fieldset>{/snippet}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 12c4470f1..aea40e066 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -49,6 +49,12 @@ importers:'@uiw/codemirror-themes':specifier: ^4.25.2version: 4.25.2(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])+ '@xterm/addon-fit':+ specifier: ^0.10.0+ version: 0.10.0(@xterm/[email protected])+ '@xterm/xterm':+ specifier: ^5.5.0+ version: 5.5.0axios:specifier: ^1.12.2version: 1.12.2@@ -1008,6 +1014,14 @@ packages:resolution: {integrity: sha512-ZtvYkYpZOYdvbws3uaOAvTFuvFXoQGAtmzeiXu+XSMGxi5GVsODpoI9Xu9TplEMuD/5fmAtBbKb9cQHkWkLXDQ==}engines: {node: '>=18.16.0'}+ '@xterm/[email protected]':+ resolution: {integrity: sha512-UFYkDm4HUahf2lnEyHvio51TNGiLK66mqP2JoATy7hRZeXaGMRDr00JiSF7m63vR5WKATF605yEggJKsw0JpMQ==}+ peerDependencies:+ '@xterm/xterm': ^5.0.0++ '@xterm/[email protected]':+ resolution: {integrity: sha512-hqJHYaQb5OptNunnyAnkHyM8aCjZ1MEIDTQu1iIbbTD/xops91NB5yq1ZK/dC2JDbVWtF23zUtl9JE2NqwT87A==}+resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}peerDependencies:@@ -3233,6 +3247,12 @@ snapshots:validator: 13.15.15optional: true+ '@xterm/[email protected](@xterm/[email protected])':+ dependencies:+ '@xterm/xterm': 5.5.0++ '@xterm/[email protected]': {}+dependencies:acorn: 8.15.0diff --git a/tests/spec/containers.spec.ts b/tests/spec/containers.spec.tsindex 25e3ec22f..2d6951c6d 100644--- a/tests/spec/containers.spec.ts+++ b/tests/spec/containers.spec.ts@@ -89,7 +89,7 @@ test.describe('Containers Page', () => {await navigateToContainers(page);- const row = page.locator(`tr:has(a[href="/containers/${any.id}/"])`);+ const row = page.locator(`tr:has(a[href="/containers/${any.id}"])`);await row.getByRole('button', { name: 'Open menu' }).click();await page.getByRole('menuitem', { name: 'Remove' }).click();