From 7a2a7877c4a626074a850ce3198cc3335cf2b4c6 Mon Sep 17 00:00:00 2001 From: GitHub Copilot Date: Wed, 18 Feb 2026 17:53:33 +0000 Subject: [PATCH] Default dashboard thumbnails to PNG PNG screenshots are now the default for dashboard previews, with SVG available by setting WEBTERM_SCREENSHOT_MODE=svg. Documentation and tests updated accordingly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- README.md | 4 ++-- docs/ARCHITECTURE.md | 2 +- webterm/server.go | 4 ++-- webterm/server_test.go | 13 ++++++------- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 7bc1597..93942a8 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ https://github.com/user-attachments/assets/62c52183-83a3-4fb5-97b1-ed001de4f53a - Typeahead find for quickly finding and launching sessions with minimal friction - Web terminal with reconnect support - Ghostty WebAssembly terminal engine for fast rendering from [`ghostty-web`](https://github.com/rcarmo/ghostty-web) -- Session dashboard with live SVG (or optional PNG) screenshots from [`go-te`](https://github.com/rcarmo/go-te) +- Session dashboard with live PNG (or optional SVG) screenshots from [`go-te`](https://github.com/rcarmo/go-te) - Docker watch mode (`webterm-command` / `webterm-theme` labels) - Docker compose manifest ingestion - CPU sparkline tiles for compose services @@ -97,7 +97,7 @@ go run ./cmd/webterm -- --compose-manifest ./docker-compose.yaml - `WEBTERM_DOCKER_USERNAME`: user for Docker exec sessions - `WEBTERM_DOCKER_AUTO_COMMAND`: override auto command (`/bin/bash` default) - `WEBTERM_SCREENSHOT_FORCE_REDRAW`: force redraw before screenshots (`true/1/yes/on`) -- `WEBTERM_SCREENSHOT_MODE`: screenshot format for dashboard thumbnails (`svg` default, set `png` to enable PNG) +- `WEBTERM_SCREENSHOT_MODE`: screenshot format for dashboard thumbnails (`png` default, set `svg` to use SVG) - `DOCKER_HOST`: Docker daemon endpoint override ## Development (Makefile-first) diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 0ce508b..81ee8c2 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -35,7 +35,7 @@ webterm/server.go (LocalServer) - live WS stream (`stdout`) - replay buffer (reconnect support) - terminal-state tracker (`go-te`) for screenshots -4. Dashboard pulls `/screenshot.svg` (default) or `/screenshot.png` when `WEBTERM_SCREENSHOT_MODE=png`, and listens on `/events` for activity. +4. Dashboard pulls `/screenshot.png` (default) or `/screenshot.svg` when `WEBTERM_SCREENSHOT_MODE=svg`, and listens on `/events` for activity. ## Static assets diff --git a/webterm/server.go b/webterm/server.go index 78c8881..50c4e8b 100644 --- a/webterm/server.go +++ b/webterm/server.go @@ -240,8 +240,8 @@ func NewLocalServer(config Config, options ServerOptions) *LocalServer { fontSize = DefaultFontSize } screenshotMode := strings.ToLower(strings.TrimSpace(os.Getenv(ScreenshotModeEnv))) - if screenshotMode != "png" { - screenshotMode = "svg" + if screenshotMode != "svg" { + screenshotMode = "png" } apps := append([]App{}, config.Apps...) for _, app := range options.LandingApps { diff --git a/webterm/server_test.go b/webterm/server_test.go index ac6202e..c687232 100644 --- a/webterm/server_test.go +++ b/webterm/server_test.go @@ -456,7 +456,6 @@ func TestScreenshotAndETag(t *testing.T) { } func TestScreenshotPNGAndETag(t *testing.T) { - t.Setenv(ScreenshotModeEnv, "png") server, httpServer, _ := newServerForTests(t, false) if _, err := server.sessionManager.NewSession("shell", "sid", "shell", 80, 24); err != nil { t.Fatalf("NewSession error = %v", err) @@ -534,13 +533,13 @@ func TestDashboardIncludesContextMenuSanitizedDownload(t *testing.T) { if !strings.Contains(text, "contextmenu") || !strings.Contains(text, "sanitize_font_urls=1&download=1") { t.Fatalf("expected contextmenu sanitized download wiring in dashboard page") } - if !strings.Contains(text, "screenshot.svg") { - t.Fatalf("expected dashboard to request svg screenshots by default") + if !strings.Contains(text, "screenshot.png") { + t.Fatalf("expected dashboard to request png screenshots by default") } } -func TestDashboardUsesPNGWhenEnabled(t *testing.T) { - t.Setenv(ScreenshotModeEnv, "png") +func TestDashboardUsesSVGWhenConfigured(t *testing.T) { + t.Setenv(ScreenshotModeEnv, "svg") _, httpServer, _ := newServerForTests(t, true) resp, err := http.Get(httpServer.URL + "/") if err != nil { @@ -549,8 +548,8 @@ func TestDashboardUsesPNGWhenEnabled(t *testing.T) { body, _ := io.ReadAll(resp.Body) _ = resp.Body.Close() text := string(body) - if !strings.Contains(text, "screenshot.png") { - t.Fatalf("expected dashboard to request png screenshots when enabled") + if !strings.Contains(text, "screenshot.svg") { + t.Fatalf("expected dashboard to request svg screenshots when configured") } if !strings.Contains(text, "sanitize_font_urls=1&download=1") || !strings.Contains(text, "screenshot.svg") { t.Fatalf("expected contextmenu downloads to use svg screenshots")