mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-16 12:03:27 +00:00
Add header status pill showing task/session/sandbox state
Surface aggregate status (error, provisioning, running, ready, no sandbox) as a colored pill in the transcript panel header. Integrates task runtime status, session status, and sandbox availability via the sandboxProcesses interest topic so the pill accurately reflects unreachable sandboxes. Includes mock tasks demonstrating error, provisioning, and running states, unit tests for deriveHeaderStatus, and workspace-dashboard integration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
098b8113f3
commit
5bd85e4a28
77 changed files with 2329 additions and 4134 deletions
|
|
@ -1,23 +1,10 @@
|
|||
import type {
|
||||
BackendDriver,
|
||||
DaytonaClientLike,
|
||||
DaytonaDriver,
|
||||
GitDriver,
|
||||
GithubDriver,
|
||||
StackDriver,
|
||||
SandboxAgentDriver,
|
||||
SandboxAgentClientLike,
|
||||
TmuxDriver,
|
||||
} from "../../src/driver.js";
|
||||
import type { ListEventsRequest, ListPage, ListPageRequest, ProcessInfo, ProcessLogsResponse, SessionEvent, SessionRecord } from "sandbox-agent";
|
||||
import type { BackendDriver, GitDriver, GithubDriver, StackDriver, TmuxDriver } from "../../src/driver.js";
|
||||
|
||||
export function createTestDriver(overrides?: Partial<BackendDriver>): BackendDriver {
|
||||
return {
|
||||
git: overrides?.git ?? createTestGitDriver(),
|
||||
stack: overrides?.stack ?? createTestStackDriver(),
|
||||
github: overrides?.github ?? createTestGithubDriver(),
|
||||
sandboxAgent: overrides?.sandboxAgent ?? createTestSandboxAgentDriver(),
|
||||
daytona: overrides?.daytona ?? createTestDaytonaDriver(),
|
||||
tmux: overrides?.tmux ?? createTestTmuxDriver(),
|
||||
};
|
||||
}
|
||||
|
|
@ -63,79 +50,6 @@ export function createTestGithubDriver(overrides?: Partial<GithubDriver>): Githu
|
|||
};
|
||||
}
|
||||
|
||||
export function createTestSandboxAgentDriver(overrides?: Partial<SandboxAgentDriver>): SandboxAgentDriver {
|
||||
return {
|
||||
createClient: (_opts) => createTestSandboxAgentClient(),
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
export function createTestSandboxAgentClient(overrides?: Partial<SandboxAgentClientLike>): SandboxAgentClientLike {
|
||||
const defaultProcess: ProcessInfo = {
|
||||
id: "process-1",
|
||||
command: "bash",
|
||||
args: ["-lc", "echo test"],
|
||||
createdAtMs: Date.now(),
|
||||
cwd: "/workspace",
|
||||
exitCode: null,
|
||||
exitedAtMs: null,
|
||||
interactive: true,
|
||||
pid: 123,
|
||||
status: "running",
|
||||
tty: true,
|
||||
};
|
||||
const defaultLogs: ProcessLogsResponse = {
|
||||
processId: defaultProcess.id,
|
||||
stream: "combined",
|
||||
entries: [],
|
||||
};
|
||||
return {
|
||||
createSession: async (_prompt) => ({ id: "test-session-1", status: "running" }),
|
||||
sessionStatus: async (sessionId) => ({ id: sessionId, status: "running" }),
|
||||
listSessions: async (_request?: ListPageRequest): Promise<ListPage<SessionRecord>> => ({
|
||||
items: [],
|
||||
nextCursor: undefined,
|
||||
}),
|
||||
listEvents: async (_request: ListEventsRequest): Promise<ListPage<SessionEvent>> => ({
|
||||
items: [],
|
||||
nextCursor: undefined,
|
||||
}),
|
||||
createProcess: async () => defaultProcess,
|
||||
listProcesses: async () => ({ processes: [defaultProcess] }),
|
||||
getProcessLogs: async () => defaultLogs,
|
||||
stopProcess: async () => ({ ...defaultProcess, status: "exited", exitCode: 0, exitedAtMs: Date.now() }),
|
||||
killProcess: async () => ({ ...defaultProcess, status: "exited", exitCode: 137, exitedAtMs: Date.now() }),
|
||||
deleteProcess: async () => {},
|
||||
sendPrompt: async (_request) => {},
|
||||
cancelSession: async (_sessionId) => {},
|
||||
destroySession: async (_sessionId) => {},
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
export function createTestDaytonaDriver(overrides?: Partial<DaytonaDriver>): DaytonaDriver {
|
||||
return {
|
||||
createClient: (_opts) => createTestDaytonaClient(),
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
export function createTestDaytonaClient(overrides?: Partial<DaytonaClientLike>): DaytonaClientLike {
|
||||
return {
|
||||
createSandbox: async () => ({ id: "sandbox-test-1", state: "started" }),
|
||||
getSandbox: async (sandboxId) => ({ id: sandboxId, state: "started" }),
|
||||
startSandbox: async () => {},
|
||||
stopSandbox: async () => {},
|
||||
deleteSandbox: async () => {},
|
||||
executeCommand: async () => ({ exitCode: 0, result: "" }),
|
||||
getPreviewEndpoint: async (sandboxId, port) => ({
|
||||
url: `https://preview.example/sandbox/${sandboxId}/port/${port}`,
|
||||
token: "preview-token",
|
||||
}),
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
export function createTestTmuxDriver(overrides?: Partial<TmuxDriver>): TmuxDriver {
|
||||
return {
|
||||
setWindowStatus: () => 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue