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))
|
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,7 +309,10 @@ describe("run session replay", () => {
|
|||||||
} as const
|
} as const
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
replayLocalRows([userMessage("msg-user-1", "start")], [first, complete], [
|
replayLocalRows(
|
||||||
|
[userMessage("msg-user-1", "start")],
|
||||||
|
[first, complete],
|
||||||
|
[
|
||||||
{
|
{
|
||||||
commit: error,
|
commit: error,
|
||||||
after: {
|
after: {
|
||||||
@@ -320,7 +324,8 @@ describe("run session replay", () => {
|
|||||||
visible: "before ",
|
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(
|
||||||
|
[],
|
||||||
|
[answer],
|
||||||
|
[
|
||||||
{ commit: prompt },
|
{ commit: prompt },
|
||||||
{
|
{
|
||||||
commit: error,
|
commit: error,
|
||||||
after: { kind: "assistant", text: "partial answer", phase: "progress", messageID: "msg-2" },
|
after: { kind: "assistant", text: "partial answer", phase: "progress", messageID: "msg-2" },
|
||||||
},
|
},
|
||||||
]),
|
],
|
||||||
|
),
|
||||||
).toEqual([prompt, answer, error])
|
).toEqual([prompt, answer, error])
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -393,7 +402,10 @@ 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")],
|
||||||
|
[prompt, running, completed],
|
||||||
|
[
|
||||||
{
|
{
|
||||||
commit: error,
|
commit: error,
|
||||||
after: {
|
after: {
|
||||||
@@ -405,7 +417,8 @@ describe("run session replay", () => {
|
|||||||
toolState: "running",
|
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])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user