feat: switch to managed Paseo Sprite agents, remote hosts, and Fly token exchange

This commit is contained in:
nandi committed 2026-11-19 01:47:07 +00:00
1 parent 9188bfc277
commit 32c02cb3cd
14 files changed
+1860 -446

No files matched your search

+430 -220
View File
@@ -1,51 +1,66 @@
import {
type PluginHostProps,
type PluginSurfaceProps,
openExternalUrl,
usePaseo,
useRpc,
useSubscription,
} from "@getpaseo/plugin/client";
import type { PaseoAgent, PaseoWorkspace } from "@getpaseo/client";
import { ScrollView, TextInput, copyText, useToast } from "@getpaseo/plugin/client/ui";
import { useCallback, useEffect, useMemo, useState } from "react";
import { Pressable, Text, View } from "react-native";
import {
type CheckpointSummary,
type SpriteAgentSummary,
type SpriteHostSummary,
type SpriteSummary,
type TokenSource,
type WorkerSummary,
createCheckpointRpc,
createSpriteRpc,
destroySpriteRpc,
ensureSpriteHostRpc,
launchSpriteAgentRpc,
listCheckpointsRpc,
restoreCheckpointRpc,
spawnWorkerRpc,
spriteAgentActionRpc,
statusRpc,
stopWorkerRpc,
syncWorkspaceRpc,
watchWorkersSub,
workerLogsRpc,
} from "../shared/contracts";
import { useOpenBaoAuth } from "./use-openbao-auth";
interface WorkersScreenProps extends PluginHostProps {
interface WorkersScreenProps extends PluginSurfaceProps {
workspaceName?: string;
workspaceDirectory?: string;
}
const PROVIDER_CHOICES = [
{ id: "auto", label: "Auto" },
{ id: "claude", label: "Claude" },
{ id: "codex", label: "Codex" },
{ id: "opencode", label: "OpenCode" },
{ id: "pi", label: "Pi" },
] as const;
function getWorkspacePath(ws: PaseoWorkspace): string {
return ws.workspaceDirectory || ws.projectRootPath;
}
export function FlySpritesWorkersScreen({
theme,
layout,
host,
navigation,
workspaceName,
workspaceDirectory,
}: WorkersScreenProps) {
const paseo = usePaseo();
const toast = useToast();
const fetchStatus = useRpc(statusRpc);
const createSprite = useRpc(createSpriteRpc);
const ensureSpriteHost = useRpc(ensureSpriteHostRpc);
const launchSpriteAgent = useRpc(launchSpriteAgentRpc);
const spriteAgentAction = useRpc(spriteAgentActionRpc);
const syncWorkspace = useRpc(syncWorkspaceRpc);
const spawnWorker = useRpc(spawnWorkerRpc);
const stopWorker = useRpc(stopWorkerRpc);
const fetchLogs = useRpc(workerLogsRpc);
const destroySprite = useRpc(destroySpriteRpc);
const listCheckpoints = useRpc(listCheckpointsRpc);
const createCheckpoint = useRpc(createCheckpointRpc);
@@ -55,47 +70,74 @@ export function FlySpritesWorkersScreen({
const [tokenSource, setTokenSource] = useState<TokenSource>("none");
const [remoteError, setRemoteError] = useState<string | null>(null);
const [sprites, setSprites] = useState<SpriteSummary[]>([]);
const [workers, setWorkers] = useState<WorkerSummary[]>([]);
const [spriteHosts, setSpriteHosts] = useState<SpriteHostSummary[]>([]);
const [spriteAgents, setSpriteAgents] = useState<SpriteAgentSummary[]>([]);
const [legacyAgents, setLegacyAgents] = useState<PaseoAgent[]>([]);
const [workspaces, setWorkspaces] = useState<PaseoWorkspace[]>([]);
const [loading, setLoading] = useState(true);
const [busy, setBusy] = useState(false);
const [agentBusyId, setAgentBusyId] = useState<string | null>(null);
const [spriteNameInput, setSpriteNameInput] = useState("");
const [commandInput, setCommandInput] = useState("");
const [syncPathInput, setSyncPathInput] = useState(workspaceDirectory ?? "");
const [syncBeforeSpawn, setSyncBeforeSpawn] = useState(Boolean(workspaceDirectory));
const [agentTitleInput, setAgentTitleInput] = useState("");
const [promptInput, setPromptInput] = useState("");
const [cwdInput, setCwdInput] = useState(workspaceDirectory ?? "");
const [providerInput, setProviderInput] = useState<string>("auto");
const [syncBeforeOpen, setSyncBeforeOpen] = useState(true);
const [selectedWorkerId, setSelectedWorkerId] = useState<string | null>(null);
const [fullLogs, setFullLogs] = useState<string>("");
const [checkpointsSprite, setCheckpointsSprite] = useState<string | null>(null);
const [checkpoints, setCheckpoints] = useState<CheckpointSummary[]>([]);
useEffect(() => {
if (workspaceDirectory && !syncPathInput) {
setSyncPathInput(workspaceDirectory);
setSyncBeforeSpawn(true);
if (workspaceDirectory && !cwdInput) {
setCwdInput(workspaceDirectory);
setSyncBeforeOpen(true);
}
}, [workspaceDirectory, syncPathInput]);
}, [workspaceDirectory, cwdInput]);
const watchInput = useMemo(() => ({}), []);
useSubscription(watchWorkersSub, watchInput, (event) => {
setWorkers(event.workers);
});
const refreshClusterState = useCallback(async () => {
const [agentsRes, workspacesRes] = await Promise.all([
paseo.agents.list().catch(() => null),
paseo.workspaces.list().catch(() => null),
]);
if (agentsRes) {
const flyAgents = agentsRes.entries
.map((entry) => entry.agent)
.filter((agent) => agent.provider === "fly-sprites" && !agent.archivedAt)
.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
setLegacyAgents(flyAgents);
}
if (workspacesRes) {
const activeWorkspaces = workspacesRes.entries.filter(
(ws) => !ws.archivingAt && !ws.background && Boolean(getWorkspacePath(ws)),
);
setWorkspaces(activeWorkspaces);
setCwdInput((cur) => {
if (cur || workspaceDirectory || activeWorkspaces.length === 0) return cur;
return getWorkspacePath(activeWorkspaces[0]);
});
}
}, [paseo, workspaceDirectory]);
const refresh = useCallback(async () => {
setLoading(true);
try {
const res = await fetchStatus({ includeRemote: true });
setConfigured(res.configured);
setTokenSource(res.tokenSource);
setRemoteError(res.remoteError);
setSprites(res.sprites);
setWorkers(res.workers);
const [statusRes] = await Promise.all([
fetchStatus({ includeRemote: true }),
refreshClusterState(),
]);
setConfigured(statusRes.configured);
setTokenSource(statusRes.tokenSource);
setRemoteError(statusRes.remoteError);
setSprites(statusRes.sprites);
setSpriteHosts(statusRes.spriteHosts);
setSpriteAgents(statusRes.spriteAgents);
} catch (error) {
toast.error(error instanceof Error ? error.message : String(error));
} finally {
setLoading(false);
}
}, [fetchStatus, toast]);
}, [fetchStatus, refreshClusterState, toast]);
useEffect(() => {
void refresh();
@@ -105,32 +147,20 @@ export function FlySpritesWorkersScreen({
const pendingFlow =
openbao.status?.pendingAuth?.status === "pending" ? openbao.status.pendingAuth : null;
const selectedWorker = useMemo(
() => workers.find((w) => w.workerId === selectedWorkerId) ?? null,
[workers, selectedWorkerId],
);
useEffect(() => {
if (!selectedWorkerId) return;
let cancelled = false;
const load = async () => {
const res = await fetchLogs({ workerId: selectedWorkerId }).catch(() => null);
if (!cancelled && res?.ok) {
setFullLogs(res.output);
}
};
void load();
return () => {
cancelled = true;
};
}, [selectedWorkerId, workers, fetchLogs]);
const hostBySprite = useMemo(() => {
const map = new Map<string, SpriteHostSummary>();
for (const h of spriteHosts) {
map.set(h.spriteName, h);
}
return map;
}, [spriteHosts]);
const handleCreateSprite = async () => {
setBusy(true);
try {
const res = await createSprite({
name: spriteNameInput.trim() || undefined,
syncLocalPath: syncBeforeSpawn && syncPathInput.trim() ? syncPathInput.trim() : undefined,
syncLocalPath: syncBeforeOpen && cwdInput.trim() ? cwdInput.trim() : undefined,
});
if (!res.ok) {
toast.error(res.error);
@@ -146,26 +176,19 @@ export function FlySpritesWorkersScreen({
}
};
const handleSpawnWorker = async () => {
const command = commandInput.trim();
if (!command) {
toast.error("Enter a worker command to run.");
return;
}
const handleConnectHost = async (name?: string) => {
setBusy(true);
try {
const res = await spawnWorker({
spriteName: spriteNameInput.trim() || undefined,
command,
syncLocalPath: syncBeforeSpawn && syncPathInput.trim() ? syncPathInput.trim() : undefined,
const res = await ensureSpriteHost({
spriteName: name?.trim() || undefined,
syncLocalPath: syncBeforeOpen && cwdInput.trim() ? cwdInput.trim() : undefined,
});
if (!res.ok) {
toast.error(res.error);
return;
}
toast.show(`Spawned ${res.worker.workerId} on ${res.worker.spriteName}`, { variant: "success" });
setSelectedWorkerId(res.worker.workerId);
setCommandInput("");
toast.show(`Sprite host ${res.spriteName} connected`, { variant: "success" });
setSpriteNameInput(res.spriteName);
await refresh();
} catch (error) {
toast.error(error instanceof Error ? error.message : String(error));
@@ -174,10 +197,81 @@ export function FlySpritesWorkersScreen({
}
};
const handleLaunchAgent = async () => {
const targetSprite = spriteNameInput.trim();
const initialPrompt = promptInput.trim();
const title = agentTitleInput.trim();
setBusy(true);
try {
const res = await launchSpriteAgent({
spriteName: targetSprite || undefined,
title: title || undefined,
prompt: initialPrompt || undefined,
syncLocalPath: syncBeforeOpen && cwdInput.trim() ? cwdInput.trim() : undefined,
provider: providerInput || "auto",
});
if (!res.ok) {
toast.error(res.error);
await refresh();
return;
}
toast.show(`Launched on ${res.spriteName} (${res.provider})`, { variant: "success" });
setSpriteNameInput(res.spriteName);
setPromptInput("");
setAgentTitleInput("");
await refresh();
navigation?.openAgent({ agentId: res.agentId, serverId: res.serverId });
} catch (error) {
toast.error(error instanceof Error ? error.message : String(error));
} finally {
setBusy(false);
}
};
const handleSpriteAgentAction = async (
agent: SpriteAgentSummary,
action: "interrupt" | "archive",
) => {
setAgentBusyId(agent.agentId);
try {
const res = await spriteAgentAction({
serverId: agent.serverId,
agentId: agent.agentId,
action,
});
if (!res.ok) {
toast.error(res.error ?? `Failed to ${action} agent`);
return;
}
toast.show(action === "interrupt" ? "Interrupted agent turn" : "Archived agent", {
variant: "info",
});
await refresh();
} catch (error) {
toast.error(error instanceof Error ? error.message : String(error));
} finally {
setAgentBusyId(null);
}
};
const handleArchiveLegacyAgent = async (agentId: string) => {
setAgentBusyId(agentId);
try {
await paseo.agents.ref(agentId).archive();
toast.show("Archived legacy cluster agent", { variant: "info" });
setLegacyAgents((prev) => prev.filter((a) => a.id !== agentId));
} catch (error) {
toast.error(error instanceof Error ? error.message : String(error));
} finally {
setAgentBusyId(null);
}
};
const handleSyncSprite = async (name: string) => {
const localPath = syncPathInput.trim();
const localPath = cwdInput.trim();
if (!localPath) {
toast.error("Enter a local workspace path to sync.");
toast.error("Select a workspace or enter a local folder path to sync.");
return;
}
setBusy(true);
@@ -323,6 +417,24 @@ export function FlySpritesWorkersScreen({
paddingVertical: 6,
},
btnDangerText: { color: theme.colors.statusDanger, fontSize: 12, fontWeight: "500" as const },
chip: {
borderWidth: 1,
borderColor: theme.colors.border,
backgroundColor: theme.colors.surface0,
borderRadius: 999,
paddingHorizontal: 10,
paddingVertical: 4,
},
chipActive: {
borderWidth: 1,
borderColor: theme.colors.accent,
backgroundColor: theme.colors.surface2,
borderRadius: 999,
paddingHorizontal: 10,
paddingVertical: 4,
},
chipText: { color: theme.colors.foregroundMuted, fontSize: 12 },
chipActiveText: { color: theme.colors.foreground, fontSize: 12, fontWeight: "600" as const },
monoBox: {
backgroundColor: theme.colors.surface0,
borderWidth: 1,
@@ -330,19 +442,16 @@ export function FlySpritesWorkersScreen({
borderRadius: 8,
padding: 10,
},
monoText: {
color: theme.colors.foreground,
fontSize: 12,
fontFamily: "monospace",
},
}),
[theme, layout.compact],
);
const statusColor = (status: WorkerSummary["status"]) => {
if (status === "completed") return theme.colors.statusSuccess;
if (status === "failed") return theme.colors.statusDanger;
if (status === "running" || status === "starting") return theme.colors.accent;
const statusColor = (status: string) => {
if (status === "running" || status === "initializing" || status === "connecting") {
return theme.colors.accent;
}
if (status === "error" || status === "offline") return theme.colors.statusDanger;
if (status === "idle" || status === "online") return theme.colors.statusSuccess;
return theme.colors.foregroundMuted;
};
@@ -350,7 +459,7 @@ export function FlySpritesWorkersScreen({
<ScrollView style={styles.screen} contentContainerStyle={styles.body}>
<View style={styles.headerRow}>
<View>
<Text style={styles.title}>Fly Sprites Workers</Text>
<Text style={styles.title}>Fly Sprites Agents</Text>
<Text style={styles.muted}>
Host: {host.label} · Token: {tokenSource}
{workspaceName ? ` · Workspace: ${workspaceName}` : ""}
@@ -429,37 +538,83 @@ export function FlySpritesWorkersScreen({
) : null}
<View style={styles.card}>
<Text style={styles.sectionTitle}>Spawn Worker / Create Sprite</Text>
<Text style={styles.sectionTitle}>Launch Agent on Sprite Host</Text>
<Text style={styles.muted}>
Provisions Paseo inside the Sprite and connects it as its own host so workspaces and agents appear under the Sprite host.
</Text>
<TextInput
style={styles.input}
value={spriteNameInput}
onChangeText={setSpriteNameInput}
placeholder="Sprite name (blank creates a new paseo-worker-* sprite)"
placeholder="Target Sprite name (blank creates a new Sprite host)"
placeholderTextColor={theme.colors.foregroundMuted}
/>
<TextInput
style={styles.input}
value={commandInput}
onChangeText={setCommandInput}
placeholder="Command to run (e.g. npm test, or claude -p '...')"
value={agentTitleInput}
onChangeText={setAgentTitleInput}
placeholder="Agent title (optional)"
placeholderTextColor={theme.colors.foregroundMuted}
/>
<TextInput
style={styles.input}
value={syncPathInput}
onChangeText={setSyncPathInput}
placeholder="Optional local folder to sync to /workspace"
value={promptInput}
onChangeText={setPromptInput}
placeholder="Initial prompt / task (optional; leave blank for interactive chat)"
placeholderTextColor={theme.colors.foregroundMuted}
multiline
/>
{workspaces.length > 0 && !workspaceDirectory ? (
<View style={styles.row}>
{workspaces.map((ws) => {
const wsPath = getWorkspacePath(ws);
const active = cwdInput === wsPath;
return (
<Pressable
key={ws.id}
style={active ? styles.chipActive : styles.chip}
onPress={() => setCwdInput(wsPath)}
>
<Text style={active ? styles.chipActiveText : styles.chipText}>
{ws.title || ws.name || wsPath}
</Text>
</Pressable>
);
})}
</View>
) : null}
<TextInput
style={styles.input}
value={cwdInput}
onChangeText={setCwdInput}
placeholder="Optional local workspace directory to sync to /workspace"
placeholderTextColor={theme.colors.foregroundMuted}
/>
<View style={styles.row}>
{PROVIDER_CHOICES.map((choice) => {
const active = providerInput === choice.id;
return (
<Pressable
key={choice.id}
style={active ? styles.chipActive : styles.chip}
onPress={() => setProviderInput(choice.id)}
>
<Text style={active ? styles.chipActiveText : styles.chipText}>
{choice.label}
</Text>
</Pressable>
);
})}
<Pressable
style={styles.btnSecondary}
onPress={() => setSyncBeforeSpawn((v) => !v)}
onPress={() => setSyncBeforeOpen((v) => !v)}
>
<Text style={styles.btnSecondaryText}>
{syncBeforeSpawn ? "Sync workspace: ON" : "Sync workspace: OFF"}
{syncBeforeOpen ? "Sync workspace: ON" : "Sync workspace: OFF"}
</Text>
</Pressable>
</View>
<View style={styles.row}>
<Pressable
style={styles.btnSecondary}
onPress={() => void handleCreateSprite()}
@@ -468,161 +623,216 @@ export function FlySpritesWorkersScreen({
<Text style={styles.btnSecondaryText}>Create Sprite</Text>
</Pressable>
<Pressable
style={styles.btnPrimary}
onPress={() => void handleSpawnWorker()}
style={styles.btnSecondary}
onPress={() => void handleConnectHost(spriteNameInput)}
disabled={busy || !configured}
>
<Text style={styles.btnPrimaryText}>Spawn Worker</Text>
<Text style={styles.btnSecondaryText}>Connect Host</Text>
</Pressable>
<Pressable
style={styles.btnPrimary}
onPress={() => void handleLaunchAgent()}
disabled={busy || !configured}
>
<Text style={styles.btnPrimaryText}>
{busy ? "Working…" : "Launch Agent"}
</Text>
</Pressable>
</View>
</View>
<Text style={styles.sectionTitle}>Tracked Workers ({workers.length})</Text>
{workers.length === 0 ? (
<Text style={styles.sectionTitle}>Sprite Host Agents ({spriteAgents.length})</Text>
{spriteAgents.length === 0 ? (
<View style={styles.card}>
<Text style={styles.muted}>No workers spawned on this daemon yet.</Text>
<Text style={styles.muted}>
No agents on connected Sprite hosts yet. Launch one above to create it under its Sprite host.
</Text>
</View>
) : (
workers.map((worker) => (
<View key={worker.workerId} style={styles.card}>
<View style={styles.headerRow}>
<Text style={{ color: theme.colors.foreground, fontWeight: "600", fontSize: 13 }}>
{worker.workerId} · {worker.spriteName}
</Text>
<Text style={{ color: statusColor(worker.status), fontSize: 12, fontWeight: "600" }}>
{worker.status}
{worker.exitCode !== null ? ` (${worker.exitCode})` : ""}
</Text>
</View>
<Text style={styles.muted} numberOfLines={2}>
$ {worker.command}
</Text>
<Text style={styles.muted}>
cwd: {worker.cwd} · started: {worker.startedAt}
</Text>
{worker.error ? <Text style={styles.error}>{worker.error}</Text> : null}
<View style={styles.row}>
<Pressable
style={styles.btnSecondary}
onPress={() =>
setSelectedWorkerId((cur) => (cur === worker.workerId ? null : worker.workerId))
}
>
<Text style={styles.btnSecondaryText}>
{selectedWorkerId === worker.workerId ? "Hide Logs" : "View Logs"}
spriteAgents.map((agent) => {
const isBusy = agentBusyId === agent.agentId;
return (
<View key={`${agent.serverId}:${agent.agentId}`} style={styles.card}>
<View style={styles.headerRow}>
<Text style={{ color: theme.colors.foreground, fontWeight: "600", fontSize: 13, flex: 1 }}>
{agent.title || `Agent ${agent.agentId.slice(0, 8)}`}
</Text>
</Pressable>
{worker.status === "running" || worker.status === "starting" ? (
<Pressable
style={styles.btnDanger}
onPress={() => void stopWorker({ workerId: worker.workerId })}
>
<Text style={styles.btnDangerText}>Stop</Text>
</Pressable>
) : null}
</View>
{selectedWorker?.workerId === worker.workerId ? (
<View style={styles.monoBox}>
<View style={[styles.headerRow, { marginBottom: 6 }]}>
<Text style={styles.muted}>Output ({worker.outputBytes} bytes)</Text>
<Pressable
onPress={() => {
void copyText(fullLogs || worker.outputTail);
toast.show("Copied worker output", { variant: "info" });
}}
>
<Text style={{ color: theme.colors.accent, fontSize: 12 }}>Copy</Text>
</Pressable>
</View>
<Text style={styles.monoText}>
{fullLogs || worker.outputTail || "(no output yet)"}
<Text style={{ color: statusColor(agent.status), fontSize: 12, fontWeight: "600" }}>
{agent.status}
{agent.pendingPermissionsCount > 0 ? " · permission" : ""}
</Text>
</View>
) : null}
</View>
))
<Text style={styles.muted}>
Host: {agent.hostLabel} · {agent.provider}
{agent.model ? `/${agent.model}` : ""} · {agent.cwd}
</Text>
{agent.lastError ? <Text style={styles.error}>{agent.lastError}</Text> : null}
<View style={styles.row}>
{navigation ? (
<Pressable
style={styles.btnPrimary}
onPress={() =>
navigation.openAgent({ agentId: agent.agentId, serverId: agent.serverId })
}
>
<Text style={styles.btnPrimaryText}>Open</Text>
</Pressable>
) : null}
{agent.status === "running" ? (
<Pressable
style={styles.btnSecondary}
onPress={() => void handleSpriteAgentAction(agent, "interrupt")}
disabled={isBusy}
>
<Text style={styles.btnSecondaryText}>Interrupt</Text>
</Pressable>
) : null}
<Pressable
style={styles.btnDanger}
onPress={() => void handleSpriteAgentAction(agent, "archive")}
disabled={isBusy}
>
<Text style={styles.btnDangerText}>Archive</Text>
</Pressable>
</View>
</View>
);
})
)}
{legacyAgents.length > 0 ? (
<>
<Text style={styles.sectionTitle}>Cluster-Hosted Fly Agents ({legacyAgents.length})</Text>
{legacyAgents.map((agent) => (
<View key={agent.id} style={styles.card}>
<View style={styles.headerRow}>
<Text style={{ color: theme.colors.foreground, fontWeight: "600", fontSize: 13, flex: 1 }}>
{agent.title || `Agent ${agent.id.slice(0, 8)}`}
</Text>
<Text style={{ color: statusColor(agent.status), fontSize: 12, fontWeight: "600" }}>
{agent.status}
</Text>
</View>
<Text style={styles.muted}>
Cluster host ({host.label}) · {agent.cwd}
</Text>
<View style={styles.row}>
{navigation ? (
<Pressable
style={styles.btnSecondary}
onPress={() => navigation.openAgent({ agentId: agent.id, serverId: host.id })}
>
<Text style={styles.btnSecondaryText}>Open</Text>
</Pressable>
) : null}
<Pressable
style={styles.btnDanger}
onPress={() => void handleArchiveLegacyAgent(agent.id)}
disabled={agentBusyId === agent.id}
>
<Text style={styles.btnDangerText}>Archive</Text>
</Pressable>
</View>
</View>
))}
</>
) : null}
<Text style={styles.sectionTitle}>Remote Fly Sprites ({sprites.length})</Text>
{sprites.length === 0 ? (
<View style={styles.card}>
<Text style={styles.muted}>No Fly Sprites found.</Text>
</View>
) : (
sprites.map((sprite) => (
<View key={sprite.name} style={styles.card}>
<View style={styles.headerRow}>
<Text style={{ color: theme.colors.foreground, fontWeight: "600", fontSize: 13 }}>
{sprite.name}
</Text>
<Text style={styles.muted}>
{sprite.status}
{sprite.primaryRegion ? ` · ${sprite.primaryRegion}` : ""}
</Text>
</View>
{sprite.url ? <Text style={styles.muted}>{sprite.url}</Text> : null}
<View style={styles.row}>
<Pressable
style={styles.btnSecondary}
onPress={() => setSpriteNameInput(sprite.name)}
>
<Text style={styles.btnSecondaryText}>Select</Text>
</Pressable>
<Pressable
style={styles.btnSecondary}
onPress={() => void handleSyncSprite(sprite.name)}
disabled={busy}
>
<Text style={styles.btnSecondaryText}>Sync Here</Text>
</Pressable>
<Pressable
style={styles.btnSecondary}
onPress={() => void handleCheckpoint(sprite.name)}
disabled={busy}
>
<Text style={styles.btnSecondaryText}>Checkpoint</Text>
</Pressable>
<Pressable
style={styles.btnSecondary}
onPress={() => void handleLoadCheckpoints(sprite.name)}
>
<Text style={styles.btnSecondaryText}>Checkpoints</Text>
</Pressable>
<Pressable
style={styles.btnDanger}
onPress={() => void handleDestroySprite(sprite.name)}
disabled={busy}
>
<Text style={styles.btnDangerText}>Delete</Text>
</Pressable>
</View>
{checkpointsSprite === sprite.name ? (
<View style={styles.monoBox}>
<Text style={[styles.muted, { marginBottom: 4 }]}>
Checkpoints for {sprite.name} ({checkpoints.length})
sprites.map((sprite) => {
const connectedHost = hostBySprite.get(sprite.name);
return (
<View key={sprite.name} style={styles.card}>
<View style={styles.headerRow}>
<Text style={{ color: theme.colors.foreground, fontWeight: "600", fontSize: 13 }}>
{sprite.name}
</Text>
<Text style={styles.muted}>
VM: {sprite.status}
{connectedHost ? ` · Host: ${connectedHost.status}` : " · Host: not connected"}
</Text>
{checkpoints.length === 0 ? (
<Text style={styles.muted}>No checkpoints.</Text>
) : (
checkpoints.map((cp) => (
<View key={cp.id} style={[styles.headerRow, { paddingVertical: 4 }]}>
<Text style={styles.muted}>
{cp.id} {cp.comment ? `— ${cp.comment}` : ""}
</Text>
<Pressable
style={styles.btnSecondary}
onPress={() => void handleRestoreCheckpoint(sprite.name, cp.id)}
disabled={busy}
>
<Text style={styles.btnSecondaryText}>Restore</Text>
</Pressable>
</View>
))
)}
</View>
) : null}
</View>
))
{connectedHost?.error ? (
<Text style={styles.error}>Host error: {connectedHost.error}</Text>
) : null}
{sprite.url ? <Text style={styles.muted}>{sprite.url}</Text> : null}
<View style={styles.row}>
<Pressable
style={styles.btnSecondary}
onPress={() => setSpriteNameInput(sprite.name)}
>
<Text style={styles.btnSecondaryText}>Select</Text>
</Pressable>
{!connectedHost || connectedHost.status !== "online" ? (
<Pressable
style={styles.btnSecondary}
onPress={() => void handleConnectHost(sprite.name)}
disabled={busy}
>
<Text style={styles.btnSecondaryText}>Connect Host</Text>
</Pressable>
) : null}
<Pressable
style={styles.btnSecondary}
onPress={() => void handleSyncSprite(sprite.name)}
disabled={busy}
>
<Text style={styles.btnSecondaryText}>Sync Here</Text>
</Pressable>
<Pressable
style={styles.btnSecondary}
onPress={() => void handleCheckpoint(sprite.name)}
disabled={busy}
>
<Text style={styles.btnSecondaryText}>Checkpoint</Text>
</Pressable>
<Pressable
style={styles.btnSecondary}
onPress={() => void handleLoadCheckpoints(sprite.name)}
>
<Text style={styles.btnSecondaryText}>Checkpoints</Text>
</Pressable>
<Pressable
style={styles.btnDanger}
onPress={() => void handleDestroySprite(sprite.name)}
disabled={busy}
>
<Text style={styles.btnDangerText}>Delete</Text>
</Pressable>
</View>
{checkpointsSprite === sprite.name ? (
<View style={styles.monoBox}>
<Text style={[styles.muted, { marginBottom: 4 }]}>
Checkpoints for {sprite.name} ({checkpoints.length})
</Text>
{checkpoints.length === 0 ? (
<Text style={styles.muted}>No checkpoints.</Text>
) : (
checkpoints.map((cp) => (
<View key={cp.id} style={[styles.headerRow, { paddingVertical: 4 }]}>
<Text style={styles.muted}>
{cp.id} {cp.comment ? `— ${cp.comment}` : ""}
</Text>
<Pressable
style={styles.btnSecondary}
onPress={() => void handleRestoreCheckpoint(sprite.name, cp.id)}
disabled={busy}
>
<Text style={styles.btnSecondaryText}>Restore</Text>
</Pressable>
</View>
))
)}
</View>
) : null}
</View>
);
})
)}
</ScrollView>
);