mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-16 21:03:46 +00:00
factory: rename project and handoff actors
This commit is contained in:
parent
3022bce2ad
commit
ea7c36a8e7
147 changed files with 6313 additions and 14364 deletions
|
|
@ -1,18 +1,18 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import type { BackendClient } from "../src/backend-client.js";
|
||||
import { createHandoffWorkbenchClient } from "../src/workbench-client.js";
|
||||
import { createTaskWorkbenchClient } from "../src/workbench-client.js";
|
||||
|
||||
async function sleep(ms: number): Promise<void> {
|
||||
await new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
describe("createHandoffWorkbenchClient", () => {
|
||||
describe("createTaskWorkbenchClient", () => {
|
||||
it("scopes mock clients by workspace", async () => {
|
||||
const alpha = createHandoffWorkbenchClient({
|
||||
const alpha = createTaskWorkbenchClient({
|
||||
mode: "mock",
|
||||
workspaceId: "mock-alpha",
|
||||
});
|
||||
const beta = createHandoffWorkbenchClient({
|
||||
const beta = createTaskWorkbenchClient({
|
||||
mode: "mock",
|
||||
workspaceId: "mock-beta",
|
||||
});
|
||||
|
|
@ -22,24 +22,24 @@ describe("createHandoffWorkbenchClient", () => {
|
|||
expect(alphaInitial.workspaceId).toBe("mock-alpha");
|
||||
expect(betaInitial.workspaceId).toBe("mock-beta");
|
||||
|
||||
await alpha.createHandoff({
|
||||
await alpha.createTask({
|
||||
repoId: alphaInitial.repos[0]!.id,
|
||||
task: "Ship alpha-only change",
|
||||
title: "Alpha only",
|
||||
});
|
||||
|
||||
expect(alpha.getSnapshot().handoffs).toHaveLength(alphaInitial.handoffs.length + 1);
|
||||
expect(beta.getSnapshot().handoffs).toHaveLength(betaInitial.handoffs.length);
|
||||
expect(alpha.getSnapshot().tasks).toHaveLength(alphaInitial.tasks.length + 1);
|
||||
expect(beta.getSnapshot().tasks).toHaveLength(betaInitial.tasks.length);
|
||||
});
|
||||
|
||||
it("uses the initial task to bootstrap a new mock handoff session", async () => {
|
||||
const client = createHandoffWorkbenchClient({
|
||||
it("uses the initial task to bootstrap a new mock task session", async () => {
|
||||
const client = createTaskWorkbenchClient({
|
||||
mode: "mock",
|
||||
workspaceId: "mock-onboarding",
|
||||
});
|
||||
const snapshot = client.getSnapshot();
|
||||
|
||||
const created = await client.createHandoff({
|
||||
const created = await client.createTask({
|
||||
repoId: snapshot.repos[0]!.id,
|
||||
task: "Reply with exactly: MOCK_WORKBENCH_READY",
|
||||
title: "Mock onboarding",
|
||||
|
|
@ -47,22 +47,22 @@ describe("createHandoffWorkbenchClient", () => {
|
|||
model: "gpt-4o",
|
||||
});
|
||||
|
||||
const runningHandoff = client.getSnapshot().handoffs.find((handoff) => handoff.id === created.handoffId);
|
||||
expect(runningHandoff).toEqual(
|
||||
const runningTask = client.getSnapshot().tasks.find((task) => task.id === created.taskId);
|
||||
expect(runningTask).toEqual(
|
||||
expect.objectContaining({
|
||||
title: "Mock onboarding",
|
||||
branch: "feat/mock-onboarding",
|
||||
status: "running",
|
||||
}),
|
||||
);
|
||||
expect(runningHandoff?.tabs[0]).toEqual(
|
||||
expect(runningTask?.tabs[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
id: created.tabId,
|
||||
created: true,
|
||||
status: "running",
|
||||
}),
|
||||
);
|
||||
expect(runningHandoff?.tabs[0]?.transcript).toEqual([
|
||||
expect(runningTask?.tabs[0]?.transcript).toEqual([
|
||||
expect.objectContaining({
|
||||
sender: "client",
|
||||
payload: expect.objectContaining({
|
||||
|
|
@ -73,26 +73,26 @@ describe("createHandoffWorkbenchClient", () => {
|
|||
|
||||
await sleep(2_700);
|
||||
|
||||
const completedHandoff = client.getSnapshot().handoffs.find((handoff) => handoff.id === created.handoffId);
|
||||
expect(completedHandoff?.status).toBe("idle");
|
||||
expect(completedHandoff?.tabs[0]).toEqual(
|
||||
const completedTask = client.getSnapshot().tasks.find((task) => task.id === created.taskId);
|
||||
expect(completedTask?.status).toBe("idle");
|
||||
expect(completedTask?.tabs[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
status: "idle",
|
||||
unread: true,
|
||||
}),
|
||||
);
|
||||
expect(completedHandoff?.tabs[0]?.transcript).toEqual([
|
||||
expect(completedTask?.tabs[0]?.transcript).toEqual([
|
||||
expect.objectContaining({ sender: "client" }),
|
||||
expect.objectContaining({ sender: "agent" }),
|
||||
]);
|
||||
});
|
||||
|
||||
it("routes remote push actions through the backend boundary", async () => {
|
||||
const actions: Array<{ workspaceId: string; handoffId: string; action: string }> = [];
|
||||
const actions: Array<{ workspaceId: string; taskId: string; action: string }> = [];
|
||||
let snapshotReads = 0;
|
||||
const backend = {
|
||||
async runAction(workspaceId: string, handoffId: string, action: string): Promise<void> {
|
||||
actions.push({ workspaceId, handoffId, action });
|
||||
async runAction(workspaceId: string, taskId: string, action: string): Promise<void> {
|
||||
actions.push({ workspaceId, taskId, action });
|
||||
},
|
||||
async getWorkbench(workspaceId: string) {
|
||||
snapshotReads += 1;
|
||||
|
|
@ -100,7 +100,7 @@ describe("createHandoffWorkbenchClient", () => {
|
|||
workspaceId,
|
||||
repos: [],
|
||||
projects: [],
|
||||
handoffs: [],
|
||||
tasks: [],
|
||||
};
|
||||
},
|
||||
subscribeWorkbench(): () => void {
|
||||
|
|
@ -108,18 +108,18 @@ describe("createHandoffWorkbenchClient", () => {
|
|||
},
|
||||
} as unknown as BackendClient;
|
||||
|
||||
const client = createHandoffWorkbenchClient({
|
||||
const client = createTaskWorkbenchClient({
|
||||
mode: "remote",
|
||||
backend,
|
||||
workspaceId: "remote-ws",
|
||||
});
|
||||
|
||||
await client.pushHandoff({ handoffId: "handoff-123" });
|
||||
await client.pushTask({ taskId: "task-123" });
|
||||
|
||||
expect(actions).toEqual([
|
||||
{
|
||||
workspaceId: "remote-ws",
|
||||
handoffId: "handoff-123",
|
||||
taskId: "task-123",
|
||||
action: "push",
|
||||
},
|
||||
]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue