Configure lefthook formatter checks (#231)

* Add lefthook formatter checks

* Fix SDK mode hydration

* Stabilize SDK mode integration test
This commit is contained in:
Nathan Flurry 2026-03-10 23:03:11 -07:00 committed by GitHub
parent 0471214d65
commit d2346bafb3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
282 changed files with 5840 additions and 8399 deletions

View file

@ -24,7 +24,7 @@ const base: HandoffRecord = {
cwd: null,
createdAt: 10,
updatedAt: 10,
}
},
],
agentType: null,
prSubmitted: false,

View file

@ -4,9 +4,7 @@ import { buildTranscript, extractEventText, resolveSessionSelection } from "./mo
describe("extractEventText", () => {
it("extracts prompt text arrays", () => {
expect(
extractEventText({ params: { prompt: [{ type: "text", text: "hello" }] } })
).toBe("hello");
expect(extractEventText({ params: { prompt: [{ type: "text", text: "hello" }] } })).toBe("hello");
});
it("falls back to method name", () => {
@ -17,9 +15,9 @@ describe("extractEventText", () => {
expect(
extractEventText({
result: {
text: "agent output"
}
})
text: "agent output",
},
}),
).toBe("agent output");
});
@ -31,11 +29,11 @@ describe("extractEventText", () => {
sessionUpdate: "agent_message_chunk",
content: {
type: "text",
text: "chunk"
}
}
}
})
text: "chunk",
},
},
},
}),
).toBe("chunk");
});
});
@ -50,7 +48,7 @@ describe("buildTranscript", () => {
createdAt: 1000,
connectionId: "conn-1",
sender: "client",
payload: { params: { prompt: [{ type: "text", text: "hello" }] } }
payload: { params: { prompt: [{ type: "text", text: "hello" }] } },
},
{
id: "evt-2",
@ -59,8 +57,8 @@ describe("buildTranscript", () => {
createdAt: 2000,
connectionId: "conn-1",
sender: "agent",
payload: { params: { text: "world" } }
}
payload: { params: { text: "world" } },
},
]);
expect(rows).toEqual([
@ -68,37 +66,38 @@ describe("buildTranscript", () => {
id: "evt-1",
sender: "client",
text: "hello",
createdAt: 1000
createdAt: 1000,
},
{
id: "evt-2",
sender: "agent",
text: "world",
createdAt: 2000
}
createdAt: 2000,
},
]);
});
});
describe("resolveSessionSelection", () => {
const session = (id: string, status: "running" | "idle" | "error" = "running"): SandboxSessionRecord => ({
id,
agentSessionId: `agent-${id}`,
lastConnectionId: `conn-${id}`,
createdAt: 1,
status
} as SandboxSessionRecord);
const session = (id: string, status: "running" | "idle" | "error" = "running"): SandboxSessionRecord =>
({
id,
agentSessionId: `agent-${id}`,
lastConnectionId: `conn-${id}`,
createdAt: 1,
status,
}) as SandboxSessionRecord;
it("prefers explicit selection when present in session list", () => {
const resolved = resolveSessionSelection({
explicitSessionId: "session-2",
handoffSessionId: "session-1",
sessions: [session("session-1"), session("session-2")]
sessions: [session("session-1"), session("session-2")],
});
expect(resolved).toEqual({
sessionId: "session-2",
staleSessionId: null
staleSessionId: null,
});
});
@ -106,12 +105,12 @@ describe("resolveSessionSelection", () => {
const resolved = resolveSessionSelection({
explicitSessionId: null,
handoffSessionId: "session-1",
sessions: [session("session-1")]
sessions: [session("session-1")],
});
expect(resolved).toEqual({
sessionId: "session-1",
staleSessionId: null
staleSessionId: null,
});
});
@ -119,12 +118,12 @@ describe("resolveSessionSelection", () => {
const resolved = resolveSessionSelection({
explicitSessionId: null,
handoffSessionId: "session-stale",
sessions: [session("session-fresh")]
sessions: [session("session-fresh")],
});
expect(resolved).toEqual({
sessionId: "session-fresh",
staleSessionId: null
staleSessionId: null,
});
});
@ -132,12 +131,12 @@ describe("resolveSessionSelection", () => {
const resolved = resolveSessionSelection({
explicitSessionId: null,
handoffSessionId: "session-stale",
sessions: []
sessions: [],
});
expect(resolved).toEqual({
sessionId: null,
staleSessionId: "session-stale"
staleSessionId: "session-stale",
});
});
});

View file

@ -105,11 +105,7 @@ export function buildTranscript(events: SandboxSessionEventRecord[]): Array<{
}));
}
export function resolveSessionSelection(input: {
explicitSessionId: string | null;
handoffSessionId: string | null;
sessions: SandboxSessionRecord[];
}): {
export function resolveSessionSelection(input: { explicitSessionId: string | null; handoffSessionId: string | null; sessions: SandboxSessionRecord[] }): {
sessionId: string | null;
staleSessionId: string | null;
} {