fix(tui): order messages by creation time (#40994)
Co-authored-by: Dax <mail@thdxr.com>
This commit is contained in:
committed by
GitHub
parent
a6d88d99d5
commit
b173ba95bd
@@ -349,6 +349,34 @@ describe("transcript", () => {
|
||||
expect(result).toContain("---")
|
||||
})
|
||||
|
||||
test("orders messages by creation time and preserves part order", () => {
|
||||
const message = (id: string, created: number, parts: string[]) => ({
|
||||
info: {
|
||||
id,
|
||||
sessionID: "ses_abc123",
|
||||
role: "user" as const,
|
||||
agent: "build",
|
||||
model: { providerID: "anthropic", modelID: "claude" },
|
||||
time: { created },
|
||||
},
|
||||
parts: parts.map((text, index) => ({
|
||||
id: `part_${parts.length - index}`,
|
||||
sessionID: "ses_abc123",
|
||||
messageID: id,
|
||||
type: "text" as const,
|
||||
text,
|
||||
})),
|
||||
})
|
||||
const result = formatTranscript(
|
||||
{ id: "ses_abc123", title: "Order", time: { created: 1, updated: 2 } },
|
||||
[message("msg_a", 30, ["third"]), message("msg_z", 10, ["first", "second"])],
|
||||
{ thinking: false, toolDetails: false, assistantMetadata: false },
|
||||
)
|
||||
|
||||
expect(result.indexOf("first")).toBeLessThan(result.indexOf("second"))
|
||||
expect(result.indexOf("second")).toBeLessThan(result.indexOf("third"))
|
||||
})
|
||||
|
||||
test("falls back to raw model id when provider data is missing", () => {
|
||||
const session = {
|
||||
id: "ses_abc123",
|
||||
|
||||
Reference in New Issue
Block a user