Skip to content

Modern Docker Management, Designed for Everyone

perf: batch live stats per environment and cut table render cost

Kyle Mendell3330f4e0f53b
diff --git a/.arcane.json b/.arcane.json
index 5a9df6200..981a424ea 100644
--- a/.arcane.json
+++ b/.arcane.json
@@ -1,5 +1,5 @@
{
- "version": "2.16.0",
- "revision": "94b16586821322962f0cc3316f483d905a131789",
- "buildTime": "2026-10-13T21:23:27Z"
+ "version": "2.16.0",
+ "revision": "94b16586821322962f0cc3316f483d905a131789",
+ "buildTime": "2026-10-13T21:23:27Z"
}
diff --git a/.golangci.yml b/.golangci.yml
index 8ed62f154..acb384897 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -1,8 +1,8 @@
# Slightly Modified Version of docker's golangci lint configuration to fit arcanes standards
-version: "2"
+version: '2'
run:
- go: "1.27.2"
+ go: '1.27.2'
build-tags:
- exclude_frontend
- playwright
@@ -79,9 +79,9 @@ linters:
desc: use stdlib maps package
- pkg: golang.org/x/exp/slices
desc: use stdlib slices package
- - pkg: "github.com/google/uuid"
+ - pkg: 'github.com/google/uuid'
desc: Use stdlib uuid instead.
- - pkg: "gopkg.in/yaml.v3"
+ - pkg: 'gopkg.in/yaml.v3'
desc: Use go.yaml.in/yaml/v4 instead.
exhaustruct_v5:
@@ -91,11 +91,11 @@ linters:
analyze-types: true
forbid:
- pattern: 'context\.Background'
- pkg: "^context$"
- msg: "in tests, use t.Context() instead of context.Background()"
+ pkg: '^context$'
+ msg: 'in tests, use t.Context() instead of context.Background()'
- pattern: 'context\.TODO'
- pkg: "^context$"
- msg: "in tests, use t.Context() instead of context.TODO()"
+ pkg: '^context$'
+ msg: 'in tests, use t.Context() instead of context.TODO()'
gocritic:
disabled-checks:
@@ -146,7 +146,7 @@ linters:
disabled: true
sloglint:
- context: "all" # https://github.com/go-simpler/sloglint#context-only
+ context: 'all' # https://github.com/go-simpler/sloglint#context-only
kv-only: true # https://github.com/go-simpler/sloglint#key-value-pairs-only
static-msg: true # https://github.com/go-simpler/sloglint#static-message
key-naming-case: camel
@@ -157,4 +157,4 @@ linters:
# The legacy edge message protocol uses deprecated tunnel.proto messages until v3 removes both.
- path: pkg/libarcane/edge/
linters: [staticcheck]
- text: "SA1019: .*proto/tunnel/v1"
+ text: 'SA1019: .*proto/tunnel/v1'
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3c0a75dbc..f4bd39169 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -59,6 +59,7 @@
- store auth config in a seperate auth.json file ([\#4379](https://github.com/getarcaneapp/arcane/pull/4379) by @kmendell)
**Full Changelog**: https://github.com/getarcaneapp/arcane/compare/v2.15.1...v2.16.0
+
## v2.15.1
### Bug fixes
diff --git a/Justfile b/Justfile
index 22004ce3a..3255afc21 100644
--- a/Justfile
+++ b/Justfile
@@ -284,6 +284,7 @@ format target="all" check="":
[group('checks')]
_lint_frontend:
vp -C frontend run check
+ vp -C frontend run lint
# Type check Playwright tests
[group('checks')]
diff --git a/backend/api/ws/containers.go b/backend/api/ws/containers.go
new file mode 100644
index 000000000..b196a7e9e
--- /dev/null
+++ b/backend/api/ws/containers.go
@@ -0,0 +1,114 @@
+package ws
+
+import (
+ "context"
+ "encoding/json/v2"
+ "log/slog"
+ "sync/atomic"
+ "time"
+
+ "github.com/coder/websocket"
+ containertypes "github.com/getarcaneapp/arcane/types/v2/container"
+ systemtypes "github.com/getarcaneapp/arcane/types/v2/system"
+ "github.com/labstack/echo/v5"
+ kit "go.getarcane.app/kit/pkg"
+
+ wshub "github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/ws"
+)
+
+const (
+ // containersStatsInterval is the pause between batches and the oldest cached sample a batch reuses.
+ containersStatsInterval = 2 * time.Second
+ // containersStatsReadLimit fits a subscription of 500 full container IDs, the most one batch samples.
+ containersStatsReadLimit = 64 << 10
+)
+
+// ContainersStats streams resource samples for a client-chosen set of containers over one WebSocket.
+// The client sends a ResourceSampleSubscription whenever its set changes; the server answers with a
+// ResourceSampleBatch every couple of seconds.
+//
+// @Summary Get batched container stats via WebSocket
+// @Description Stream resource samples for the subscribed containers over one WebSocket connection
+// @Tags WebSocket
+// @Param id path string true "Environment ID"
+// @Router /api/environments/{id}/ws/containers/stats [get]
+func (h *WebSocketHandler) ContainersStats(c *echo.Context) error {
+ conn, unregister, ok := h.acceptWS(c, systemtypes.WSKindContainerStats, "batch")
+ if !ok {
+ return nil
+ }
+ defer unregister()
+ defer func() { _ = conn.CloseNow() }()
+ conn.SetReadLimit(containersStatsReadLimit)
+
+ ctx, cancel := context.WithCancel(c.Request().Context())
+ defer cancel()
+
+ var ids atomic.Pointer[[]string]
+ wake := make(chan struct{}, 1)
+ go readContainersStatsPump(ctx, cancel, conn, &ids, wake)
+ // The pong is serviced by readContainersStatsPump.
+ go wshub.KeepAlive(ctx, cancel, conn)
+
+ send := func(batch containertypes.ResourceSampleBatch) error {
+ b, err := json.Marshal(batch)
+ if err != nil {
+ return err
+ }
+ wctx, wcancel := context.WithTimeout(ctx, 10*time.Second)
+ defer wcancel()
+ return conn.Write(wctx, websocket.MessageText, b)
+ }
+
+ // Nothing to sample until the first subscription arrives.
+ select {
+ case <-ctx.Done():
+ return nil
+ case <-wake:
+ }
+
+ for {
+ samples, err := h.containerService.SampleResources(ctx, kit.FromPtr(ids.Load()), containersStatsInterval)
+ switch {
+ case ctx.Err() != nil:
+ return nil
+ case err != nil:
+ slog.DebugContext(ctx, "Failed to sample container stats", "envId", c.Param("id"), "error", err)
+ if send(containertypes.ResourceSampleBatch{Error: "Failed to sample container stats: " + err.Error(), Timestamp: time.Now()}) != nil {
+ return nil
+ }
+ default:
+ if send(containertypes.ResourceSampleBatch{Samples: samples, Timestamp: time.Now()}) != nil {
+ return nil
+ }
+ }
+
+ select {
+ case <-ctx.Done():
+ return nil
+ case <-wake:
+ case <-time.After(containersStatsInterval):
+ }
+ }
+}
+
+// readContainersStatsPump is the single reader for the ContainersStats websocket. It stores each
+// subscription and wakes the sampler; malformed frames are ignored. Do not add other readers.
+func readContainersStatsPump(ctx context.Context, cancel context.CancelFunc, conn *websocket.Conn, ids *atomic.Pointer[[]string], wake chan<- struct{}) {
+ defer cancel()
+ for {
+ _, data, err := conn.Read(ctx)
+ if err != nil {
+ return
+ }
+ var subscription containertypes.ResourceSampleSubscription
+ if json.Unmarshal(data, &subscription) != nil {
+ continue
+ }
+ ids.Store(new(subscription.ContainerIDs))
+ select {
+ case wake <- struct{}{}:
+ default:
+ }
+ }
+}
diff --git a/backend/api/ws/proxy_permissions.go b/backend/api/ws/proxy_permissions.go
index a6c07589d..f427b866e 100644
--- a/backend/api/ws/proxy_permissions.go
+++ b/backend/api/ws/proxy_permissions.go
@@ -23,6 +23,7 @@ type proxiedWSRoute struct {
func (h *WebSocketHandler) proxiedRoutes() []proxiedWSRoute {
return []proxiedWSRoute{
{"/projects/:projectId/logs", h.ProjectLogs, authz.PermProjectsLogs},
+ {"/containers/stats", h.ContainersStats, authz.PermContainersRead},
{"/containers/:containerId/logs", h.ContainerLogs, authz.PermContainersLogs},
{"/containers/:containerId/stats", h.ContainerStats, authz.PermContainersRead},
{"/containers/:containerId/terminal", h.ContainerExec, authz.PermContainersExec},
diff --git a/backend/internal/bootstrap/router_bootstrap.go b/backend/internal/bootstrap/router_bootstrap.go
index eeda2b605..993dda67a 100644
--- a/backend/internal/bootstrap/router_bootstrap.go
+++ b/backend/internal/bootstrap/router_bootstrap.go
@@ -43,6 +43,7 @@ var (
var loggerSkipPatterns = []string{
"POST /api/tunnel/poll",
+ "GET /api/environments/*/ws/containers/stats",
"GET /api/environments/*/ws/containers/*/logs",
"GET /api/environments/*/ws/containers/*/stats",
"GET /api/environments/*/ws/containers/*/terminal",
diff --git a/backend/internal/container/children/stats/service.go b/backend/internal/container/children/stats/service.go
index 30f4e0617..f9622673c 100644
--- a/backend/internal/container/children/stats/service.go
+++ b/backend/internal/container/children/stats/service.go
@@ -46,13 +46,19 @@ type Service struct {
getClient func(context.Context) (*client.Client, error)
dockerHost func() string
history stats.Store
- cache *hot.HotCache[string, container.StatsResponse]
+ cache *hot.HotCache[string, cachedStats]
inspectCache *hot.HotCache[string, container.InspectResponse]
flight singleflight.Group
sampleTimeout time.Duration
batchTimeout time.Duration
}
+// cachedStats records when Arcane fetched a sample, so freshness checks don't depend on the daemon's clock.
+type cachedStats struct {
+ stats container.StatsResponse
+ fetchedAt time.Time
+}
+
// New builds a stats service. Non-positive timeouts fall back to defaults.
func New(getClient func(context.Context) (*client.Client, error), dockerHost func() string, cacheTTL, sampleTimeout, batchTimeout time.Duration) *Service {
if sampleTimeout <= 0 {
@@ -64,7 +70,7 @@ func New(getClient func(context.Context) (*client.Client, error), dockerHost fun
return &Service{
getClient: getClient,
dockerHost: dockerHost,
- cache: hot.NewHotCache[string, container.StatsResponse](hot.LRU, ContainerResourceSampleCacheSize).
+ cache: hot.NewHotCache[string, cachedStats](hot.LRU, ContainerResourceSampleCacheSize).
WithTTL(cacheTTL).
WithJanitor().
Build(),
@@ -130,16 +136,19 @@ func (s *Service) Stream(ctx context.Context, containerID string, statsChan chan
}
}
-// Collect fetches one sample per running container. Individual failures leave the container
-// unsampled; a batch timeout or cancellation fails so partial lists never sort as global.
-func (s *Service) Collect(ctx context.Context, items []containertypes.Summary) (map[string]*containertypes.ResourceSample, error) {
+// Collect fetches one sample per running container, reusing cached samples younger than maxAge.
+// Individual failures leave the container unsampled; a batch timeout or cancellation fails so partial
+// lists never sort as global.
+func (s *Service) Collect(ctx context.Context, items []containertypes.Summary, maxAge time.Duration) (map[string]*containertypes.ResourceSample, error) {
ids := make([]string, 0, len(items))
for i := range items {
if items[i].State == string(container.StateRunning) {
ids = append(ids, items[i].ID)
}
}
- raw, err := collect(ctx, s.batchTimeout, ids, s.fetch)
+ raw, err := collect(ctx, s.batchTimeout, ids, func(ctx context.Context, id string) (container.StatsResponse, error) {
+ return s.fetch(ctx, id, maxAge)
+ })
if err != nil {
return nil, fmt.Errorf("failed to collect container resource samples: %w", err)
}
@@ -185,12 +194,12 @@ func collect[T any](ctx context.Context, timeout time.Duration, ids []string, fe
return results, g.Wait()
}
-// fetch returns a cached stats sample when fresh and coalesces concurrent fetches per daemon and
-// container. IncludePreviousSample gives the CPU delta a valid previous sample.
-func (s *Service) fetch(ctx context.Context, containerID string) (container.StatsResponse, error) {
+// fetch returns a cached stats sample younger than maxAge and coalesces concurrent fetches per daemon
+// and container. IncludePreviousSample gives the CPU delta a valid previous sample.
+func (s *Service) fetch(ctx context.Context, containerID string, maxAge time.Duration) (container.StatsResponse, error) {
key := s.dockerHost() + "\x00" + containerID
- if sample, ok, _ := s.cache.Get(key); ok {
- return sample, nil
+ if cached, ok, _ := s.cache.Get(key); ok && time.Since(cached.fetchedAt) < maxAge {
+ return cached.stats, nil
}
ch := s.flight.DoChan(key, func() (any, error) {
@@ -214,7 +223,7 @@ func (s *Service) fetch(ctx context.Context, containerID string) (container.Stat
if statsData.Read.IsZero() {
statsData.Read = time.Now()
}
- s.cache.Set(key, statsData)
+ s.cache.Set(key, cachedStats{stats: statsData, fetchedAt: time.Now()})
return statsData, nil
})
@@ -289,7 +298,7 @@ func (s *Service) ObserveResources(meter metric.Meter, list func(context.Context
}
}
samples, err := collect(ctx, ContainerMetricsCollectTimeout, slices.Collect(maps.Keys(running)), func(ctx context.Context, id string) (resourceSample, error) {
- statsData, fetchErr := s.fetch(ctx, id)
+ statsData, fetchErr := s.fetch(ctx, id, ContainerResourceSampleTTL)
if fetchErr != nil {
return resourceSample{}, fetchErr
}
diff --git a/backend/internal/container/children/stats/service_test.go b/backend/internal/container/children/stats/service_test.go
index 1853ccb3c..bdfd3fefe 100644
--- a/backend/internal/container/children/stats/service_test.go
+++ b/backend/internal/container/children/stats/service_test.go
@@ -1,9 +1,17 @@
package stats
import (
+ "context"
+ "io"
+ "net/http"
+ "net/http/httptest"
+ "strings"
+ "sync/atomic"
"testing"
+ "time"
"github.com/getarcaneapp/arcane/types/v2/container"
+ "github.com/moby/moby/client"
"github.com/stretchr/testify/require"
"github.com/getarcaneapp/arcane/backend/v2/pkg/authz"
@@ -38,3 +46,49 @@ func TestResourceSortComparatorKeepsUnavailableLast(t *testing.T) {
require.Equal(t, -1, asc(zero, unsampled), "zero is a valid value, not unavailable")
require.Equal(t, -1, asc(zero, sampled))
}
+
+func TestCollectMaxAge(t *testing.T) {
+ tests := []struct {
+ name string
+ maxAge time.Duration
+ wantCalls int32
+ }{
+ {name: "TTL reuses the cached sample", maxAge: ContainerResourceSampleTTL, wantCalls: 1},
+ {name: "maxAge older than the cached sample refetches", maxAge: time.Nanosecond, wantCalls: 2},
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ var calls atomic.Int32
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if !strings.HasSuffix(r.URL.Path, "/containers/web/stats") {
+ http.NotFound(w, r)
+ return
+ }
+ calls.Add(1)
+ _, _ = io.WriteString(w, `{"read":"2026-01-01T00:00:00Z","memory_stats":{"usage":100,"limit":1000}}`)
+ }))
+ t.Cleanup(server.Close)
+ dockerClient, err := client.New(
+ client.WithHost(server.URL),
+ client.WithAPIVersion("1.41"),
+ client.WithHTTPClient(server.Client()),
+ )
+ require.NoError(t, err)
+ t.Cleanup(func() { _ = dockerClient.Close() })
+
+ svc := New(
+ func(context.Context) (*client.Client, error) { return dockerClient, nil },
+ func() string { return "test" },
+ ContainerResourceSampleTTL,
+ 0,
+ 0,
+ )
+ for range 2 {
+ samples, collectErr := svc.Collect(t.Context(), []container.Summary{{ID: "web", State: "running"}}, tt.maxAge)
+ require.NoError(t, collectErr)
+ require.Contains(t, samples, "web")
+ }
+ require.Equal(t, tt.wantCalls, calls.Load())
+ })
+ }
+}
diff --git a/backend/internal/container/service.go b/backend/internal/container/service.go
index b2148eabf..cb9f569fa 100644
--- a/backend/internal/container/service.go
+++ b/backend/internal/container/service.go
@@ -10,6 +10,7 @@ import (
"maps"
"net/netip"
"net/url"
+ "slices"
"strings"
"sync"
"time"
@@ -1620,6 +1621,32 @@ func (s *ContainerService) StreamStats(ctx context.Context, containerID string,
return s.stats.Stream(ctx, containerID, statsChan)
}
+// containerResourceSampleLimit caps how many requested containers one SampleResources call reads.
+const containerResourceSampleLimit = 500
+
+// SampleResources samples the running containers among the first containerResourceSampleLimit ids,
+// refetching samples older than maxAge. Blank, stopped and unknown IDs are omitted.
+func (s *ContainerService) SampleResources(ctx context.Context, ids []string, maxAge time.Duration) (map[string]*containertypes.ResourceSample, error) {
+ requested := slices.DeleteFunc(slices.Clone(ids[:min(len(ids), containerResourceSampleLimit)]), func(id string) bool {
+ return strings.TrimSpace(id) == ""
+ })
+ if len(requested) == 0 {
+ return map[string]*containertypes.ResourceSample{}, nil
+ }
+
+ dockerContainers, err := s.dockerService.ListContainers(ctx)
+ if err != nil {
+ return nil, err
+ }
+ matched := make([]containertypes.Summary, 0, len(requested))
+ for _, dc := range dockerContainers {
+ if dc.State == container.StateRunning && slices.Contains(requested, dc.ID) {
+ matched = append(matched, containertypes.Summary{ID: dc.ID, State: string(dc.State)})
+ }
+ }
+ return s.stats.Collect(ctx, matched, maxAge)
+}
+
func (s *ContainerService) ListContainersPaginated(
ctx context.Context,
params pagination.QueryParams,
@@ -1704,7 +1731,7 @@ func (s *ContainerService) listContainersByResourceInternal(
}
}
- samples, err := s.stats.Collect(ctx, filtered)
+ samples, err := s.stats.Collect(ctx, filtered, stats.ContainerResourceSampleTTL)
if err != nil {
return ContainerListResult{}, err
}
diff --git a/backend/internal/container/service_test.go b/backend/internal/container/service_test.go
index 67a43a936..048dc08fe 100644
--- a/backend/internal/container/service_test.go
+++ b/backend/internal/container/service_test.go
@@ -8,11 +8,13 @@ import (
"encoding/json"
"fmt"
"io"
+ "maps"
"net/http"
"net/http/httptest"
"net/netip"
"net/url"
"regexp"
+ "slices"
"strings"
"sync"
"sync/atomic"
@@ -1118,7 +1120,7 @@ func TestResourceSortCoalescesConcurrentFetches(t *testing.T) {
errs := make([]error, callers)
for i := range callers {
wg.Go(func() {
- _, err := svc.stats.Collect(t.Context(), []containertypes.Summary{{ID: "web", State: "running"}})
+ _, err := svc.stats.Collect(t.Context(), []containertypes.Summary{{ID: "web", State: "running"}}, stats.ContainerResourceSampleTTL)
errs[i] = err
})
}
@@ -1189,6 +1191,65 @@ func TestResourceSortCancelledContextFailsRequest(t *testing.T) {
require.Error(t, err)
}
+func TestSampleResourcesFiltersRequestedIDs(t *testing.T) {
+ capped := make([]string, containerResourceSampleLimit+1)
+ for i := range capped {
+ capped[i] = fmt.Sprintf("c%03d", i)
+ }
+ tests := []struct {
+ name string
+ running []string
+ stopped []string
+ request []string
+ want []string
+ }{
+ {
+ name: "stopped, unknown and blank ids are omitted",
+ running: []string{"web"},
+ stopped: []string{"db"},
+ request: []string{"web", "db", "ghost", "", " "},
+ want: []string{"web"},
+ },
+ {
+ name: "only exact requested ids are sampled",
+ running: []string{"web", "web2"},
+ request: []string{"web"},
+ want: []string{"web"},
+ },
+ {
+ name: "ids past the limit are ignored",
+ running: capped,
+ request: capped,
+ want: capped[:containerResourceSampleLimit],
+ },
+ {
+ name: "no ids samples nothing",
+ running: []string{"web"},
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ fixture := newResourceStatsServerInternal()
+ for _, id := range tt.running {
+ fixture.addContainer(id, id, "running")
+ fixture.setStats(id, 10, 100, 1000)
+ }
+ for _, id := range tt.stopped {
+ fixture.addContainer(id, id, "exited")
+ fixture.setStats(id, 10, 100, 1000)
+ }
+ svc := newResourceSortServiceInternal(t, fixture)
+
+ samples, err := svc.SampleResources(t.Context(), tt.request, stats.ContainerResourceSampleTTL)
+ require.NoError(t, err)
+ require.ElementsMatch(t, tt.want, slices.Collect(maps.Keys(samples)))
+ for _, id := range tt.stopped {
+ require.Zero(t, fixture.callsFor(id), "stopped containers must not trigger stats collection")
+ }
+ })
+ }
+}
+
func newLogsTestServiceInternal(t *testing.T, tty bool, logsBody []byte, gotQuery *url.Values) *ContainerService {
t.Helper()
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
diff --git a/backend/pkg/libarcane/edge/commands.go b/backend/pkg/libarcane/edge/commands.go
index dcebf9f08..6f5462b78 100644
--- a/backend/pkg/libarcane/edge/commands.go
+++ b/backend/pkg/libarcane/edge/commands.go
@@ -271,6 +271,7 @@ var commandRoutes = []commandRoute{
{Method: http.MethodDelete, PathPattern: "/api/environments/{id}/swarm/secrets/{secretId}", CommandName: "swarm.secret.delete"},
{PathPattern: "/api/environments/{id}/ws/projects/{projectId}/logs", CommandName: "project.logs.stream", Stream: true},
+ {PathPattern: "/api/environments/{id}/ws/containers/stats", CommandName: "container.stats.batch.stream", Stream: true},
{PathPattern: "/api/environments/{id}/ws/containers/{containerId}/logs", CommandName: "container.logs.stream", Stream: true},
{PathPattern: "/api/environments/{id}/ws/containers/{containerId}/stats", CommandName: "container.stats.stream", Stream: true},
{PathPattern: "/api/environments/{id}/ws/containers/{containerId}/terminal", CommandName: "container.exec.stream", Stream: true},
diff --git a/frontend/src/lib/components/arcane-table/arcane-table-desktop-view.svelte b/frontend/src/lib/components/arcane-table/arcane-table-desktop-view.svelte
index 61bfb89f6..cd61b5a4b 100644
--- a/frontend/src/lib/components/arcane-table/arcane-table-desktop-view.svelte
+++ b/frontend/src/lib/components/arcane-table/arcane-table-desktop-view.svelte
@@ -116,6 +116,29 @@
);
const columnWidths = $derived(shouldVirtualize && lockedColumns?.key === columnKey ? lockedColumns.widths : null);
const lockedTableWidth = $derived(columnWidths?.reduce((total, width) => total + width, 0));
+ // Per-column cell flags, computed once per layout change instead of per cell on every row render.
+ const cellPropsByColumn = $derived(
+ new Map(
+ table.getVisibleLeafColumns().map((column, index) => {
+ const meta = column.columnDef.meta;
+ const isControl = column.id === 'select' || column.id === 'actions';
+ return [
+ column.id,
+ {
+ pinned: column.id === 'actions',
+ variant: column.id === 'select' ? ('checkbox' as const) : ('default' as const),
+ firstData: column.id !== 'select' && index === (selectionDisabled ? 0 : 1),
+ shrink: column.id === 'actions' || meta?.width === 'min',
+ grow: meta?.width === 'max',
+ align: meta?.align,
+ clip: !wrapText && (!!meta?.truncate || (!!columnWidths && !isControl)),
+ wrap: wrapText && !isControl,
+ width: typeof meta?.width === 'number' ? meta.width : undefined
+ }
+ ];
+ })
+ )
+ );
const getItemKey = $derived.by(() => {
const displayed = entries;
return (index: number) => displayed[index]?.key ?? index;
@@ -211,13 +234,9 @@
{#snippet cellContent(cell: ArcaneCell<TData>)}
{#if cell.column.id === 'actions'}
- <!-- Pinned row actions: a floating chip at the row's end, always present in its own gutter. -->
- <div class="flex items-center justify-end py-1 pr-3 pl-2" data-row-select-ignore>
- <div
- class="flex items-center gap-0.5 rounded-full border border-border/50 bg-card/90 p-0.5 shadow-sm transition-all duration-150 group-hover/row:border-border group-hover/row:shadow-md"
- >
- <FlexRender {cell} />
- </div>
+ <!-- Pinned row actions at the row's end, always present in their own gutter. -->
+ <div class="flex items-center justify-end gap-0.5 py-1 pr-3 pl-2" data-row-select-ignore>
+ <FlexRender {cell} />
</div>
{:else}
<FlexRender {cell} />
@@ -240,7 +259,7 @@
data-expanded={isExpanded ? true : undefined}
onclick={(event) => handleRowClick(event, rowId)}
onmousedown={handleRowMouseDown}
- class={cn('isolate', hasExpand && 'cursor-pointer')}
+ class={hasExpand ? 'cursor-pointer' : undefined}
>
{#if hasExpand}
<Table.Cell variant="expander" data-row-select-ignore>
@@ -259,28 +278,24 @@
</button>
</Table.Cell>
{/if}
- {#each row.getVisibleCells() as cell, cellIndex (cell.id)}
- {@const isFirstDataCell = !selectionDisabled ? cellIndex === 1 : cellIndex === 0}
- {@const meta = cell.column.columnDef.meta}
- {@const clip =
- !wrapText && (meta?.truncate || (!!columnWidths && cell.column.id !== 'select' && cell.column.id !== 'actions'))}
+ {#each row.getVisibleCells() as cell (cell.id)}
+ {@const props = cellPropsByColumn.get(cell.column.id)}
<Table.Cell
- pinned={cell.column.id === 'actions'}
- variant={cell.column.id === 'select' ? 'checkbox' : 'default'}
- indent={isGroupedRow && isFirstDataCell && cell.column.id !== 'select'}
- style={typeof meta?.width === 'number' ? `--col-width: ${meta.width}px` : undefined}
+ pinned={props?.pinned}
+ variant={props?.variant}
+ indent={isGroupedRow && !!props?.firstData}
+ style={props?.width !== undefined ? `--col-width: ${props.width}px` : undefined}
class={cn(
- cell.column.id === 'actions' && 'w-0',
- meta?.width === 'min' && 'w-0',
- meta?.width === 'max' && 'w-full',
- meta?.align === 'center' && 'text-center',
- meta?.align === 'right' && 'text-right',
- clip && 'max-w-0',
- wrapText && cell.column.id !== 'select' && cell.column.id !== 'actions' && 'break-words whitespace-normal',
- typeof meta?.width === 'number' && 'w-(--col-width)'
+ props?.shrink && 'w-0',
+ props?.grow && 'w-full',
+ props?.align === 'center' && 'text-center',
+ props?.align === 'right' && 'text-right',
+ props?.clip && 'max-w-0',
+ props?.wrap && 'break-words whitespace-normal',
+ props?.width !== undefined && 'w-(--col-width)'
)}
>
- {#if clip}
+ {#if props?.clip}
<span class="block min-w-0 truncate">{@render cellContent(cell)}</span>
{:else}
{@render cellContent(cell)}
diff --git a/frontend/src/lib/components/arcane-table/arcane-table.utils.ts b/frontend/src/lib/components/arcane-table/arcane-table.utils.ts
index 2a53fe403..61f597229 100644
--- a/frontend/src/lib/components/arcane-table/arcane-table.utils.ts
+++ b/frontend/src/lib/components/arcane-table/arcane-table.utils.ts
@@ -147,7 +147,7 @@ export function getTableDisplayEntries<T extends RowData & { id: string }>(
const entries: TableDisplayEntry<T>[] = [];
const appendRows = (groupRows: ArcaneRow<T>[], groupName?: string) => {
for (const row of groupRows) {
- const key = JSON.stringify([groupName ?? null, row.id]);
+ const key = `${groupName ?? ''}\u0000${row.id}`;
entries.push({ kind: 'row', key: `row:${key}`, row, grouped: groupName !== undefined });
if (expanded?.has(row.id)) {
entries.push({ kind: 'detail', key: `detail:${key}`, row, grouped: groupName !== undefined });
diff --git a/frontend/src/lib/components/arcane-tooltip/arcane-tooltip.svelte b/frontend/src/lib/components/arcane-tooltip/arcane-tooltip.svelte
index 52db65f29..a119e4471 100644
--- a/frontend/src/lib/components/arcane-tooltip/arcane-tooltip.svelte
+++ b/frontend/src/lib/components/arcane-tooltip/arcane-tooltip.svelte
@@ -3,7 +3,7 @@
import * as Popover from '#lib/components/ui/popover/index.js';
import * as Tooltip from '#lib/components/ui/tooltip/index.js';
- import { IsTouchDevice } from '#lib/hooks/is-touch-device.svelte.js';
+ import { isTouchDevice } from '#lib/hooks/is-touch-device.svelte.js';
import { setArcaneTooltipContext } from './context.svelte.js';
@@ -19,7 +19,6 @@
children?: Snippet;
} = $props();
- const isTouchDevice = new IsTouchDevice();
let isTouch = $derived(isTouchDevice.current);
setArcaneTooltipContext({
@@ -43,9 +42,7 @@
{@render children?.()}
</Popover.Root>
{:else}
- <Tooltip.Provider {delayDuration}>
- <Tooltip.Root bind:open>
- {@render children?.()}
- </Tooltip.Root>
- </Tooltip.Provider>
+ <Tooltip.Root bind:open {delayDuration}>
+ {@render children?.()}
+ </Tooltip.Root>
{/if}
diff --git a/frontend/src/lib/components/metric-ring.svelte b/frontend/src/lib/components/metric-ring.svelte
index 537273ca0..716b04062 100644
--- a/frontend/src/lib/components/metric-ring.svelte
+++ b/frontend/src/lib/components/metric-ring.svelte
@@ -53,6 +53,6 @@
stroke-linecap="round"
stroke-dasharray={circumference}
stroke-dashoffset={dashOffset}
- class="transition-all duration-300 ease-out"
+ class="transition-stroke-dashoffset duration-300 ease-out"
/>
</svg>
diff --git a/frontend/src/lib/components/ui/table/table-cell.svelte b/frontend/src/lib/components/ui/table/table-cell.svelte
index 6bb30941f..a92635ce5 100644
--- a/frontend/src/lib/components/ui/table/table-cell.svelte
+++ b/frontend/src/lib/components/ui/table/table-cell.svelte
@@ -12,7 +12,7 @@
children,
...restProps
}: WithElementRef<HTMLTdAttributes> & {
- /** Sticky, opaque column at the row's right edge that mirrors the row's hover/selected tints. */
+ /** Sticky column at the row's right edge that inherits the row's opaque background. */
pinned?: boolean;
/** `checkbox` and `expander` size narrow control columns; `flush` drops padding for full-width panels. */
variant?: 'default' | 'checkbox' | 'expander' | 'flush';
@@ -31,8 +31,7 @@
variant === 'expander' && 'w-8 px-2',
variant === 'flush' && 'p-0',
indent && 'pl-10',
- pinned &&
- 'sticky right-0 z-(--arcane-z-sticky) bg-background p-0 whitespace-nowrap group-hover/row:bg-primary/6 group-data-[expanded]/row:bg-muted/30 group-data-[state=selected]/row:bg-primary/12',
+ pinned && 'sticky right-0 z-(--arcane-z-sticky) bg-inherit p-0 whitespace-nowrap',
className
)}
{...restProps}
diff --git a/frontend/src/lib/components/ui/table/table-head.svelte b/frontend/src/lib/components/ui/table/table-head.svelte
index a60e8a0a7..2e5bf6513 100644
--- a/frontend/src/lib/components/ui/table/table-head.svelte
+++ b/frontend/src/lib/components/ui/table/table-head.svelte
@@ -32,8 +32,7 @@
variant === 'expander' && 'w-8 px-2',
variant === 'flush' && 'p-0',
indent && 'pl-10',
- pinned &&
- 'sticky right-0 z-(--arcane-z-page-floating) bg-background p-0 whitespace-nowrap group-hover/row:bg-primary/6 group-data-[expanded]/row:bg-muted/30 group-data-[state=selected]/row:bg-primary/12',
+ pinned && 'sticky right-0 z-(--arcane-z-page-floating) bg-background p-0 whitespace-nowrap',
className
)}
{...restProps}
diff --git a/frontend/src/lib/components/ui/table/table-row.svelte b/frontend/src/lib/components/ui/table/table-row.svelte
index becc23c2d..1bc4132a8 100644
--- a/frontend/src/lib/components/ui/table/table-row.svelte
+++ b/frontend/src/lib/components/ui/table/table-row.svelte
@@ -20,7 +20,7 @@
data-slot="table-row"
class={cn(
'group/row cursor-pointer border-b border-border/40 bg-background transition-colors duration-150',
- 'hover:bg-primary/[0.06] data-expanded:bg-muted/30 data-[state=selected]:bg-primary/[0.12] data-[state=selected]:hover:bg-primary/[0.15]',
+ 'hover:bg-row-hover data-expanded:bg-row-expanded data-[state=selected]:bg-row-selected data-[state=selected]:hover:bg-row-selected-hover',
variant === 'detail' && 'bg-muted/10 hover:bg-muted/10',
variant === 'static' && 'bg-transparent hover:bg-transparent',
className
diff --git a/frontend/src/lib/hooks/is-touch-device.svelte.ts b/frontend/src/lib/hooks/is-touch-device.svelte.ts
index 9374f509d..63b681289 100644
--- a/frontend/src/lib/hooks/is-touch-device.svelte.ts
+++ b/frontend/src/lib/hooks/is-touch-device.svelte.ts
@@ -1,10 +1,9 @@
import { MediaQuery } from 'svelte/reactivity';
-/**
- * Detects when the primary input cannot hover and should use touch-first UI.
- */
export class IsTouchDevice extends MediaQuery {
constructor() {
super('(hover: none)', false);
}
}
+
+export const isTouchDevice = new IsTouchDevice();
diff --git a/frontend/src/lib/types/docker.ts b/frontend/src/lib/types/docker.ts
index ae0d945fd..de0955c18 100644
--- a/frontend/src/lib/types/docker.ts
+++ b/frontend/src/lib/types/docker.ts
@@ -174,6 +174,18 @@ export interface ContainerResourceSample {
sampleTime: string;
}
+/** Client frame on the batched container stats stream; each frame replaces the previous set. */
+export interface ContainerResourceSampleSubscription {
+ containerIds: string[];
+}
+
+/** Server frame on the batched container stats stream. Stopped, unknown and unsampled containers are omitted. */
+export interface ContainerResourceSampleBatch {
+ samples: Record<string, ContainerResourceSample>;
+ error?: string;
+ timestamp: string;
+}
+
export interface ContainerSummaryDto extends BaseContainer {
updateStrategy?: string;
ports: ContainerPorts[];
diff --git a/frontend/src/lib/utils/ws.ts b/frontend/src/lib/utils/ws.ts
index f87df8855..57d6006dc 100644
--- a/frontend/src/lib/utils/ws.ts
+++ b/frontend/src/lib/utils/ws.ts
@@ -8,6 +8,7 @@ import type {
LogEntry,
PprofProfile
} from '#lib/types/diagnostics.js';
+import type { ContainerResourceSampleBatch } from '#lib/types/docker.js';
import type { SystemStats } from '#lib/types/shared.js';
import { downloadBlob } from '#lib/utils/browser-download.js';
import { tryCatch } from '#lib/utils/try-catch.js';
@@ -259,6 +260,29 @@ export function createContainerStatsWebSocket(opts: {
});
}
+/** One stream per environment sampling the containers named by the latest subscription frame. */
+export function createContainersStatsWebSocket(opts: {
+ envId: string;
+ onMessage: (data: ContainerResourceSampleBatch) => void;
+ onOpen?: () => void;
+ onError?: (err: Event | Error) => void;
+ shouldReconnect?: () => boolean;
+}) {
+ const buildUrl = () => {
+ const protocol = location.protocol === 'https:' ? 'wss' : 'ws';
+ return `${protocol}://${location.host}/api/environments/${opts.envId}/ws/containers/stats`;
+ };
+
+ return new ReconnectingWebSocket<ContainerResourceSampleBatch>({
+ buildUrl,
+ parseMessage: (evt) => JSON.parse(evt.data as string) as ContainerResourceSampleBatch,
+ onMessage: opts.onMessage,
+ onOpen: opts.onOpen,
+ onError: opts.onError,
+ shouldReconnect: opts.shouldReconnect
+ });
+}
+
/** Diagnostics stream carrying live snapshots plus request/response commands. */
export function createDiagnosticsWebSocket(opts: {
onSnapshot: (data: Diagnostics) => void;
diff --git a/frontend/src/routes/(app)/containers/components/container-stats-manager.svelte.ts b/frontend/src/routes/(app)/containers/components/container-stats-manager.svelte.ts
index 084bc04a8..f48d98410 100644
--- a/frontend/src/routes/(app)/containers/components/container-stats-manager.svelte.ts
+++ b/frontend/src/routes/(app)/containers/components/container-stats-manager.svelte.ts
@@ -1,76 +1,34 @@
-import { SvelteMap, SvelteSet } from 'svelte/reactivity';
+import { SvelteMap } from 'svelte/reactivity';
-import type { ContainerStats } from '#lib/types/docker.js';
-import { calculateCPUPercent, calculateMemoryPercent, calculateMemoryUsage } from '#lib/utils/docker.js';
+import type { ContainerResourceSample, ContainerResourceSampleBatch } from '#lib/types/docker.js';
import { parseRowKey } from '#lib/utils/environments.js';
-import { createContainerStatsWebSocket } from '#lib/utils/ws.js';
+import { createContainersStatsWebSocket } from '#lib/utils/ws.js';
import type { ReconnectingWebSocket } from '#lib/utils/ws.js';
+/** The server samples at most this many containers per environment stream. */
+const MAX_SUBSCRIBED_CONTAINERS = 500;
+
+interface EnvironmentStream {
+ ws: ReconnectingWebSocket<ContainerResourceSampleBatch>;
+ /** Container ID to table row key. */
+ rowKeys: Map<string, string>;
+}
+
+/** One batched stats socket per environment; samples are keyed by table row key. */
export class ContainerStatsManager {
- private connections = new SvelteMap<string, ReconnectingWebSocket<ContainerStats>>();
- private stats = new SvelteMap<string, ContainerStats>();
+ private streams = new Map<string, EnvironmentStream>();
+ private samples = new SvelteMap<string, ContainerResourceSample>();
private loadingStates = new SvelteMap<string, boolean>();
private errorStates = new SvelteMap<string, boolean>();
- private desiredIds = new SvelteSet<string>();
-
- /** Keyed by table row key; the row's environment is decoded only for the websocket URL. */
- connect(containerId: string): void {
- if (this.connections.has(containerId)) return;
- const { id, environmentId } = parseRowKey(containerId);
- if (!environmentId) return;
-
- this.loadingStates.set(containerId, true);
-
- const ws = createContainerStatsWebSocket({
- getEnvId: () => environmentId,
- containerId: id,
- onMessage: (data: ContainerStats) => {
- this.stats.set(containerId, data);
- this.loadingStates.set(containerId, false);
- this.errorStates.delete(containerId);
- },
- onError: () => {
- this.stats.delete(containerId);
- this.loadingStates.set(containerId, false);
- this.errorStates.set(containerId, true);
- },
- shouldReconnect: () => this.connections.has(containerId)
- });
-
- ws.connect();
- this.connections.set(containerId, ws);
- }
-
- disconnect(containerId: string): void {
- const ws = this.connections.get(containerId);
- if (ws) {
- ws.close();
- this.connections.delete(containerId);
- this.stats.delete(containerId);
- this.loadingStates.delete(containerId);
- this.errorStates.delete(containerId);
- }
- }
getCPUPercent(containerId: string): number | undefined {
- const stats = this.stats.get(containerId);
- if (!stats) return undefined;
- return calculateCPUPercent(stats);
- }
-
- getMemoryPercent(containerId: string): number | undefined {
- const stats = this.stats.get(containerId);
- if (!stats) return undefined;
- return calculateMemoryPercent(stats);
+ return this.samples.get(containerId)?.cpuPercent;
}
getMemoryUsage(containerId: string): { usage: number; limit: number } | undefined {
- const stats = this.stats.get(containerId);
- if (!stats) return undefined;
- return {
- usage: calculateMemoryUsage(stats),
- limit: stats.memory_stats?.limit || 0
- };
+ const sample = this.samples.get(containerId);
+ if (!sample) return undefined;
+ return { usage: sample.memoryUsageBytes, limit: sample.memoryLimitBytes };
}
isLoading(containerId: string): boolean {
@@ -81,42 +39,109 @@ export class ContainerStatsManager {
return this.errorStates.get(containerId) ?? false;
}
- hasConnection(containerId: string): boolean {
- return this.connections.has(containerId);
+ /** Table row keys; each container is sampled on its row's environment stream. */
+ set targetIds(value: Set<string>) {
+ const byEnvironment = new Map<string, Map<string, string>>();
+ for (const key of value) {
+ const { id, environmentId } = parseRowKey(key);
+ if (!environmentId) continue;
+ const rowKeys = byEnvironment.get(environmentId) ?? new Map<string, string>();
+ rowKeys.set(id, key);
+ byEnvironment.set(environmentId, rowKeys);
+ }
+
+ for (const [environmentId, stream] of this.streams) {
+ if (byEnvironment.has(environmentId)) continue;
+ stream.ws.close();
+ this.streams.delete(environmentId);
+ this.forget(stream.rowKeys.values());
+ }
+
+ for (const [environmentId, rowKeys] of byEnvironment) {
+ const stream = this.streams.get(environmentId);
+ if (!stream) {
+ for (const key of rowKeys.values()) this.loadingStates.set(key, true);
+ this.open(environmentId, rowKeys);
+ continue;
+ }
+ const unchanged = stream.rowKeys.size === rowKeys.size && [...rowKeys.keys()].every((id) => stream.rowKeys.has(id));
+ if (unchanged) continue;
+
+ this.forget([...stream.rowKeys].filter(([id]) => !rowKeys.has(id)).map(([, key]) => key));
+ for (const [id, key] of rowKeys) {
+ if (!stream.rowKeys.has(id)) this.loadingStates.set(key, true);
+ }
+ stream.rowKeys = rowKeys;
+ this.subscribe(stream);
+ }
+ }
+
+ destroy(): void {
+ for (const stream of this.streams.values()) stream.ws.close();
+ this.streams.clear();
+ this.samples.clear();
+ this.loadingStates.clear();
+ this.errorStates.clear();
}
- getConnectedIds(): string[] {
- return Array.from(this.connections.keys());
+ private open(environmentId: string, rowKeys: Map<string, string>): void {
+ const ws = createContainersStatsWebSocket({
+ envId: environmentId,
+ onOpen: () => {
+ const stream = this.streams.get(environmentId);
+ if (stream?.ws === ws) this.subscribe(stream);
+ },
+ onMessage: (batch) => {
+ const stream = this.streams.get(environmentId);
+ if (stream?.ws === ws) this.apply(stream, batch);
+ },
+ onError: () => {
+ const stream = this.streams.get(environmentId);
+ if (stream?.ws === ws) this.markUnavailable(stream);
+ },
+ shouldReconnect: () => this.streams.get(environmentId)?.ws === ws
+ });
+ this.streams.set(environmentId, { ws, rowKeys });
+ void ws.connect();
}
- /** Table row keys; each container streams from its row's environment. */
- set targetIds(value: Set<string>) {
- this.desiredIds = new SvelteSet(value);
- this.syncConnections();
+ /** Sends the stream's container set; a closed socket resends it from onOpen. */
+ private subscribe(stream: EnvironmentStream): void {
+ const containerIds = [...stream.rowKeys.keys()].slice(0, MAX_SUBSCRIBED_CONTAINERS);
+ stream.ws.send(JSON.stringify({ containerIds }));
}
- private syncConnections(): void {
- const connectedIds = new SvelteSet(this.connections.keys());
- for (const id of this.desiredIds) {
- if (!connectedIds.has(id)) {
- this.connect(id);
+ /** Writes one batch in a single synchronous pass so it flushes as one update. */
+ private apply(stream: EnvironmentStream, batch: ContainerResourceSampleBatch): void {
+ if (batch.error) {
+ this.markUnavailable(stream);
+ return;
+ }
+ for (const [id, key] of stream.rowKeys) {
+ const sample = batch.samples?.[id];
+ if (sample) {
+ this.samples.set(key, sample);
+ this.errorStates.delete(key);
+ } else {
+ this.samples.delete(key);
}
+ this.loadingStates.set(key, false);
}
+ }
- for (const id of connectedIds) {
- if (!this.desiredIds.has(id)) {
- this.disconnect(id);
- }
+ private markUnavailable(stream: EnvironmentStream): void {
+ for (const key of stream.rowKeys.values()) {
+ this.samples.delete(key);
+ this.loadingStates.set(key, false);
+ this.errorStates.set(key, true);
}
}
- destroy(): void {
- for (const ws of this.connections.values()) {
- ws.close();
+ private forget(keys: Iterable<string>): void {
+ for (const key of keys) {
+ this.samples.delete(key);
+ this.loadingStates.delete(key);
+ this.errorStates.delete(key);
}
- this.connections.clear();
- this.stats.clear();
- this.loadingStates.clear();
- this.errorStates.clear();
}
}
diff --git a/frontend/src/routes/(app)/containers/components/container-stats-sync.svelte b/frontend/src/routes/(app)/containers/components/container-stats-sync.svelte
index eed42397b..d8528e15e 100644
--- a/frontend/src/routes/(app)/containers/components/container-stats-sync.svelte
+++ b/frontend/src/routes/(app)/containers/components/container-stats-sync.svelte
@@ -1,4 +1,6 @@
<script lang="ts">
+ import { untrack } from 'svelte';
+
import type { ContainerStatsManager } from './container-stats-manager.svelte';
let {
@@ -9,7 +11,11 @@
targetIds: Set<string>;
} = $props();
+ // Only targetIds is tracked; the manager's own state reads and writes stay out of this effect.
$effect(() => {
- statsManager.targetIds = targetIds;
+ const ids = targetIds;
+ untrack(() => {
+ statsManager.targetIds = ids;
+ });
});
</script>
diff --git a/frontend/src/routes/(app)/containers/components/container-table.svelte b/frontend/src/routes/(app)/containers/components/container-table.svelte
index dd57d0112..91c6c81e8 100644
--- a/frontend/src/routes/(app)/containers/components/container-table.svelte
+++ b/frontend/src/routes/(app)/containers/components/container-table.svelte
@@ -717,9 +717,9 @@
{#if !status && item.state !== 'running' && hasPermission('containers:start', item.environmentId)}
<ArcaneButton
action="base"
- tone="outline"
+ tone="ghost"
size="sm"
- class="size-7 border-transparent bg-transparent p-0 text-success shadow-none hover:bg-success/10 hover:text-success"
+ class="size-7 p-0 text-success! hover:bg-success/10 hover:text-success"
onclick={() => performContainerAction('start', item.id, item.environmentId)}
disabled={!resourcesCurrent || isAnyLoading}
icon={StartIcon}
@@ -728,9 +728,9 @@
{:else if !status && item.state === 'running' && hasPermission('containers:stop', item.environmentId)}
<ArcaneButton
action="base"
- tone="outline"
+ tone="ghost"
size="sm"
- class="size-7 border-transparent bg-transparent p-0 text-destructive shadow-none hover:bg-destructive/10 hover:text-destructive"
+ class="size-7 p-0 text-destructive! hover:bg-destructive/10 hover:text-destructive"
onclick={() => performContainerAction('stop', item.id, item.environmentId)}
disabled={!resourcesCurrent || isAnyLoading}
title={m.common_stop()}
diff --git a/frontend/src/routes/layout.css b/frontend/src/routes/layout.css
index 298b9de3e..9c92797b7 100644
--- a/frontend/src/routes/layout.css
+++ b/frontend/src/routes/layout.css
@@ -218,6 +218,10 @@ html.reduce-effects *::after {
--radius-4xl: calc(var(--radius) * 2.6);
--color-background: var(--background);
+ --color-row-hover: color-mix(in oklab, var(--primary) 6%, var(--background));
+ --color-row-selected: color-mix(in oklab, var(--primary) 12%, var(--background));
+ --color-row-selected-hover: color-mix(in oklab, var(--primary) 15%, var(--background));
+ --color-row-expanded: color-mix(in oklab, var(--muted) 30%, var(--background));
--color-foreground: var(--foreground);
--color-muted: var(--muted);
--color-muted-foreground: var(--muted-foreground);
@@ -567,3 +571,7 @@ input:autofill:active {
@utility rounded-inherit {
border-radius: inherit;
}
+
+@utility transition-stroke-dashoffset {
+ transition-property: stroke-dashoffset;
+}
diff --git a/types/container/container.go b/types/container/container.go
index 87994e868..a40e44adc 100644
--- a/types/container/container.go
+++ b/types/container/container.go
@@ -836,6 +836,34 @@ type ResourceSample struct {
SampleTime time.Time `json:"sampleTime"`
}
+// ResourceSampleSubscription is the client frame on the batched container stats
+// stream naming the containers to sample. Each frame replaces the previous set.
+type ResourceSampleSubscription struct {
+ // ContainerIDs are the containers to sample.
+ //
+ // Required: true
+ ContainerIDs []string `json:"containerIds"`
+}
+
+// ResourceSampleBatch is one server frame on the batched container stats stream.
+type ResourceSampleBatch struct {
+ // Samples maps container ID to its sample. Stopped, unknown and unsampled
+ // containers are omitted.
+ //
+ // Required: true
+ Samples map[string]*ResourceSample `json:"samples"`
+
+ // Error describes why this round could not be sampled.
+ //
+ // Required: false
+ Error string `json:"error,omitempty"`
+
+ // Timestamp is when the batch was sent.
+ //
+ // Required: true
+ Timestamp time.Time `json:"timestamp"`
+}
+
// Summary represents a container summary.
type Summary struct {
base.EnvironmentTag