Skip to content

An open-source, faster Devin alternative

TypeScript

add terminal ssh, some ui improvements

Brian Reardon56104bece47e
diff --git a/internal/api/dashboard.go b/internal/api/dashboard.go
index d54f7796..3ca06cdd 100644
--- a/internal/api/dashboard.go
+++ b/internal/api/dashboard.go
@@ -1,12 +1,20 @@
package api
import (
+ "context"
+ "encoding/json"
+ "fmt"
"net/http"
+ "time"
"github.com/google/uuid"
+ "github.com/gorilla/websocket"
"github.com/labstack/echo/v4"
"github.com/opensandbox/opensandbox/internal/auth"
"github.com/opensandbox/opensandbox/internal/db"
+ "github.com/opensandbox/opensandbox/internal/sandbox"
+ "github.com/opensandbox/opensandbox/pkg/types"
+ pb "github.com/opensandbox/opensandbox/proto/worker"
)
// dashboardMe returns the current authenticated user info.
@@ -245,7 +253,24 @@ func (s *Server) dashboardListTemplates(c echo.Context) error {
})
}
- return c.JSON(http.StatusOK, templates)
+ // Strip internal image refs from dashboard response
+ type safeTemplate struct {
+ ID uuid.UUID `json:"id"`
+ OrgID *uuid.UUID `json:"orgId,omitempty"`
+ Name string `json:"name"`
+ Tag string `json:"tag"`
+ IsPublic bool `json:"isPublic"`
+ CreatedAt time.Time `json:"createdAt"`
+ }
+ safe := make([]safeTemplate, len(templates))
+ for i, t := range templates {
+ safe[i] = safeTemplate{
+ ID: t.ID, OrgID: t.OrgID, Name: t.Name,
+ Tag: t.Tag, IsPublic: t.IsPublic, CreatedAt: t.CreatedAt,
+ }
+ }
+
+ return c.JSON(http.StatusOK, safe)
}
// dashboardBuildTemplate builds a new template for the authenticated org.
@@ -284,3 +309,394 @@ func (s *Server) dashboardDeleteTemplate(c echo.Context) error {
return c.NoContent(http.StatusNoContent)
}
+
+// dashboardGetSession returns detailed info for a single session.
+func (s *Server) dashboardGetSession(c echo.Context) error {
+ if s.store == nil {
+ return c.JSON(http.StatusServiceUnavailable, map[string]string{
+ "error": "database not configured",
+ })
+ }
+
+ orgID, ok := auth.GetOrgID(c)
+ if !ok {
+ return c.JSON(http.StatusUnauthorized, map[string]string{
+ "error": "org context required",
+ })
+ }
+
+ sandboxID := c.Param("sandboxId")
+ session, err := s.store.GetSandboxSession(c.Request().Context(), sandboxID)
+ if err != nil {
+ return c.JSON(http.StatusNotFound, map[string]string{
+ "error": "session not found",
+ })
+ }
+
+ // Verify session belongs to this org
+ if session.OrgID != orgID {
+ return c.JSON(http.StatusForbidden, map[string]string{
+ "error": "session does not belong to this organization",
+ })
+ }
+
+ // Build response
+ resp := map[string]interface{}{
+ "id": session.ID,
+ "sandboxId": session.SandboxID,
+ "template": session.Template,
+ "status": session.Status,
+ "startedAt": session.StartedAt,
+ }
+ if session.StoppedAt != nil {
+ resp["stoppedAt"] = session.StoppedAt
+ }
+ if session.ErrorMsg != nil {
+ resp["errorMsg"] = *session.ErrorMsg
+ }
+
+ // Compute domain
+ if s.sandboxDomain != "" {
+ resp["domain"] = fmt.Sprintf("%s.%s", sandboxID, s.sandboxDomain)
+ }
+
+ // Parse config JSON if available
+ if len(session.Config) > 0 {
+ var cfg map[string]interface{}
+ if json.Unmarshal(session.Config, &cfg) == nil {
+ resp["config"] = cfg
+ }
+ }
+
+ // If hibernated, include checkpoint info
+ if session.Status == "hibernated" {
+ checkpoint, err := s.store.GetActiveCheckpoint(c.Request().Context(), sandboxID)
+ if err == nil {
+ resp["checkpoint"] = map[string]interface{}{
+ "checkpointKey": checkpoint.CheckpointKey,
+ "sizeBytes": checkpoint.SizeBytes,
+ "hibernatedAt": checkpoint.HibernatedAt,
+ }
+ }
+ }
+
+ return c.JSON(http.StatusOK, resp)
+}
+
+// dashboardGetSessionStats returns live CPU/memory stats for a running sandbox.
+func (s *Server) dashboardGetSessionStats(c echo.Context) error {
+ if s.store == nil {
+ return c.JSON(http.StatusServiceUnavailable, map[string]string{
+ "error": "database not configured",
+ })
+ }
+
+ orgID, ok := auth.GetOrgID(c)
+ if !ok {
+ return c.JSON(http.StatusUnauthorized, map[string]string{
+ "error": "org context required",
+ })
+ }
+
+ sandboxID := c.Param("sandboxId")
+ session, err := s.store.GetSandboxSession(c.Request().Context(), sandboxID)
+ if err != nil {
+ return c.JSON(http.StatusNotFound, map[string]string{
+ "error": "session not found",
+ })
+ }
+
+ if session.OrgID != orgID {
+ return c.JSON(http.StatusForbidden, map[string]string{
+ "error": "session does not belong to this organization",
+ })
+ }
+
+ if session.Status != "running" {
+ return c.JSON(http.StatusBadRequest, map[string]string{
+ "error": "sandbox is not running",
+ })
+ }
+
+ // Combined mode: get stats directly from manager
+ if s.manager != nil {
+ stats, err := s.manager.Stats(c.Request().Context(), sandboxID)
+ if err != nil {
+ return c.JSON(http.StatusServiceUnavailable, map[string]string{
+ "error": "stats unavailable: " + err.Error(),
+ })
+ }
+ return c.JSON(http.StatusOK, stats)
+ }
+
+ // Server mode: dispatch to worker via gRPC
+ if s.workerRegistry != nil {
+ grpcClient, err := s.workerRegistry.GetWorkerClient(session.WorkerID)
+ if err != nil {
+ return c.JSON(http.StatusServiceUnavailable, map[string]string{
+ "error": "worker not available: " + err.Error(),
+ })
+ }
+
+ ctx, cancel := context.WithTimeout(c.Request().Context(), 10*time.Second)
+ defer cancel()
+
+ grpcResp, err := grpcClient.GetSandboxStats(ctx, &pb.GetSandboxStatsRequest{
+ SandboxId: sandboxID,
+ })
+ if err != nil {
+ return c.JSON(http.StatusServiceUnavailable, map[string]string{
+ "error": "stats unavailable: " + err.Error(),
+ })
+ }
+
+ return c.JSON(http.StatusOK, map[string]interface{}{
+ "cpuPercent": grpcResp.CpuPercent,
+ "memUsage": grpcResp.MemUsage,
+ "memLimit": grpcResp.MemLimit,
+ "netInput": grpcResp.NetInput,
+ "netOutput": grpcResp.NetOutput,
+ "pids": grpcResp.Pids,
+ })
+ }
+
+ return c.JSON(http.StatusServiceUnavailable, map[string]string{
+ "error": "no stats provider available",
+ })
+}
+
+// dashboardCreatePTY creates a PTY session for a sandbox owned by the authenticated org.
+func (s *Server) dashboardCreatePTY(c echo.Context) error {
+ sandboxID, session, err := s.dashboardResolveSandbox(c)
+ if err != nil {
+ return err
+ }
+ _ = session
+
+ if s.ptyManager == nil {
+ return c.JSON(http.StatusServiceUnavailable, map[string]string{
+ "error": "terminal not available in server-only mode",
+ })
+ }
+
+ var req types.PTYCreateRequest
+ if err := c.Bind(&req); err != nil {
+ return c.JSON(http.StatusBadRequest, map[string]string{
+ "error": "invalid request body",
+ })
+ }
+
+ var ptySession *sandbox.PTYSessionHandle
+ routeOp := func(_ context.Context) error {
+ var err error
+ ptySession, err = s.ptyManager.CreateSession(sandboxID, req)
+ return err
+ }
+
+ if s.router != nil {
+ if err := s.router.Route(c.Request().Context(), sandboxID, "createPTY", routeOp); err != nil {
+ return c.JSON(http.StatusInternalServerError, map[string]string{
+ "error": err.Error(),
+ })
+ }
+ } else {
+ if err := routeOp(c.Request().Context()); err != nil {
+ return c.JSON(http.StatusInternalServerError, map[string]string{
+ "error": err.Error(),
+ })
+ }
+ }
+
+ return c.JSON(http.StatusCreated, map[string]string{
+ "sessionId": ptySession.ID,
+ "sandboxId": sandboxID,
+ })
+}
+
+// dashboardPTYWebSocket upgrades to a WebSocket for an interactive terminal.
+func (s *Server) dashboardPTYWebSocket(c echo.Context) error {
+ sandboxID, session, err := s.dashboardResolveSandbox(c)
+ if err != nil {
+ return err
+ }
+ _ = session
+
+ if s.ptyManager == nil {
+ return c.JSON(http.StatusServiceUnavailable, map[string]string{
+ "error": "terminal not available in server-only mode",
+ })
+ }
+
+ sessionID := c.Param("sessionId")
+ ptySession, err := s.ptyManager.GetSession(sessionID)
+ if err != nil {
+ return c.JSON(http.StatusNotFound, map[string]string{
+ "error": err.Error(),
+ })
+ }
+
+ if s.router != nil {
+ s.router.Touch(sandboxID)
+ }
+
+ ws, err := upgrader.Upgrade(c.Response(), c.Request(), nil)
+ if err != nil {
+ return err
+ }
+ defer ws.Close()
+
+ // PTY -> WebSocket
+ done := make(chan struct{})
+ go func() {
+ defer close(done)
+ buf := make([]byte, 4096)
+ for {
+ n, readErr := ptySession.PTY.Read(buf)
+ if n > 0 {
+ if writeErr := ws.WriteMessage(websocket.BinaryMessage, buf[:n]); writeErr != nil {
+ return
+ }
+ }
+ if readErr != nil {
+ return
+ }
+ }
+ }()
+
+ // WebSocket -> PTY
+ go func() {
+ for {
+ _, msg, readErr := ws.ReadMessage()
+ if readErr != nil {
+ return
+ }
+ if _, writeErr := ptySession.PTY.Write(msg); writeErr != nil {
+ return
+ }
+ if s.router != nil {
+ s.router.Touch(sandboxID)
+ }
+ }
+ }()
+
+ select {
+ case <-done:
+ case <-ptySession.Done:
+ }
+
+ ws.WriteControl(websocket.CloseMessage,
+ websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""),
+ time.Now().Add(time.Second))
+
+ return nil
+}
+
+// dashboardResizePTY resizes a PTY session.
+func (s *Server) dashboardResizePTY(c echo.Context) error {
+ _, session, err := s.dashboardResolveSandbox(c)
+ if err != nil {
+ return err
+ }
+ _ = session
+
+ if s.ptyManager == nil {
+ return c.JSON(http.StatusServiceUnavailable, map[string]string{
+ "error": "terminal not available in server-only mode",
+ })
+ }
+
+ sessionID := c.Param("sessionId")
+
+ var req struct {
+ Cols int `json:"cols"`
+ Rows int `json:"rows"`
+ }
+ if err := c.Bind(&req); err != nil {
+ return c.JSON(http.StatusBadRequest, map[string]string{
+ "error": "invalid request body",
+ })
+ }
+
+ if err := s.ptyManager.Resize(sessionID, req.Cols, req.Rows); err != nil {
+ return c.JSON(http.StatusNotFound, map[string]string{
+ "error": err.Error(),
+ })
+ }
+
+ return c.NoContent(http.StatusOK)
+}
+
+// dashboardKillPTY kills a PTY session.
+func (s *Server) dashboardKillPTY(c echo.Context) error {
+ sandboxID, session, err := s.dashboardResolveSandbox(c)
+ if err != nil {
+ return err
+ }
+ _ = session
+
+ if s.ptyManager == nil {
+ return c.JSON(http.StatusServiceUnavailable, map[string]string{
+ "error": "terminal not available in server-only mode",
+ })
+ }
+
+ sessionID := c.Param("sessionId")
+
+ routeOp := func(_ context.Context) error {
+ return s.ptyManager.KillSession(sessionID)
+ }
+
+ if s.router != nil {
+ if err := s.router.Route(c.Request().Context(), sandboxID, "killPTY", routeOp); err != nil {
+ return c.JSON(http.StatusNotFound, map[string]string{
+ "error": err.Error(),
+ })
+ }
+ } else {
+ if err := routeOp(c.Request().Context()); err != nil {
+ return c.JSON(http.StatusNotFound, map[string]string{
+ "error": err.Error(),
+ })
+ }
+ }
+
+ return c.NoContent(http.StatusNoContent)
+}
+
+// dashboardResolveSandbox validates the sandbox belongs to the authenticated org and is running.
+func (s *Server) dashboardResolveSandbox(c echo.Context) (string, *db.SandboxSession, error) {
+ if s.store == nil {
+ return "", nil, c.JSON(http.StatusServiceUnavailable, map[string]string{
+ "error": "database not configured",
+ })
+ }
+
+ orgID, ok := auth.GetOrgID(c)
+ if !ok {
+ return "", nil, c.JSON(http.StatusUnauthorized, map[string]string{
+ "error": "org context required",
+ })
+ }
+
+ sandboxID := c.Param("sandboxId")
+ session, err := s.store.GetSandboxSession(c.Request().Context(), sandboxID)
+ if err != nil {
+ return "", nil, c.JSON(http.StatusNotFound, map[string]string{
+ "error": "session not found",
+ })
+ }
+
+ if session.OrgID != orgID {
+ return "", nil, c.JSON(http.StatusForbidden, map[string]string{
+ "error": "session does not belong to this organization",
+ })
+ }
+
+ if session.Status != "running" {
+ return "", nil, c.JSON(http.StatusBadRequest, map[string]string{
+ "error": "sandbox is not running",
+ })
+ }
+
+ return sandboxID, session, nil
+}
diff --git a/internal/api/router.go b/internal/api/router.go
index 16807a35..b7a46f70 100644
--- a/internal/api/router.go
+++ b/internal/api/router.go
@@ -170,6 +170,16 @@ func NewServer(mgr *sandbox.Manager, ptyMgr *sandbox.PTYManager, apiKey string,
dash.GET("/templates", s.dashboardListTemplates)
dash.POST("/templates", s.dashboardBuildTemplate)
dash.DELETE("/templates/:id", s.dashboardDeleteTemplate)
+
+ // Session detail + stats
+ dash.GET("/sessions/:sandboxId", s.dashboardGetSession)
+ dash.GET("/sessions/:sandboxId/stats", s.dashboardGetSessionStats)
+
+ // PTY (terminal)
+ dash.POST("/sessions/:sandboxId/pty", s.dashboardCreatePTY)
+ dash.GET("/sessions/:sandboxId/pty/:sessionId", s.dashboardPTYWebSocket)
+ dash.POST("/sessions/:sandboxId/pty/:sessionId/resize", s.dashboardResizePTY)
+ dash.DELETE("/sessions/:sandboxId/pty/:sessionId", s.dashboardKillPTY)
}
// Auto-detect FrontendURL for dev: if web/dist doesn't exist, assume Vite dev on :3000
diff --git a/internal/controlplane/redis_registry.go b/internal/controlplane/redis_registry.go
index c9b93ae3..0241caa0 100644
--- a/internal/controlplane/redis_registry.go
+++ b/internal/controlplane/redis_registry.go
@@ -240,8 +240,8 @@ func (r *RedisWorkerRegistry) dialWorkerLocked(workerID, grpcAddr string) {
conn, err := grpc.NewClient(grpcAddr,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithKeepaliveParams(keepalive.ClientParameters{
- Time: 10 * time.Second,
- Timeout: 5 * time.Second,
+ Time: 30 * time.Second,
+ Timeout: 10 * time.Second,
PermitWithoutStream: true,
}),
)
diff --git a/internal/podman/container.go b/internal/podman/container.go
index 10f17843..396862e7 100644
--- a/internal/podman/container.go
+++ b/internal/podman/container.go
@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
+ "strconv"
"strings"
)
@@ -256,6 +257,117 @@ func parseJSONOutput(output string, dest *[]PSEntry) error {
return nil
}
+// ContainerStats holds resource usage stats for a running container.
+type ContainerStats struct {
+ CPUPercent float64 `json:"cpuPercent"`
+ MemUsage uint64 `json:"memUsage"` // bytes
+ MemLimit uint64 `json:"memLimit"` // bytes
+ NetInput uint64 `json:"netInput"` // bytes
+ NetOutput uint64 `json:"netOutput"`// bytes
+ PIDs int `json:"pids"`
+}
+
+// podmanStatsEntry matches the JSON output of podman stats --format json.
+// Note: podman outputs pids as a string (e.g. "1") and mem_usage includes both
+// usage and limit combined (e.g. "303.1kB / 536.9MB").
+type podmanStatsEntry struct {
+ CPU string `json:"cpu_percent"`
+ MemUsage string `json:"mem_usage"` // "usage / limit" combined
+ NetIO string `json:"net_io"`
+ PIDs string `json:"pids"` // podman outputs as string
+}
+
+// ContainerStats returns live resource usage stats for a running container.
+func (c *Client) ContainerStats(ctx context.Context, nameOrID string) (*ContainerStats, error) {
+ result, err := c.Run(ctx, "stats", "--no-stream", "--no-reset", "--format", "json", nameOrID)
+ if err != nil {
+ return nil, fmt.Errorf("failed to get stats for %s: %w", nameOrID, err)
+ }
+ if result.ExitCode != 0 {
+ return nil, fmt.Errorf("podman stats failed (exit %d): %s",
+ result.ExitCode, strings.TrimSpace(result.Stderr))
+ }
+
+ output := strings.TrimSpace(result.Stdout)
+ if output == "" {
+ return nil, fmt.Errorf("no stats output for %s", nameOrID)
+ }
+
+ var entries []podmanStatsEntry
+ if err := json.Unmarshal([]byte(output), &entries); err != nil {
+ return nil, fmt.Errorf("failed to parse stats JSON: %w", err)
+ }
+ if len(entries) == 0 {
+ return nil, fmt.Errorf("no stats entries for %s", nameOrID)
+ }
+
+ e := entries[0]
+ stats := &ContainerStats{}
+
+ // Parse PIDs: podman outputs as string (e.g. "1")
+ if v, err := strconv.Atoi(strings.TrimSpace(e.PIDs)); err == nil {
+ stats.PIDs = v
+ }
+
+ // Parse CPU percent: "12.5%" -> 12.5
+ cpu := strings.TrimSpace(strings.TrimSuffix(e.CPU, "%"))
+ if v, err := strconv.ParseFloat(cpu, 64); err == nil {
+ stats.CPUPercent = v
+ }
+
+ // Parse memory: podman combines usage and limit as "303.1kB / 536.9MB"
+ if parts := strings.SplitN(e.MemUsage, "/", 2); len(parts) == 2 {
+ stats.MemUsage = parseBytes(strings.TrimSpace(parts[0]))
+ stats.MemLimit = parseBytes(strings.TrimSpace(parts[1]))
+ } else {
+ stats.MemUsage = parseBytes(e.MemUsage)
+ }
+
+ // Parse net I/O: "1.2kB / 3.4kB"
+ if parts := strings.SplitN(e.NetIO, "/", 2); len(parts) == 2 {
+ stats.NetInput = parseBytes(strings.TrimSpace(parts[0]))
+ stats.NetOutput = parseBytes(strings.TrimSpace(parts[1]))
+ }
+
+ return stats, nil
+}
+
+// parseBytes converts human-readable byte strings like "45.2MB", "1.5GiB", "512kB" to bytes.
+func parseBytes(s string) uint64 {
+ s = strings.TrimSpace(s)
+ if s == "" || s == "--" {
+ return 0
+ }
+
+ multipliers := map[string]float64{
+ "B": 1,
+ "kB": 1000,
+ "KB": 1000,
+ "MB": 1000 * 1000,
+ "GB": 1000 * 1000 * 1000,
+ "TB": 1000 * 1000 * 1000 * 1000,
+ "KiB": 1024,
+ "MiB": 1024 * 1024,
+ "GiB": 1024 * 1024 * 1024,
+ "TiB": 1024 * 1024 * 1024 * 1024,
+ }
+
+ for suffix, mult := range multipliers {
+ if strings.HasSuffix(s, suffix) {
+ numStr := strings.TrimSpace(strings.TrimSuffix(s, suffix))
+ if v, err := strconv.ParseFloat(numStr, 64); err == nil {
+ return uint64(v * mult)
+ }
+ }
+ }
+
+ // Try as plain number
+ if v, err := strconv.ParseUint(s, 10, 64); err == nil {
+ return v
+ }
+ return 0
+}
+
// PullImage pulls a container image.
func (c *Client) PullImage(ctx context.Context, image string) error {
result, err := c.Run(ctx, "pull", image)
diff --git a/internal/sandbox/manager.go b/internal/sandbox/manager.go
index f63eebe8..31d328ba 100644
--- a/internal/sandbox/manager.go
+++ b/internal/sandbox/manager.go
@@ -188,6 +188,12 @@ func (m *Manager) HostPort(ctx context.Context, sandboxID string) (int, error) {
return port, nil
}
+// Stats returns live CPU/memory stats for a running sandbox.
+func (m *Manager) Stats(ctx context.Context, sandboxID string) (*podman.ContainerStats, error) {
+ name := m.ContainerName(sandboxID)
+ return m.podman.ContainerStats(ctx, name)
+}
+
// Close is a no-op — timer management now lives in SandboxRouter.
func (m *Manager) Close() {}
diff --git a/internal/worker/grpc_server.go b/internal/worker/grpc_server.go
index e1c44f74..be0547dc 100644
--- a/internal/worker/grpc_server.go
+++ b/internal/worker/grpc_server.go
@@ -7,6 +7,7 @@ import (
"time"
"google.golang.org/grpc"
+ "google.golang.org/grpc/keepalive"
"github.com/opensandbox/opensandbox/internal/sandbox"
"github.com/opensandbox/opensandbox/internal/storage"
@@ -36,7 +37,16 @@ func NewGRPCServer(mgr *sandbox.Manager, ptyMgr *sandbox.PTYManager, sandboxDBs
sandboxDBs: sandboxDBs,
checkpointStore: checkpointStore,
builder: builder,
- server: grpc.NewServer(),
+ server: grpc.NewServer(
+ grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{
+ MinTime: 5 * time.Second,
+ PermitWithoutStream: true,
+ }),
+ grpc.KeepaliveParams(keepalive.ServerParameters{
+ Time: 30 * time.Second,
+ Timeout: 10 * time.Second,
+ }),
+ ),
}
pb.RegisterSandboxWorkerServer(s.server, s)
return s
@@ -362,3 +372,19 @@ func (s *GRPCServer) BuildTemplate(ctx context.Context, req *pb.BuildTemplateReq
BuildLog: buildLog,
}, nil
}
+
+func (s *GRPCServer) GetSandboxStats(ctx context.Context, req *pb.GetSandboxStatsRequest) (*pb.GetSandboxStatsResponse, error) {
+ stats, err := s.manager.Stats(ctx, req.SandboxId)
+ if err != nil {
+ return nil, fmt.Errorf("failed to get sandbox stats: %w", err)
+ }
+
+ return &pb.GetSandboxStatsResponse{
+ CpuPercent: stats.CPUPercent,
+ MemUsage: stats.MemUsage,
+ MemLimit: stats.MemLimit,
+ NetInput: stats.NetInput,
+ NetOutput: stats.NetOutput,
+ Pids: int32(stats.PIDs),
+ }, nil
+}
diff --git a/proto/worker/worker.pb.go b/proto/worker/worker.pb.go
index 7e4c7a07..2a23a5da 100644
--- a/proto/worker/worker.pb.go
+++ b/proto/worker/worker.pb.go
@@ -1685,6 +1685,134 @@ func (x *BuildTemplateResponse) GetBuildLog() string {
return ""
}
+type GetSandboxStatsRequest struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ SandboxId string `protobuf:"bytes,1,opt,name=sandbox_id,json=sandboxId,proto3" json:"sandbox_id,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *GetSandboxStatsRequest) Reset() {
+ *x = GetSandboxStatsRequest{}
+ mi := &file_proto_worker_worker_proto_msgTypes[29]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *GetSandboxStatsRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*GetSandboxStatsRequest) ProtoMessage() {}
+
+func (x *GetSandboxStatsRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_proto_worker_worker_proto_msgTypes[29]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use GetSandboxStatsRequest.ProtoReflect.Descriptor instead.
+func (*GetSandboxStatsRequest) Descriptor() ([]byte, []int) {
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{29}
+}
+
+func (x *GetSandboxStatsRequest) GetSandboxId() string {
+ if x != nil {
+ return x.SandboxId
+ }
+ return ""
+}
+
+type GetSandboxStatsResponse struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ CpuPercent float64 `protobuf:"fixed64,1,opt,name=cpu_percent,json=cpuPercent,proto3" json:"cpu_percent,omitempty"`
+ MemUsage uint64 `protobuf:"varint,2,opt,name=mem_usage,json=memUsage,proto3" json:"mem_usage,omitempty"`
+ MemLimit uint64 `protobuf:"varint,3,opt,name=mem_limit,json=memLimit,proto3" json:"mem_limit,omitempty"`
+ NetInput uint64 `protobuf:"varint,4,opt,name=net_input,json=netInput,proto3" json:"net_input,omitempty"`
+ NetOutput uint64 `protobuf:"varint,5,opt,name=net_output,json=netOutput,proto3" json:"net_output,omitempty"`
+ Pids int32 `protobuf:"varint,6,opt,name=pids,proto3" json:"pids,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *GetSandboxStatsResponse) Reset() {
+ *x = GetSandboxStatsResponse{}
+ mi := &file_proto_worker_worker_proto_msgTypes[30]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *GetSandboxStatsResponse) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*GetSandboxStatsResponse) ProtoMessage() {}
+
+func (x *GetSandboxStatsResponse) ProtoReflect() protoreflect.Message {
+ mi := &file_proto_worker_worker_proto_msgTypes[30]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use GetSandboxStatsResponse.ProtoReflect.Descriptor instead.
+func (*GetSandboxStatsResponse) Descriptor() ([]byte, []int) {
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{30}
+}
+
+func (x *GetSandboxStatsResponse) GetCpuPercent() float64 {
+ if x != nil {
+ return x.CpuPercent
+ }
+ return 0
+}
+
+func (x *GetSandboxStatsResponse) GetMemUsage() uint64 {
+ if x != nil {
+ return x.MemUsage
+ }
+ return 0
+}
+
+func (x *GetSandboxStatsResponse) GetMemLimit() uint64 {
+ if x != nil {
+ return x.MemLimit
+ }
+ return 0
+}
+
+func (x *GetSandboxStatsResponse) GetNetInput() uint64 {
+ if x != nil {
+ return x.NetInput
+ }
+ return 0
+}
+
+func (x *GetSandboxStatsResponse) GetNetOutput() uint64 {
+ if x != nil {
+ return x.NetOutput
+ }
+ return 0
+}
+
+func (x *GetSandboxStatsResponse) GetPids() int32 {
+ if x != nil {
+ return x.Pids
+ }
+ return 0
+}
+
var File_proto_worker_worker_proto protoreflect.FileDescriptor
const file_proto_worker_worker_proto_rawDesc = "" +
@@ -1818,7 +1946,19 @@ const file_proto_worker_worker_proto_rawDesc = "" +
"\recr_image_ref\x18\x04 \x01(\tR\vecrImageRef\"Q\n" +
"\x15BuildTemplateResponse\x12\x1b\n" +
"\timage_ref\x18\x01 \x01(\tR\bimageRef\x12\x1b\n" +
- "\tbuild_log\x18\x02 \x01(\tR\bbuildLog2\xf7\a\n" +
+ "\tbuild_log\x18\x02 \x01(\tR\bbuildLog\"7\n" +
+ "\x16GetSandboxStatsRequest\x12\x1d\n" +
+ "\n" +
+ "sandbox_id\x18\x01 \x01(\tR\tsandboxId\"\xc4\x01\n" +
+ "\x17GetSandboxStatsResponse\x12\x1f\n" +
+ "\vcpu_percent\x18\x01 \x01(\x01R\n" +
+ "cpuPercent\x12\x1b\n" +
+ "\tmem_usage\x18\x02 \x01(\x04R\bmemUsage\x12\x1b\n" +
+ "\tmem_limit\x18\x03 \x01(\x04R\bmemLimit\x12\x1b\n" +
+ "\tnet_input\x18\x04 \x01(\x04R\bnetInput\x12\x1d\n" +
+ "\n" +
+ "net_output\x18\x05 \x01(\x04R\tnetOutput\x12\x12\n" +
+ "\x04pids\x18\x06 \x01(\x05R\x04pids2\xcb\b\n" +
"\rSandboxWorker\x12L\n" +
"\rCreateSandbox\x12\x1c.worker.CreateSandboxRequest\x1a\x1d.worker.CreateSandboxResponse\x12O\n" +
"\x0eDestroySandbox\x12\x1d.worker.DestroySandboxRequest\x1a\x1e.worker.DestroySandboxResponse\x12C\n" +
@@ -1834,7 +1974,8 @@ const file_proto_worker_worker_proto_rawDesc = "" +
"\tPTYStream\x12\x10.worker.PTYInput\x1a\x11.worker.PTYOutput(\x010\x01\x12U\n" +
"\x10HibernateSandbox\x12\x1f.worker.HibernateSandboxRequest\x1a .worker.HibernateSandboxResponse\x12F\n" +
"\vWakeSandbox\x12\x1a.worker.WakeSandboxRequest\x1a\x1b.worker.WakeSandboxResponse\x12L\n" +
- "\rBuildTemplate\x12\x1c.worker.BuildTemplateRequest\x1a\x1d.worker.BuildTemplateResponseB1Z/github.com/opensandbox/opensandbox/proto/workerb\x06proto3"
+ "\rBuildTemplate\x12\x1c.worker.BuildTemplateRequest\x1a\x1d.worker.BuildTemplateResponse\x12R\n" +
+ "\x0fGetSandboxStats\x12\x1e.worker.GetSandboxStatsRequest\x1a\x1f.worker.GetSandboxStatsResponseB1Z/github.com/opensandbox/opensandbox/proto/workerb\x06proto3"
var (
file_proto_worker_worker_proto_rawDescOnce sync.Once
@@ -1849,7 +1990,7 @@ func file_proto_worker_worker_proto_rawDescGZIP() []byte {
}
var file_proto_worker_worker_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
-var file_proto_worker_worker_proto_msgTypes = make([]protoimpl.MessageInfo, 31)
+var file_proto_worker_worker_proto_msgTypes = make([]protoimpl.MessageInfo, 33)
var file_proto_worker_worker_proto_goTypes = []any{
(ExecOutputChunk_Stream)(0), // 0: worker.ExecOutputChunk.Stream
(*CreateSandboxRequest)(nil), // 1: worker.CreateSandboxRequest
@@ -1881,13 +2022,15 @@ var file_proto_worker_worker_proto_goTypes = []any{
(*WakeSandboxResponse)(nil), // 27: worker.WakeSandboxResponse
(*BuildTemplateRequest)(nil), // 28: worker.BuildTemplateRequest
(*BuildTemplateResponse)(nil), // 29: worker.BuildTemplateResponse
- nil, // 30: worker.CreateSandboxRequest.EnvsEntry
- nil, // 31: worker.ExecCommandRequest.EnvsEntry
+ (*GetSandboxStatsRequest)(nil), // 30: worker.GetSandboxStatsRequest
+ (*GetSandboxStatsResponse)(nil), // 31: worker.GetSandboxStatsResponse
+ nil, // 32: worker.CreateSandboxRequest.EnvsEntry
+ nil, // 33: worker.ExecCommandRequest.EnvsEntry
}
var file_proto_worker_worker_proto_depIdxs = []int32{
- 30, // 0: worker.CreateSandboxRequest.envs:type_name -> worker.CreateSandboxRequest.EnvsEntry
+ 32, // 0: worker.CreateSandboxRequest.envs:type_name -> worker.CreateSandboxRequest.EnvsEntry
6, // 1: worker.ListSandboxesResponse.sandboxes:type_name -> worker.GetSandboxResponse
- 31, // 2: worker.ExecCommandRequest.envs:type_name -> worker.ExecCommandRequest.EnvsEntry
+ 33, // 2: worker.ExecCommandRequest.envs:type_name -> worker.ExecCommandRequest.EnvsEntry
0, // 3: worker.ExecOutputChunk.stream:type_name -> worker.ExecOutputChunk.Stream
17, // 4: worker.ListDirResponse.entries:type_name -> worker.DirEntry
22, // 5: worker.PTYInput.resize:type_name -> worker.PTYResize
@@ -1905,22 +2048,24 @@ var file_proto_worker_worker_proto_depIdxs = []int32{
24, // 17: worker.SandboxWorker.HibernateSandbox:input_type -> worker.HibernateSandboxRequest
26, // 18: worker.SandboxWorker.WakeSandbox:input_type -> worker.WakeSandboxRequest
28, // 19: worker.SandboxWorker.BuildTemplate:input_type -> worker.BuildTemplateRequest
- 2, // 20: worker.SandboxWorker.CreateSandbox:output_type -> worker.CreateSandboxResponse
- 4, // 21: worker.SandboxWorker.DestroySandbox:output_type -> worker.DestroySandboxResponse
- 6, // 22: worker.SandboxWorker.GetSandbox:output_type -> worker.GetSandboxResponse
- 8, // 23: worker.SandboxWorker.ListSandboxes:output_type -> worker.ListSandboxesResponse
- 10, // 24: worker.SandboxWorker.ExecCommand:output_type -> worker.ExecCommandResponse
- 11, // 25: worker.SandboxWorker.ExecCommandStream:output_type -> worker.ExecOutputChunk
- 13, // 26: worker.SandboxWorker.ReadFile:output_type -> worker.ReadFileResponse
- 15, // 27: worker.SandboxWorker.WriteFile:output_type -> worker.WriteFileResponse
- 18, // 28: worker.SandboxWorker.ListDir:output_type -> worker.ListDirResponse
- 20, // 29: worker.SandboxWorker.CreatePTY:output_type -> worker.CreatePTYResponse
- 23, // 30: worker.SandboxWorker.PTYStream:output_type -> worker.PTYOutput
- 25, // 31: worker.SandboxWorker.HibernateSandbox:output_type -> worker.HibernateSandboxResponse
- 27, // 32: worker.SandboxWorker.WakeSandbox:output_type -> worker.WakeSandboxResponse
- 29, // 33: worker.SandboxWorker.BuildTemplate:output_type -> worker.BuildTemplateResponse
- 20, // [20:34] is the sub-list for method output_type
- 6, // [6:20] is the sub-list for method input_type
+ 30, // 20: worker.SandboxWorker.GetSandboxStats:input_type -> worker.GetSandboxStatsRequest
+ 2, // 21: worker.SandboxWorker.CreateSandbox:output_type -> worker.CreateSandboxResponse
+ 4, // 22: worker.SandboxWorker.DestroySandbox:output_type -> worker.DestroySandboxResponse
+ 6, // 23: worker.SandboxWorker.GetSandbox:output_type -> worker.GetSandboxResponse
+ 8, // 24: worker.SandboxWorker.ListSandboxes:output_type -> worker.ListSandboxesResponse
+ 10, // 25: worker.SandboxWorker.ExecCommand:output_type -> worker.ExecCommandResponse
+ 11, // 26: worker.SandboxWorker.ExecCommandStream:output_type -> worker.ExecOutputChunk
+ 13, // 27: worker.SandboxWorker.ReadFile:output_type -> worker.ReadFileResponse
+ 15, // 28: worker.SandboxWorker.WriteFile:output_type -> worker.WriteFileResponse
+ 18, // 29: worker.SandboxWorker.ListDir:output_type -> worker.ListDirResponse
+ 20, // 30: worker.SandboxWorker.CreatePTY:output_type -> worker.CreatePTYResponse
+ 23, // 31: worker.SandboxWorker.PTYStream:output_type -> worker.PTYOutput
+ 25, // 32: worker.SandboxWorker.HibernateSandbox:output_type -> worker.HibernateSandboxResponse
+ 27, // 33: worker.SandboxWorker.WakeSandbox:output_type -> worker.WakeSandboxResponse
+ 29, // 34: worker.SandboxWorker.BuildTemplate:output_type -> worker.BuildTemplateResponse
+ 31, // 35: worker.SandboxWorker.GetSandboxStats:output_type -> worker.GetSandboxStatsResponse
+ 21, // [21:36] is the sub-list for method output_type
+ 6, // [6:21] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
@@ -1941,7 +2086,7 @@ func file_proto_worker_worker_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_worker_worker_proto_rawDesc), len(file_proto_worker_worker_proto_rawDesc)),
NumEnums: 1,
- NumMessages: 31,
+ NumMessages: 33,
NumExtensions: 0,
NumServices: 1,
},
diff --git a/proto/worker/worker.proto b/proto/worker/worker.proto
index f6272c1c..72c07f3e 100644
--- a/proto/worker/worker.proto
+++ b/proto/worker/worker.proto
@@ -24,6 +24,8 @@ service SandboxWorker {
rpc WakeSandbox(WakeSandboxRequest) returns (WakeSandboxResponse);
rpc BuildTemplate(BuildTemplateRequest) returns (BuildTemplateResponse);
+
+ rpc GetSandboxStats(GetSandboxStatsRequest) returns (GetSandboxStatsResponse);
}
message CreateSandboxRequest {
@@ -183,3 +185,16 @@ message BuildTemplateResponse {
string image_ref = 1;
string build_log = 2;
}
+
+message GetSandboxStatsRequest {
+ string sandbox_id = 1;
+}
+
+message GetSandboxStatsResponse {
+ double cpu_percent = 1;
+ uint64 mem_usage = 2;
+ uint64 mem_limit = 3;
+ uint64 net_input = 4;
+ uint64 net_output = 5;
+ int32 pids = 6;
+}
diff --git a/proto/worker/worker_grpc.pb.go b/proto/worker/worker_grpc.pb.go
index fba53a87..e2277a05 100644
--- a/proto/worker/worker_grpc.pb.go
+++ b/proto/worker/worker_grpc.pb.go
@@ -33,6 +33,7 @@ const (
SandboxWorker_HibernateSandbox_FullMethodName = "/worker.SandboxWorker/HibernateSandbox"
SandboxWorker_WakeSandbox_FullMethodName = "/worker.SandboxWorker/WakeSandbox"
SandboxWorker_BuildTemplate_FullMethodName = "/worker.SandboxWorker/BuildTemplate"
+ SandboxWorker_GetSandboxStats_FullMethodName = "/worker.SandboxWorker/GetSandboxStats"
)
// SandboxWorkerClient is the client API for SandboxWorker service.
@@ -53,6 +54,7 @@ type SandboxWorkerClient interface {
HibernateSandbox(ctx context.Context, in *HibernateSandboxRequest, opts ...grpc.CallOption) (*HibernateSandboxResponse, error)
WakeSandbox(ctx context.Context, in *WakeSandboxRequest, opts ...grpc.CallOption) (*WakeSandboxResponse, error)
BuildTemplate(ctx context.Context, in *BuildTemplateRequest, opts ...grpc.CallOption) (*BuildTemplateResponse, error)
+ GetSandboxStats(ctx context.Context, in *GetSandboxStatsRequest, opts ...grpc.CallOption) (*GetSandboxStatsResponse, error)
}
type sandboxWorkerClient struct {
@@ -215,6 +217,16 @@ func (c *sandboxWorkerClient) BuildTemplate(ctx context.Context, in *BuildTempla
return out, nil
}
+func (c *sandboxWorkerClient) GetSandboxStats(ctx context.Context, in *GetSandboxStatsRequest, opts ...grpc.CallOption) (*GetSandboxStatsResponse, error) {
+ cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
+ out := new(GetSandboxStatsResponse)
+ err := c.cc.Invoke(ctx, SandboxWorker_GetSandboxStats_FullMethodName, in, out, cOpts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
// SandboxWorkerServer is the server API for SandboxWorker service.
// All implementations must embed UnimplementedSandboxWorkerServer
// for forward compatibility.
@@ -233,6 +245,7 @@ type SandboxWorkerServer interface {
HibernateSandbox(context.Context, *HibernateSandboxRequest) (*HibernateSandboxResponse, error)
WakeSandbox(context.Context, *WakeSandboxRequest) (*WakeSandboxResponse, error)
BuildTemplate(context.Context, *BuildTemplateRequest) (*BuildTemplateResponse, error)
+ GetSandboxStats(context.Context, *GetSandboxStatsRequest) (*GetSandboxStatsResponse, error)
mustEmbedUnimplementedSandboxWorkerServer()
}
@@ -285,6 +298,9 @@ func (UnimplementedSandboxWorkerServer) WakeSandbox(context.Context, *WakeSandbo
func (UnimplementedSandboxWorkerServer) BuildTemplate(context.Context, *BuildTemplateRequest) (*BuildTemplateResponse, error) {
return nil, status.Error(codes.Unimplemented, "method BuildTemplate not implemented")
}
+func (UnimplementedSandboxWorkerServer) GetSandboxStats(context.Context, *GetSandboxStatsRequest) (*GetSandboxStatsResponse, error) {
+ return nil, status.Error(codes.Unimplemented, "method GetSandboxStats not implemented")
+}
func (UnimplementedSandboxWorkerServer) mustEmbedUnimplementedSandboxWorkerServer() {}
func (UnimplementedSandboxWorkerServer) testEmbeddedByValue() {}
@@ -540,6 +556,24 @@ func _SandboxWorker_BuildTemplate_Handler(srv interface{}, ctx context.Context,
return interceptor(ctx, in, info, handler)
}
+func _SandboxWorker_GetSandboxStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(GetSandboxStatsRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(SandboxWorkerServer).GetSandboxStats(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: SandboxWorker_GetSandboxStats_FullMethodName,
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(SandboxWorkerServer).GetSandboxStats(ctx, req.(*GetSandboxStatsRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
// SandboxWorker_ServiceDesc is the grpc.ServiceDesc for SandboxWorker service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@@ -595,6 +629,10 @@ var SandboxWorker_ServiceDesc = grpc.ServiceDesc{
MethodName: "BuildTemplate",
Handler: _SandboxWorker_BuildTemplate_Handler,
},
+ {
+ MethodName: "GetSandboxStats",
+ Handler: _SandboxWorker_GetSandboxStats_Handler,
+ },
},
Streams: []grpc.StreamDesc{
{
diff --git a/web/package-lock.json b/web/package-lock.json
index 7ba0205a..1b3b2744 100644
--- a/web/package-lock.json
+++ b/web/package-lock.json
@@ -9,6 +9,9 @@
"version": "0.1.0",
"dependencies": {
"@tanstack/react-query": "^5.60.0",
+ "@xterm/addon-fit": "^0.11.0",
+ "@xterm/addon-web-links": "^0.12.0",
+ "@xterm/xterm": "^6.0.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.28.0",
@@ -53,7 +56,6 @@
"integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"@babel/code-frame": "^7.29.0",
"@babel/generator": "^7.29.0",
@@ -1365,7 +1367,6 @@
"integrity": "sha512-z9VXpC7MWrhfWipitjNdgCauoMLRdIILQsAEV+ZesIzBq/oUlxk0m3ApZuMFCXdnS4U7KrI+l3WRUEGQ8K1QKw==",
"devOptional": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"@types/prop-types": "*",
"csstype": "^3.2.2"
@@ -1408,6 +1409,27 @@
"vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
}
},
+ "node_modules/@xterm/addon-fit": {
+ "version": "0.11.0",
+ "resolved": "https://registry.npmjs.org/@xterm/addon-fit/-/addon-fit-0.11.0.tgz",
+ "integrity": "sha512-jYcgT6xtVYhnhgxh3QgYDnnNMYTcf8ElbxxFzX0IZo+vabQqSPAjC3c1wJrKB5E19VwQei89QCiZZP86DCPF7g==",
+ "license": "MIT"
+ },
+ "node_modules/@xterm/addon-web-links": {
+ "version": "0.12.0",
+ "resolved": "https://registry.npmjs.org/@xterm/addon-web-links/-/addon-web-links-0.12.0.tgz",
+ "integrity": "sha512-4Smom3RPyVp7ZMYOYDoC/9eGJJJqYhnPLGGqJ6wOBfB8VxPViJNSKdgRYb8NpaM6YSelEKbA2SStD7lGyqaobw==",
+ "license": "MIT"
+ },
+ "node_modules/@xterm/xterm": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/@xterm/xterm/-/xterm-6.0.0.tgz",
+ "integrity": "sha512-TQwDdQGtwwDt+2cgKDLn0IRaSxYu1tSUjgKarSDkUM0ZNiSRXFpjxEsvc/Zgc5kq5omJ+V0a8/kIM2WD3sMOYg==",
+ "license": "MIT",
+ "workspaces": [
+ "addons/*"
+ ]
+ },
"node_modules/baseline-browser-mapping": {
"version": "2.9.19",
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.19.tgz",
@@ -1438,7 +1460,6 @@
}
],
"license": "MIT",
- "peer": true,
"dependencies": {
"baseline-browser-mapping": "^2.9.0",
"caniuse-lite": "^1.0.30001759",
@@ -1879,7 +1900,6 @@
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
"dev": true,
"license": "MIT",
- "peer": true,
"engines": {
"node": ">=12"
},
@@ -1921,7 +1941,6 @@
"resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz",
"integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==",
"license": "MIT",
- "peer": true,
"dependencies": {
"loose-envify": "^1.1.0"
},
@@ -1934,7 +1953,6 @@
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz",
"integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==",
"license": "MIT",
- "peer": true,
"dependencies": {
"loose-envify": "^1.1.0",
"scheduler": "^0.23.2"
@@ -1955,7 +1973,6 @@
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.2.0.tgz",
"integrity": "sha512-ROY9fvHhwOD9ySfrF0wmvu//bKCQ6AeZZq1nJNtbDC+kk5DuSuNX/n6YWYF/SYy7bSba4D4FSz8DJeKY/S/r+g==",
"license": "MIT",
- "peer": true,
"dependencies": {
"@types/use-sync-external-store": "^0.0.6",
"use-sync-external-store": "^1.4.0"
@@ -2050,8 +2067,7 @@
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz",
"integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==",
- "license": "MIT",
- "peer": true
+ "license": "MIT"
},
"node_modules/redux-thunk": {
"version": "3.1.0",
@@ -2247,7 +2263,6 @@
"integrity": "sha512-+Oxm7q9hDoLMyJOYfUYBuHQo+dkAloi33apOPP56pzj+vsdJDzr+j1NISE5pyaAuKL4A3UD34qd0lx5+kfKp2g==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"esbuild": "^0.25.0",
"fdir": "^6.4.4",
diff --git a/web/package.json b/web/package.json
index 9226c901..3c43984b 100644
--- a/web/package.json
+++ b/web/package.json
@@ -10,6 +10,9 @@
},
"dependencies": {
"@tanstack/react-query": "^5.60.0",
+ "@xterm/addon-fit": "^0.11.0",
+ "@xterm/addon-web-links": "^0.12.0",
+ "@xterm/xterm": "^6.0.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.28.0",
diff --git a/web/src/App.tsx b/web/src/App.tsx
index 17c9f015..cb765349 100644
--- a/web/src/App.tsx
+++ b/web/src/App.tsx
@@ -8,6 +8,7 @@ import Sessions from './pages/Sessions'
import APIKeys from './pages/APIKeys'
import Templates from './pages/Templates'
import Settings from './pages/Settings'
+import SessionDetail from './pages/SessionDetail'
export default function App() {
return (
@@ -18,6 +19,7 @@ export default function App() {
<Route element={<Layout />}>
<Route index element={<Dashboard />} />
<Route path="sessions" element={<Sessions />} />
+ <Route path="sessions/:sandboxId" element={<SessionDetail />} />
<Route path="templates" element={<Templates />} />
<Route path="api-keys" element={<APIKeys />} />
<Route path="settings" element={<Settings />} />
diff --git a/web/src/api/client.ts b/web/src/api/client.ts
index f2fc446e..d518b7f1 100644
--- a/web/src/api/client.ts
+++ b/web/src/api/client.ts
@@ -63,6 +63,12 @@ export const buildTemplate = (name: string, dockerfile: string) =>
export const deleteTemplate = (id: string) =>
apiFetch<void>(`/templates/${id}`, { method: 'DELETE' })
+export const getSessionDetail = (sandboxId: string) =>
+ apiFetch<SessionDetail>(`/sessions/${sandboxId}`)
+
+export const getSessionStats = (sandboxId: string) =>
+ apiFetch<SandboxStats>(`/sessions/${sandboxId}/stats`)
+
export const getOrg = () => apiFetch<Org>('/org')
export const updateOrg = (name: string) =>
@@ -98,12 +104,43 @@ export interface Template {
orgId?: string
name: string
tag: string
- imageRef: string
dockerfile?: string
isPublic: boolean
createdAt: string
}
+export interface SessionDetail {
+ id: string
+ sandboxId: string
+ template: string
+ status: string
+ startedAt: string
+ stoppedAt?: string
+ errorMsg?: string
+ domain?: string
+ config?: {
+ timeout?: number
+ cpuCount?: number
+ memoryMB?: number
+ networkEnabled?: boolean
+ envs?: Record<string, string>
+ }
+ checkpoint?: {
+ checkpointKey: string
+ sizeBytes: number
+ hibernatedAt: string
+ }
+}
+
+export interface SandboxStats {
+ cpuPercent: number
+ memUsage: number
+ memLimit: number
+ netInput: number
+ netOutput: number
+ pids: number
+}
+
export interface Org {
id: string
name: string
diff --git a/web/src/components/Terminal.tsx b/web/src/components/Terminal.tsx
new file mode 100644
index 00000000..a532bb1a
--- /dev/null
+++ b/web/src/components/Terminal.tsx
@@ -0,0 +1,229 @@
+import { useEffect, useRef, useState } from 'react'
+import { Terminal as XTerm } from '@xterm/xterm'
+import { FitAddon } from '@xterm/addon-fit'
+import { WebLinksAddon } from '@xterm/addon-web-links'
+import '@xterm/xterm/css/xterm.css'
+
+interface TerminalProps {
+ sandboxId: string
+ onClose?: () => void
+}
+
+export default function Terminal({ sandboxId, onClose }: TerminalProps) {
+ const termRef = useRef<HTMLDivElement>(null)
+ const xtermRef = useRef<XTerm | null>(null)
+ const wsRef = useRef<WebSocket | null>(null)
+ const fitRef = useRef<FitAddon | null>(null)
+ const ptySessionIdRef = useRef<string | null>(null)
+ const [status, setStatus] = useState<'connecting' | 'connected' | 'disconnected' | 'error'>('connecting')
+ const [errorMsg, setErrorMsg] = useState('')
+
+ useEffect(() => {
+ if (!termRef.current) return
+
+ const term = new XTerm({
+ cursorBlink: true,
+ fontSize: 13,
+ fontFamily: 'JetBrains Mono, Menlo, Monaco, Consolas, monospace',
+ theme: {
+ background: '#0a0a0f',
+ foreground: '#e4e4e7',
+ cursor: '#818cf8',
+ selectionBackground: 'rgba(129, 140, 248, 0.3)',
+ black: '#18181b',
+ red: '#fb7185',
+ green: '#34d399',
+ yellow: '#fbbf24',
+ blue: '#818cf8',
+ magenta: '#c084fc',
+ cyan: '#22d3ee',
+ white: '#e4e4e7',
+ brightBlack: '#52525b',
+ brightRed: '#fda4af',
+ brightGreen: '#6ee7b7',
+ brightYellow: '#fde68a',
+ brightBlue: '#a5b4fc',
+ brightMagenta: '#d8b4fe',
+ brightCyan: '#67e8f9',
+ brightWhite: '#fafafa',
+ },
+ allowProposedApi: true,
+ })
+
+ const fit = new FitAddon()
+ const webLinks = new WebLinksAddon()
+
+ term.loadAddon(fit)
+ term.loadAddon(webLinks)
+ term.open(termRef.current)
+
+ // Fit after a small delay to let the container render
+ requestAnimationFrame(() => {
+ fit.fit()
+ })
+
+ xtermRef.current = term
+ fitRef.current = fit
+
+ term.writeln('\x1b[2m Connecting to sandbox...\x1b[0m')
+
+ // Create PTY session, then connect WebSocket
+ const initTerminal = async () => {
+ try {
+ const cols = term.cols
+ const rows = term.rows
+
+ // Create PTY session
+ const res = await fetch(`/api/dashboard/sessions/${sandboxId}/pty`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ credentials: 'include',
+ body: JSON.stringify({ cols, rows }),
+ })
+
+ if (!res.ok) {
+ const data = await res.json()
+ throw new Error(data.error || `HTTP ${res.status}`)
+ }
+
+ const { sessionId } = await res.json()
+ ptySessionIdRef.current = sessionId
+
+ // Connect WebSocket
+ const proto = window.location.protocol === 'https:' ? 'wss:' : 'ws:'
+ const wsUrl = `${proto}//${window.location.host}/api/dashboard/sessions/${sandboxId}/pty/${sessionId}`
+ const ws = new WebSocket(wsUrl)
+ ws.binaryType = 'arraybuffer'
+ wsRef.current = ws
+
+ ws.onopen = () => {
+ setStatus('connected')
+ term.clear()
+ term.focus()
+ }
+
+ ws.onmessage = (event) => {
+ const data = new Uint8Array(event.data)
+ term.write(data)
+ }
+
+ ws.onclose = () => {
+ setStatus('disconnected')
+ term.writeln('')
+ term.writeln('\x1b[2m Session ended.\x1b[0m')
+ }
+
+ ws.onerror = () => {
+ setStatus('error')
+ setErrorMsg('WebSocket connection failed')
+ }
+
+ // Terminal input -> WebSocket
+ term.onData((data) => {
+ if (ws.readyState === WebSocket.OPEN) {
+ ws.send(new TextEncoder().encode(data))
+ }
+ })
+
+ // Handle resize — send to backend resize endpoint (not via PTY stream)
+ term.onResize(({ cols, rows }) => {
+ if (ptySessionIdRef.current) {
+ fetch(`/api/dashboard/sessions/${sandboxId}/pty/${ptySessionIdRef.current}/resize`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ credentials: 'include',
+ body: JSON.stringify({ cols, rows }),
+ }).catch(() => {
+ // Resize failed — not critical, ignore
+ })
+ }
+ })
+ } catch (err: unknown) {
+ setStatus('error')
+ const msg = err instanceof Error ? err.message : 'Failed to connect'
+ setErrorMsg(msg)
+ term.writeln(`\x1b[31m Error: ${msg}\x1b[0m`)
+ }
+ }
+
+ initTerminal()
+
+ // Handle window resize
+ const handleResize = () => {
+ if (fitRef.current) {
+ fitRef.current.fit()
+ }
+ }
+ window.addEventListener('resize', handleResize)
+
+ return () => {
+ window.removeEventListener('resize', handleResize)
+ if (wsRef.current) {
+ wsRef.current.close()
+ }
+ term.dispose()
+ }
+ }, [sandboxId])
+
+ return (
+ <div>
+ {/* Header */}
+ <div style={{
+ display: 'flex', justifyContent: 'space-between', alignItems: 'center',
+ marginBottom: 12,
+ }}>
+ <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round" style={{ color: 'var(--text-tertiary)' }}>
+ <polyline points="4 17 10 11 4 5" />
+ <line x1="12" y1="19" x2="20" y2="19" />
+ </svg>
+ <span style={{ fontSize: 11, fontWeight: 600, color: 'var(--text-tertiary)', textTransform: 'uppercase', letterSpacing: '0.05em' }}>
+ Terminal
+ </span>
+ <span style={{
+ fontSize: 10, padding: '2px 6px', borderRadius: 4,
+ background: status === 'connected' ? 'rgba(52,211,153,0.15)' :
+ status === 'connecting' ? 'rgba(129,140,248,0.15)' :
+ status === 'error' ? 'rgba(251,113,133,0.15)' :
+ 'rgba(255,255,255,0.05)',
+ color: status === 'connected' ? 'var(--accent-emerald)' :
+ status === 'connecting' ? '#818cf8' :
+ status === 'error' ? '#fb7185' :
+ 'var(--text-tertiary)',
+ }}>
+ {status}
+ </span>
+ </div>
+ {onClose && (
+ <button
+ onClick={onClose}
+ style={{
+ background: 'none', border: 'none', cursor: 'pointer',
+ color: 'var(--text-tertiary)', fontSize: 11, padding: '4px 8px',
+ }}
+ >
+ Close
+ </button>
+ )}
+ </div>
+
+ {/* Terminal container */}
+ <div
+ ref={termRef}
+ style={{
+ height: 350,
+ borderRadius: 8,
+ overflow: 'hidden',
+ background: '#0a0a0f',
+ padding: '8px 4px',
+ }}
+ />
+
+ {status === 'error' && errorMsg && (
+ <div style={{ fontSize: 11, color: '#fb7185', marginTop: 8 }}>
+ {errorMsg}
+ </div>
+ )}
+ </div>
+ )
+}
diff --git a/web/src/pages/Dashboard.tsx b/web/src/pages/Dashboard.tsx
index 1cc27543..53d70be2 100644
--- a/web/src/pages/Dashboard.tsx
+++ b/web/src/pages/Dashboard.tsx
@@ -1,4 +1,5 @@
import { useQuery } from '@tanstack/react-query'
+import { useNavigate } from 'react-router-dom'
import { getSessions, type Session } from '../api/client'
export default function Dashboard() {
@@ -104,8 +105,8 @@ export default function Dashboard() {
</thead>
<tbody>
{all.slice(0, 20).map(s => (
- <tr key={s.id}>
- <td><code>{s.sandboxId}</code></td>
+ <ClickableRow key={s.id} sandboxId={s.sandboxId}>
+ <td><code style={{ color: 'var(--text-accent)' }}>{s.sandboxId}</code></td>
<td>{s.template || 'base'}</td>
<td><StatusBadge status={s.status} /></td>
<td style={{ fontFamily: 'var(--font-mono)', fontSize: 12 }}>
@@ -114,7 +115,7 @@ export default function Dashboard() {
<td style={{ fontFamily: 'var(--font-mono)', fontSize: 12 }}>
{formatDuration(s)}
</td>
- </tr>
+ </ClickableRow>
))}
</tbody>
</table>
@@ -147,23 +148,26 @@ function StatCard({ label, value, accent }: {
/* ── Sandbox Row ──────────────────────────────────────────── */
function SandboxRow({ session }: { session: Session }) {
+ const navigate = useNavigate()
const elapsed = Math.round((Date.now() - new Date(session.startedAt).getTime()) / 1000 / 60)
return (
- <div style={{
- display: 'flex', alignItems: 'center', justifyContent: 'space-between',
- padding: '9px 12px', borderRadius: 8,
- background: 'rgba(255,255,255,0.015)',
- border: '1px solid rgba(255,255,255,0.035)',
- transition: 'all 0.15s ease', cursor: 'default',
- }}
- onMouseOver={e => {
- e.currentTarget.style.background = 'rgba(99,102,241,0.05)'
- e.currentTarget.style.borderColor = 'rgba(99,102,241,0.12)'
- }}
- onMouseOut={e => {
- e.currentTarget.style.background = 'rgba(255,255,255,0.015)'
- e.currentTarget.style.borderColor = 'rgba(255,255,255,0.035)'
- }}>
+ <div
+ onClick={() => navigate(`/sessions/${session.sandboxId}`)}
+ style={{
+ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
+ padding: '9px 12px', borderRadius: 8,
+ background: 'rgba(255,255,255,0.015)',
+ border: '1px solid rgba(255,255,255,0.035)',
+ transition: 'all 0.15s ease', cursor: 'pointer',
+ }}
+ onMouseOver={e => {
+ e.currentTarget.style.background = 'rgba(99,102,241,0.05)'
+ e.currentTarget.style.borderColor = 'rgba(99,102,241,0.12)'
+ }}
+ onMouseOut={e => {
+ e.currentTarget.style.background = 'rgba(255,255,255,0.015)'
+ e.currentTarget.style.borderColor = 'rgba(255,255,255,0.035)'
+ }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
<span className="pulse-dot" style={{
width: 6, height: 6, borderRadius: '50%',
@@ -185,6 +189,21 @@ function SandboxRow({ session }: { session: Session }) {
)
}
+/* ── Clickable Table Row ──────────────────────────────────── */
+function ClickableRow({ sandboxId, children }: { sandboxId: string; children: React.ReactNode }) {
+ const navigate = useNavigate()
+ return (
+ <tr
+ onClick={() => navigate(`/sessions/${sandboxId}`)}
+ style={{ cursor: 'pointer' }}
+ onMouseOver={e => { e.currentTarget.style.background = 'rgba(99,102,241,0.04)' }}
+ onMouseOut={e => { e.currentTarget.style.background = '' }}
+ >
+ {children}
+ </tr>
+ )
+}
+
/* ── Status Badge ─────────────────────────────────────────── */
function StatusBadge({ status }: { status: string }) {
const cls =
diff --git a/web/src/pages/SessionDetail.tsx b/web/src/pages/SessionDetail.tsx
new file mode 100644
index 00000000..122ee9fb
--- /dev/null
+++ b/web/src/pages/SessionDetail.tsx
@@ -0,0 +1,273 @@
+import { useState } from 'react'
+import { useParams, useNavigate } from 'react-router-dom'
+import { useQuery } from '@tanstack/react-query'
+import { getSessionDetail, getSessionStats } from '../api/client'
+import Terminal from '../components/Terminal'
+
+function StatusBadge({ status }: { status: string }) {
+ const cls =
+ status === 'running' ? 'badge-running' :
+ status === 'stopped' ? 'badge-stopped' :
+ status === 'hibernated' ? 'badge-hibernated' :
+ status === 'error' ? 'badge-error' : ''
+
+ return <span className={`status-badge ${cls}`}>{status}</span>
+}
+
+function formatBytes(bytes: number): string {
+ if (bytes === 0) return '0 B'
+ const units = ['B', 'KB', 'MB', 'GB']
+ const i = Math.floor(Math.log(bytes) / Math.log(1024))
+ return `${(bytes / Math.pow(1024, i)).toFixed(i > 0 ? 1 : 0)} ${units[i]}`
+}
+
+function timeAgo(dateStr: string): string {
+ const diff = Date.now() - new Date(dateStr).getTime()
+ const mins = Math.floor(diff / 60000)
+ if (mins < 1) return 'just now'
+ if (mins < 60) return `${mins}m ago`
+ const hrs = Math.floor(mins / 60)
+ if (hrs < 24) return `${hrs}h ${mins % 60}m ago`
+ const days = Math.floor(hrs / 24)
+ return `${days}d ago`
+}
+
+function StatCard({ label, value, sub }: { label: string; value: string; sub?: string }) {
+ return (
+ <div style={{
+ background: 'rgba(255,255,255,0.02)',
+ border: '1px solid var(--border-subtle)',
+ borderRadius: 'var(--radius-md)',
+ padding: '16px 20px',
+ flex: 1,
+ }}>
+ <div style={{ fontSize: 11, fontWeight: 600, color: 'var(--text-tertiary)', textTransform: 'uppercase', letterSpacing: '0.05em', marginBottom: 6 }}>
+ {label}
+ </div>
+ <div style={{ fontSize: 22, fontWeight: 700, color: 'var(--text-primary)' }}>
+ {value}
+ </div>
+ {sub && (
+ <div style={{ fontSize: 11, color: 'var(--text-tertiary)', marginTop: 2 }}>
+ {sub}
+ </div>
+ )}
+ </div>
+ )
+}
+
+export default function SessionDetail() {
+ const { sandboxId } = useParams<{ sandboxId: string }>()
+ const navigate = useNavigate()
+ const [copied, setCopied] = useState(false)
+ const [showTerminal, setShowTerminal] = useState(false)
+
+ const { data: session, isLoading } = useQuery({
+ queryKey: ['session-detail', sandboxId],
+ queryFn: () => getSessionDetail(sandboxId!),
+ enabled: !!sandboxId,
+ })
+
+ const { data: stats } = useQuery({
+ queryKey: ['session-stats', sandboxId],
+ queryFn: () => getSessionStats(sandboxId!),
+ enabled: !!sandboxId && session?.status === 'running',
+ refetchInterval: 5000,
+ retry: false,
+ })
+
+ const copyUrl = () => {
+ if (session?.domain) {
+ navigator.clipboard.writeText(`https://${session.domain}`)
+ setCopied(true)
+ setTimeout(() => setCopied(false), 2000)
+ }
+ }
+
+ if (isLoading) {
+ return (
+ <div style={{ display: 'flex', justifyContent: 'center', padding: 80 }}>
+ <div className="loading-spinner" />
+ </div>
+ )
+ }
+
+ if (!session) {
+ return (
+ <div style={{ padding: 40, textAlign: 'center', color: 'var(--text-tertiary)' }}>
+ Session not found
+ </div>
+ )
+ }
+
+ return (
+ <div>
+ {/* Back link */}
+ <button
+ onClick={() => navigate('/sessions')}
+ style={{
+ background: 'none', border: 'none', cursor: 'pointer',
+ color: 'var(--text-tertiary)', fontSize: 13, padding: 0,
+ marginBottom: 20, display: 'flex', alignItems: 'center', gap: 6,
+ }}
+ >
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
+ <path d="M19 12H5" /><polyline points="12 19 5 12 12 5" />
+ </svg>
+ Back to Sessions
+ </button>
+
+ {/* Header */}
+ <div className="glass-card animate-in" style={{ padding: 24, marginBottom: 16 }}>
+ <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start' }}>
+ <div>
+ <div style={{ display: 'flex', alignItems: 'center', gap: 12, marginBottom: 8 }}>
+ <code style={{ fontSize: 20, fontWeight: 700, fontFamily: 'var(--font-mono)', color: 'var(--text-primary)' }}>
+ {session.sandboxId}
+ </code>
+ <StatusBadge status={session.status} />
+ </div>
+ <div style={{ fontSize: 13, color: 'var(--text-tertiary)' }}>
+ {session.template || 'base'} &middot; Started {timeAgo(session.startedAt)}
+ </div>
+ </div>
+
+ {/* Actions */}
+ <div style={{ display: 'flex', gap: 8 }}>
+ {session.status === 'running' && (
+ <button
+ className={showTerminal ? 'btn-primary' : 'btn-ghost'}
+ onClick={() => setShowTerminal(!showTerminal)}
+ >
+ <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round">
+ <polyline points="4 17 10 11 4 5" />
+ <line x1="12" y1="19" x2="20" y2="19" />
+ </svg>
+ Terminal
+ </button>
+ )}
+ </div>
+ </div>
+ </div>
+
+ {/* Terminal */}
+ {showTerminal && session.status === 'running' && (
+ <div className="glass-card animate-in" style={{ padding: 20, marginBottom: 16 }}>
+ <Terminal sandboxId={sandboxId!} onClose={() => setShowTerminal(false)} />
+ </div>
+ )}
+
+ {/* Stats cards — only for running sandboxes */}
+ {session.status === 'running' && (
+ <div className="glass-card animate-in stagger-1" style={{ padding: 20, marginBottom: 16 }}>
+ <div style={{ fontSize: 11, fontWeight: 600, color: 'var(--text-tertiary)', textTransform: 'uppercase', letterSpacing: '0.05em', marginBottom: 14 }}>
+ Resource Usage
+ </div>
+ <div style={{ display: 'flex', gap: 12 }}>
+ <StatCard
+ label="CPU"
+ value={stats ? `${stats.cpuPercent.toFixed(1)}%` : '—'}
+ />
+ <StatCard
+ label="Memory"
+ value={stats ? formatBytes(stats.memUsage) : '—'}
+ sub={stats ? `of ${formatBytes(stats.memLimit)}` : undefined}
+ />
+ <StatCard
+ label="Processes"
+ value={stats ? String(stats.pids) : '—'}
+ />
+ <StatCard
+ label="Network"
+ value={stats ? `↑${formatBytes(stats.netOutput)}` : '—'}
+ sub={stats ? `↓${formatBytes(stats.netInput)}` : undefined}
+ />
+ </div>
+ </div>
+ )}
+
+ {/* Live URL */}
+ {session.domain && (session.status === 'running' || session.status === 'hibernated') && (
+ <div className="glass-card animate-in stagger-2" style={{ padding: 20, marginBottom: 16 }}>
+ <div style={{ fontSize: 11, fontWeight: 600, color: 'var(--text-tertiary)', textTransform: 'uppercase', letterSpacing: '0.05em', marginBottom: 10 }}>
+ Live URL
+ </div>
+ <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
+ <div style={{
+ flex: 1,
+ background: 'var(--bg-deep)',
+ border: '1px solid var(--border-subtle)',
+ borderRadius: 'var(--radius-sm)',
+ padding: '10px 14px',
+ fontFamily: 'var(--font-mono)',
+ fontSize: 13,
+ color: 'var(--text-accent)',
+ }}>
+ <a
+ href={`https://${session.domain}`}
+ target="_blank"
+ rel="noopener noreferrer"
+ style={{ color: 'var(--text-accent)', textDecoration: 'none' }}
+ >
+ https://{session.domain}
+ </a>
+ </div>
+ <button className="btn-ghost" onClick={copyUrl} style={{ whiteSpace: 'nowrap' }}>
+ {copied ? '✓ Copied' : 'Copy'}
+ </button>
+ </div>
+ </div>
+ )}
+
+ {/* Details */}
+ <div className="glass-card animate-in stagger-3" style={{ padding: 20, marginBottom: 16 }}>
+ <div style={{ fontSize: 11, fontWeight: 600, color: 'var(--text-tertiary)', textTransform: 'uppercase', letterSpacing: '0.05em', marginBottom: 14 }}>
+ Details
+ </div>
+ <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '12px 32px' }}>
+ <DetailRow label="Template" value={session.template || 'base'} />
+ <DetailRow label="Timeout" value={session.config?.timeout ? `${session.config.timeout}s` : '300s'} />
+ <DetailRow label="CPUs" value={String(session.config?.cpuCount ?? 1)} />
+ <DetailRow label="Memory" value={`${session.config?.memoryMB ?? 512} MB`} />
+ <DetailRow label="Network" value={session.config?.networkEnabled ? 'Enabled' : 'Disabled'} />
+ <DetailRow label="Started" value={new Date(session.startedAt).toLocaleString()} />
+ {session.stoppedAt && (
+ <DetailRow label="Stopped" value={new Date(session.stoppedAt).toLocaleString()} />
+ )}
+ {session.errorMsg && (
+ <DetailRow label="Error" value={session.errorMsg} isError />
+ )}
+ </div>
+ </div>
+
+ {/* Checkpoint info for hibernated */}
+ {session.checkpoint && (
+ <div className="glass-card animate-in stagger-4" style={{ padding: 20 }}>
+ <div style={{ fontSize: 11, fontWeight: 600, color: 'var(--text-tertiary)', textTransform: 'uppercase', letterSpacing: '0.05em', marginBottom: 14 }}>
+ Checkpoint
+ </div>
+ <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '12px 32px' }}>
+ <DetailRow label="Size" value={formatBytes(session.checkpoint.sizeBytes)} />
+ <DetailRow label="Hibernated" value={new Date(session.checkpoint.hibernatedAt).toLocaleString()} />
+ </div>
+ </div>
+ )}
+ </div>
+ )
+}
+
+function DetailRow({ label, value, isError }: { label: string; value: string; isError?: boolean }) {
+ return (
+ <div>
+ <div style={{ fontSize: 11, color: 'var(--text-tertiary)', marginBottom: 2 }}>{label}</div>
+ <div style={{
+ fontSize: 13,
+ fontFamily: 'var(--font-mono)',
+ color: isError ? 'var(--accent-rose)' : 'var(--text-primary)',
+ wordBreak: 'break-all',
+ }}>
+ {value}
+ </div>
+ </div>
+ )
+}
diff --git a/web/src/pages/Sessions.tsx b/web/src/pages/Sessions.tsx
index 64b53008..72ac931d 100644
--- a/web/src/pages/Sessions.tsx
+++ b/web/src/pages/Sessions.tsx
@@ -1,5 +1,6 @@
import { useState, useMemo } from 'react'
import { useQuery } from '@tanstack/react-query'
+import { useNavigate } from 'react-router-dom'
import { getSessions, type Session } from '../api/client'
const statusFilters = ['', 'running', 'stopped', 'hibernated', 'error'] as const
@@ -56,13 +57,13 @@ export default function Sessions() {
</thead>
<tbody>
{(sessions ?? []).map((s: Session) => (
- <tr key={s.id}>
- <td><code>{s.sandboxId}</code></td>
+ <ClickableRow key={s.id} sandboxId={s.sandboxId}>
+ <td><code style={{ color: 'var(--text-accent)' }}>{s.sandboxId}</code></td>
<td>{s.template || 'base'}</td>
<td><StatusBadge status={s.status} /></td>
<td style={{ fontFamily: 'var(--font-mono)', fontSize: 12 }}>{new Date(s.startedAt).toLocaleString()}</td>
<td style={{ fontFamily: 'var(--font-mono)', fontSize: 12 }}>{s.stoppedAt ? new Date(s.stoppedAt).toLocaleString() : '\u2014'}</td>
- </tr>
+ </ClickableRow>
))}
{(sessions ?? []).length === 0 && (
<tr>
@@ -223,6 +224,20 @@ function LegendItem({ color, label }: { color: string; label: string }) {
)
}
+function ClickableRow({ sandboxId, children }: { sandboxId: string; children: React.ReactNode }) {
+ const navigate = useNavigate()
+ return (
+ <tr
+ onClick={() => navigate(`/sessions/${sandboxId}`)}
+ style={{ cursor: 'pointer' }}
+ onMouseOver={e => { e.currentTarget.style.background = 'rgba(99,102,241,0.04)' }}
+ onMouseOut={e => { e.currentTarget.style.background = '' }}
+ >
+ {children}
+ </tr>
+ )
+}
+
function StatusBadge({ status }: { status: string }) {
const cls =
status === 'running' ? 'badge-running'
diff --git a/web/src/pages/Templates.tsx b/web/src/pages/Templates.tsx
index ad2d7a3a..314ffaee 100644
--- a/web/src/pages/Templates.tsx
+++ b/web/src/pages/Templates.tsx
@@ -127,7 +127,6 @@ export default function Templates() {
<th>Name</th>
<th>Tag</th>
<th>Type</th>
- <th>Image</th>
<th>Created</th>
<th style={{ width: 80 }}></th>
</tr>
@@ -154,9 +153,6 @@ export default function Templates() {
{t.isPublic ? 'Built-in' : 'Custom'}
</span>
</td>
- <td style={{ fontFamily: 'var(--font-mono)', fontSize: 12, maxWidth: 300, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
- {t.imageRef}
- </td>
<td style={{ fontFamily: 'var(--font-mono)', fontSize: 12 }}>
{new Date(t.createdAt).toLocaleString()}
</td>
@@ -178,7 +174,7 @@ export default function Templates() {
))}
{(templates ?? []).length === 0 && (
<tr>
- <td colSpan={6} style={{ textAlign: 'center', padding: 32, color: 'var(--text-tertiary)' }}>
+ <td colSpan={5} style={{ textAlign: 'center', padding: 32, color: 'var(--text-tertiary)' }}>
No templates yet
</td>
</tr>
diff --git a/web/tsconfig.tsbuildinfo b/web/tsconfig.tsbuildinfo
index b328fe66..dd132900 100644
--- a/web/tsconfig.tsbuildinfo
+++ b/web/tsconfig.tsbuildinfo
@@ -1 +1 @@
-{"root":["./src/app.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/api/client.ts","./src/components/layout.tsx","./src/components/protectedroute.tsx","./src/hooks/useauth.tsx","./src/pages/apikeys.tsx","./src/pages/dashboard.tsx","./src/pages/login.tsx","./src/pages/sessions.tsx","./src/pages/settings.tsx","./src/pages/templates.tsx"],"version":"5.6.3"}
\ No newline at end of file
+{"root":["./src/app.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/api/client.ts","./src/components/layout.tsx","./src/components/protectedroute.tsx","./src/components/terminal.tsx","./src/hooks/useauth.tsx","./src/pages/apikeys.tsx","./src/pages/dashboard.tsx","./src/pages/login.tsx","./src/pages/sessiondetail.tsx","./src/pages/sessions.tsx","./src/pages/settings.tsx","./src/pages/templates.tsx"],"version":"5.6.3"}
\ No newline at end of file
diff --git a/web/vite.config.ts b/web/vite.config.ts
index d4850990..52d9b760 100644
--- a/web/vite.config.ts
+++ b/web/vite.config.ts
@@ -8,7 +8,10 @@ export default defineConfig({
port: 3000,
proxy: {
'/auth': 'http://localhost:8080',
- '/api': 'http://localhost:8080',
+ '/api': {
+ target: 'http://localhost:8080',
+ ws: true,
+ },
},
},
})