chore: generate

This commit is contained in:
opencode-agent[bot]
2026-06-01 13:13:19 +00:00
parent 6a3b2f339a
commit 10095bfad4
2 changed files with 63 additions and 44 deletions
@@ -187,7 +187,11 @@ export function replaySession(input: ReplayInput): SessionReplay {
} }
} }
export function replayLocalRows(messages: SessionMessages, commits: StreamCommit[], rows: LocalReplayRow[]): StreamCommit[] { export function replayLocalRows(
messages: SessionMessages,
commits: StreamCommit[],
rows: LocalReplayRow[],
): StreamCommit[] {
const persisted = new Set(messages.map((message) => message.info.id)) const persisted = new Set(messages.map((message) => message.info.id))
return rows.reduce((out, local) => { return rows.reduce((out, local) => {
const row = local.commit const row = local.commit
@@ -180,11 +180,9 @@ describe("run session replay", () => {
messageID: "msg-user-1", messageID: "msg-user-1",
} as const } as const
expect(replayLocalRows([userMessage("msg-user-2", "successful")], [persisted], [{ commit: failed }, { commit: error }])).toEqual([ expect(
failed, replayLocalRows([userMessage("msg-user-2", "successful")], [persisted], [{ commit: failed }, { commit: error }]),
error, ).toEqual([failed, error, persisted])
persisted,
])
}) })
test("retains local errors but not duplicate local prompts once a prompt persists", () => { test("retains local errors but not duplicate local prompts once a prompt persists", () => {
@@ -203,10 +201,13 @@ describe("run session replay", () => {
messageID: "msg-user-1", messageID: "msg-user-1",
} as const } as const
expect(replayLocalRows([userMessage("msg-user-1", "failed after persistence")], [persisted], [{ commit: persisted }, { commit: error }])).toEqual([ expect(
persisted, replayLocalRows(
error, [userMessage("msg-user-1", "failed after persistence")],
]) [persisted],
[{ commit: persisted }, { commit: error }],
),
).toEqual([persisted, error])
}) })
test("keeps a local turn failure below assistant output already visible for that turn", () => { test("keeps a local turn failure below assistant output already visible for that turn", () => {
@@ -308,19 +309,23 @@ describe("run session replay", () => {
} as const } as const
expect( expect(
replayLocalRows([userMessage("msg-user-1", "start")], [first, complete], [ replayLocalRows(
{ [userMessage("msg-user-1", "start")],
commit: error, [first, complete],
after: { [
kind: "assistant", {
text: "before ", commit: error,
phase: "progress", after: {
messageID: "msg-assistant-1", kind: "assistant",
partID: "part-1", text: "before ",
visible: "before ", phase: "progress",
messageID: "msg-assistant-1",
partID: "part-1",
visible: "before ",
},
}, },
}, ],
]), ),
).toEqual([first, { ...complete, text: "before " }, error, { ...complete, text: "after" }]) ).toEqual([first, { ...complete, text: "before " }, error, { ...complete, text: "after" }])
}) })
@@ -348,13 +353,17 @@ describe("run session replay", () => {
} as const } as const
expect( expect(
replayLocalRows([], [answer], [ replayLocalRows(
{ commit: prompt }, [],
{ [answer],
commit: error, [
after: { kind: "assistant", text: "partial answer", phase: "progress", messageID: "msg-2" }, { commit: prompt },
}, {
]), commit: error,
after: { kind: "assistant", text: "partial answer", phase: "progress", messageID: "msg-2" },
},
],
),
).toEqual([prompt, answer, error]) ).toEqual([prompt, answer, error])
}) })
@@ -393,19 +402,23 @@ describe("run session replay", () => {
} as const } as const
expect( expect(
replayLocalRows([userMessage("msg-user-1", "run ls")], [prompt, running, completed], [ replayLocalRows(
{ [userMessage("msg-user-1", "run ls")],
commit: error, [prompt, running, completed],
after: { [
kind: "tool", {
text: "running bash", commit: error,
phase: "start", after: {
messageID: "msg-assistant-1", kind: "tool",
partID: "part-tool-1", text: "running bash",
toolState: "running", phase: "start",
messageID: "msg-assistant-1",
partID: "part-tool-1",
toolState: "running",
},
}, },
}, ],
]), ),
).toEqual([prompt, running, error, completed]) ).toEqual([prompt, running, error, completed])
}) })
@@ -433,9 +446,11 @@ describe("run session replay", () => {
} as const } as const
expect( expect(
replayLocalRows([userMessage("msg-user-1", "before"), userMessage("msg-user-3", "after")], [first, second], [ replayLocalRows(
{ commit: error }, [userMessage("msg-user-1", "before"), userMessage("msg-user-3", "after")],
]), [first, second],
[{ commit: error }],
),
).toEqual([first, error, second]) ).toEqual([first, error, second])
}) })
}) })