murashit_codex-panel/tests/app-server/thread-activation.test.ts

75 lines
2.1 KiB
TypeScript
Raw Normal View History

import { describe, expect, it } from "vitest";
import { threadActivationSnapshotFromAppServerResponse } from "../../src/app-server/services/threads";
2026-06-25 08:47:21 +00:00
import type { Thread as AppServerThread } from "../../src/generated/app-server/v2/Thread";
2026-06-24 05:44:16 +00:00
import type { ThreadResumeResponse } from "../../src/generated/app-server/v2/ThreadResumeResponse";
describe("app-server thread activation", () => {
it("maps app-server activation responses into panel-owned snapshots", () => {
const snapshot = threadActivationSnapshotFromAppServerResponse(responseFixture(threadFixture("thread", "Resumed")));
expect(snapshot).toMatchObject({
thread: {
id: "thread",
name: "Resumed",
archived: false,
},
model: "gpt-5.5",
serviceTier: "fast",
approvalsReviewer: "user",
reasoningEffort: "high",
approvalPolicy: "on-request",
sandboxPolicy: { type: "readOnly", networkAccess: false },
activePermissionProfile: null,
});
expect(snapshot).not.toHaveProperty("cwd");
});
});
2026-06-25 08:47:21 +00:00
function responseFixture(thread: AppServerThread): ThreadResumeResponse {
return {
thread,
model: "gpt-5.5",
modelProvider: "openai",
serviceTier: "fast",
2026-06-22 11:48:19 +00:00
approvalPolicy: "on-request",
cwd: "/vault",
runtimeWorkspaceRoots: [],
instructionSources: [],
approvalsReviewer: "user",
activePermissionProfile: null,
2026-06-22 11:48:19 +00:00
sandbox: { type: "readOnly", networkAccess: false },
reasoningEffort: "high",
multiAgentMode: "explicitRequestOnly",
initialTurnsPage: null,
};
}
2026-06-25 08:47:21 +00:00
function threadFixture(id: string, name: string): AppServerThread {
return {
id,
extra: null,
sessionId: "session",
forkedFromId: null,
parentThreadId: null,
preview: "",
ephemeral: false,
historyMode: "paginated",
modelProvider: "openai",
createdAt: 1,
updatedAt: 1,
recencyAt: null,
status: { type: "idle" },
path: null,
cwd: "/vault",
cliVersion: "0.0.0",
source: "unknown",
threadSource: null,
agentNickname: null,
agentRole: null,
gitInfo: null,
name,
turns: [],
};
}