mirror of
https://github.com/anomalyco/opencode.git
synced 2026-06-02 06:16:48 +02:00
chore: generate
This commit is contained in:
@@ -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))
|
||||
return rows.reduce((out, local) => {
|
||||
const row = local.commit
|
||||
|
||||
@@ -180,11 +180,9 @@ describe("run session replay", () => {
|
||||
messageID: "msg-user-1",
|
||||
} as const
|
||||
|
||||
expect(replayLocalRows([userMessage("msg-user-2", "successful")], [persisted], [{ commit: failed }, { commit: error }])).toEqual([
|
||||
failed,
|
||||
error,
|
||||
persisted,
|
||||
])
|
||||
expect(
|
||||
replayLocalRows([userMessage("msg-user-2", "successful")], [persisted], [{ commit: failed }, { commit: error }]),
|
||||
).toEqual([failed, error, persisted])
|
||||
})
|
||||
|
||||
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",
|
||||
} as const
|
||||
|
||||
expect(replayLocalRows([userMessage("msg-user-1", "failed after persistence")], [persisted], [{ commit: persisted }, { commit: error }])).toEqual([
|
||||
persisted,
|
||||
error,
|
||||
])
|
||||
expect(
|
||||
replayLocalRows(
|
||||
[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", () => {
|
||||
@@ -308,7 +309,10 @@ describe("run session replay", () => {
|
||||
} as const
|
||||
|
||||
expect(
|
||||
replayLocalRows([userMessage("msg-user-1", "start")], [first, complete], [
|
||||
replayLocalRows(
|
||||
[userMessage("msg-user-1", "start")],
|
||||
[first, complete],
|
||||
[
|
||||
{
|
||||
commit: error,
|
||||
after: {
|
||||
@@ -320,7 +324,8 @@ describe("run session replay", () => {
|
||||
visible: "before ",
|
||||
},
|
||||
},
|
||||
]),
|
||||
],
|
||||
),
|
||||
).toEqual([first, { ...complete, text: "before " }, error, { ...complete, text: "after" }])
|
||||
})
|
||||
|
||||
@@ -348,13 +353,17 @@ describe("run session replay", () => {
|
||||
} as const
|
||||
|
||||
expect(
|
||||
replayLocalRows([], [answer], [
|
||||
replayLocalRows(
|
||||
[],
|
||||
[answer],
|
||||
[
|
||||
{ commit: prompt },
|
||||
{
|
||||
commit: error,
|
||||
after: { kind: "assistant", text: "partial answer", phase: "progress", messageID: "msg-2" },
|
||||
},
|
||||
]),
|
||||
],
|
||||
),
|
||||
).toEqual([prompt, answer, error])
|
||||
})
|
||||
|
||||
@@ -393,7 +402,10 @@ describe("run session replay", () => {
|
||||
} as const
|
||||
|
||||
expect(
|
||||
replayLocalRows([userMessage("msg-user-1", "run ls")], [prompt, running, completed], [
|
||||
replayLocalRows(
|
||||
[userMessage("msg-user-1", "run ls")],
|
||||
[prompt, running, completed],
|
||||
[
|
||||
{
|
||||
commit: error,
|
||||
after: {
|
||||
@@ -405,7 +417,8 @@ describe("run session replay", () => {
|
||||
toolState: "running",
|
||||
},
|
||||
},
|
||||
]),
|
||||
],
|
||||
),
|
||||
).toEqual([prompt, running, error, completed])
|
||||
})
|
||||
|
||||
@@ -433,9 +446,11 @@ describe("run session replay", () => {
|
||||
} as const
|
||||
|
||||
expect(
|
||||
replayLocalRows([userMessage("msg-user-1", "before"), userMessage("msg-user-3", "after")], [first, second], [
|
||||
{ commit: error },
|
||||
]),
|
||||
replayLocalRows(
|
||||
[userMessage("msg-user-1", "before"), userMessage("msg-user-3", "after")],
|
||||
[first, second],
|
||||
[{ commit: error }],
|
||||
),
|
||||
).toEqual([first, error, second])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user