import { DownloadConsentPrompt, useDownloadConsent } from "./consent"; import { useSettings, type PluginScreenProps } from "@getpaseo/plugin/client"; import { useState } from "react"; import { Text, View } from "react-native"; import type { AgentStatus, SandboxSummary, TemplateSummary } from "../shared/rpc"; import { sandboxSettings } from "../shared/settings"; import { agentState, agentTone, baseName, errorMessage, formatBytes, formatMiB, formatSize, homeOf, parseMemoryFlag, plural, repoPath, sandboxStatus, shortRef, tildify, } from "./format"; import { Column, Columns, Empty, Figures, Frame, Needs, StatusChip, Tabbed, type Need, type Tab } from "./frame"; import { Actions, Button, Code, ConfirmButton, Dot, FadeIn, Legend, ListRow, Meter, Note, Pill, Section, SegmentBar, Stat, figures, kicker, mono, text, tint, toneColor, type Theme, type Tone, } from "./kit"; import { McpServersTab } from "./mcp"; import { useArchiveAgent, useConfigureAgent, useDisk, useInvalidateAll, useMcpServers, useMemory, useRemoveTemplate, useSandboxAction, useSandboxes, useStatus, useTemplates, } from "./queries"; interface SandboxesScreenProps extends PluginScreenProps { openSettings(): void; } type ScreenTab = "overview" | "sandboxes" | "agents" | "templates" | "mcp"; type Status = NonNullable["data"]>; type Memory = NonNullable["data"]>; type Disk = NonNullable["data"]>; type SandboxDisk = Disk["sandboxes"][number]; type McpServers = NonNullable["data"]>; /** Ready to run sessions: provider registered and current, catalog sandbox created and answering. */ const agentReady = (agent: AgentStatus) => agent.provider.current && agent.catalog.exists && agent.catalog.cliVersion !== null; function agentView(agent: AgentStatus): { label: string; tone: Tone } { if (!agent.enabled) return { label: "Off", tone: "neutral" }; if (agentReady(agent)) return { label: "Ready", tone: "success" }; if (agent.provider.configured && !agent.provider.current) return { label: "Outdated", tone: "warning" }; return { label: "Needs setup", tone: "warning" }; } export function SandboxesScreen({ theme, layout, openSettings }: SandboxesScreenProps) { const status = useStatus(); const sandboxes = useSandboxes(); const memory = useMemory(); const disk = useDisk(); const templates = useTemplates(); const mcp = useMcpServers(); const settings = useSettings(sandboxSettings); const [tab, setTab] = useState("overview"); const [width, setWidth] = useState(null); const compact = layout.compact || (width !== null && width < 760); const fetching = status.isFetching || sandboxes.isFetching || memory.isFetching || disk.isFetching; const header = { status: , actions: ( <>