mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-17 11:04:58 +00:00
feat(foundry): checkpoint actor and workspace refactor
This commit is contained in:
parent
32f3c6c3bc
commit
dbe57d45b9
81 changed files with 3441 additions and 2332 deletions
86
foundry/packages/backend/test/workspace-unread.test.ts
Normal file
86
foundry/packages/backend/test/workspace-unread.test.ts
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { requireSendableSessionMeta, shouldMarkSessionUnreadForStatus, shouldRecreateSessionForModelChange } from "../src/actors/task/workspace.js";
|
||||
|
||||
describe("workspace unread status transitions", () => {
|
||||
it("marks unread when a running session first becomes idle", () => {
|
||||
expect(shouldMarkSessionUnreadForStatus({ thinkingSinceMs: Date.now() - 1_000 }, "idle")).toBe(true);
|
||||
});
|
||||
|
||||
it("does not re-mark unread on repeated idle polls after thinking has cleared", () => {
|
||||
expect(shouldMarkSessionUnreadForStatus({ thinkingSinceMs: null }, "idle")).toBe(false);
|
||||
});
|
||||
|
||||
it("does not mark unread while the session is still running", () => {
|
||||
expect(shouldMarkSessionUnreadForStatus({ thinkingSinceMs: Date.now() - 1_000 }, "running")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("workspace model changes", () => {
|
||||
it("recreates an unused ready session so the selected model takes effect", () => {
|
||||
expect(
|
||||
shouldRecreateSessionForModelChange({
|
||||
status: "ready",
|
||||
sandboxSessionId: "session-1",
|
||||
created: false,
|
||||
transcript: [],
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("does not recreate a session once the conversation has started", () => {
|
||||
expect(
|
||||
shouldRecreateSessionForModelChange({
|
||||
status: "ready",
|
||||
sandboxSessionId: "session-1",
|
||||
created: true,
|
||||
transcript: [],
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("does not recreate pending or anonymous sessions", () => {
|
||||
expect(
|
||||
shouldRecreateSessionForModelChange({
|
||||
status: "pending_session_create",
|
||||
sandboxSessionId: "session-1",
|
||||
created: false,
|
||||
transcript: [],
|
||||
}),
|
||||
).toBe(false);
|
||||
expect(
|
||||
shouldRecreateSessionForModelChange({
|
||||
status: "ready",
|
||||
sandboxSessionId: null,
|
||||
created: false,
|
||||
transcript: [],
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("workspace send readiness", () => {
|
||||
it("rejects unknown sessions", () => {
|
||||
expect(() => requireSendableSessionMeta(null, "session-1")).toThrow("Unknown workspace session: session-1");
|
||||
});
|
||||
|
||||
it("rejects pending sessions", () => {
|
||||
expect(() =>
|
||||
requireSendableSessionMeta(
|
||||
{
|
||||
status: "pending_session_create",
|
||||
sandboxSessionId: null,
|
||||
},
|
||||
"session-2",
|
||||
),
|
||||
).toThrow("Session is not ready (status: pending_session_create). Wait for session provisioning to complete.");
|
||||
});
|
||||
|
||||
it("accepts ready sessions with a sandbox session id", () => {
|
||||
const meta = {
|
||||
status: "ready",
|
||||
sandboxSessionId: "session-1",
|
||||
};
|
||||
|
||||
expect(requireSendableSessionMeta(meta, "session-3")).toBe(meta);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue