forked from farhoodlabs/paperclip
Refine issue workflow surfaces and live updates
This commit is contained in:
@@ -370,6 +370,70 @@ describe("buildIssueChatMessages", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("compacts long run transcripts in issue chat while preserving matching tool context", () => {
|
||||
const isoAt = (baseMs: number, offsetSeconds: number) =>
|
||||
new Date(baseMs + offsetSeconds * 1000).toISOString();
|
||||
const baseMs = Date.parse("2026-04-06T12:00:00.000Z");
|
||||
const transcript = [
|
||||
...Array.from({ length: 9 }, (_, index) => ({
|
||||
kind: "assistant" as const,
|
||||
ts: isoAt(baseMs, index),
|
||||
text: `Older update ${index + 1}`,
|
||||
})),
|
||||
{
|
||||
kind: "tool_call" as const,
|
||||
ts: isoAt(baseMs, 9),
|
||||
name: "search",
|
||||
toolUseId: "tool-keep",
|
||||
input: { query: "issue chat virtualization" },
|
||||
},
|
||||
...Array.from({ length: 79 }, (_, index) => ({
|
||||
kind: "assistant" as const,
|
||||
ts: isoAt(baseMs, 10 + index),
|
||||
text: `Recent update ${index + 1}`,
|
||||
})),
|
||||
{
|
||||
kind: "tool_result" as const,
|
||||
ts: isoAt(baseMs, 89),
|
||||
toolUseId: "tool-keep",
|
||||
content: "search completed",
|
||||
isError: false,
|
||||
},
|
||||
];
|
||||
|
||||
const messages = buildIssueChatMessages({
|
||||
comments: [],
|
||||
timelineEvents: [],
|
||||
linkedRuns: [
|
||||
{
|
||||
runId: "run-history-3",
|
||||
status: "succeeded",
|
||||
agentId: "agent-1",
|
||||
agentName: "CodexCoder",
|
||||
createdAt: new Date("2026-04-06T12:00:00.000Z"),
|
||||
startedAt: new Date("2026-04-06T12:00:00.000Z"),
|
||||
finishedAt: new Date("2026-04-06T12:03:00.000Z"),
|
||||
},
|
||||
],
|
||||
liveRuns: [],
|
||||
transcriptsByRunId: new Map([["run-history-3", transcript]]),
|
||||
hasOutputForRun: (runId) => runId === "run-history-3",
|
||||
currentUserId: "user-1",
|
||||
});
|
||||
|
||||
expect(messages).toHaveLength(1);
|
||||
const textParts = messages[0]?.content
|
||||
.filter((part): part is { type: "text"; text: string } => part.type === "text")
|
||||
.map((part) => part.text) ?? [];
|
||||
expect(textParts.join("\n")).not.toContain("Older update 1");
|
||||
expect(messages[0]?.content).toContainEqual(expect.objectContaining({
|
||||
type: "tool-call",
|
||||
toolCallId: "tool-keep",
|
||||
toolName: "search",
|
||||
result: "search completed",
|
||||
}));
|
||||
});
|
||||
|
||||
it("keeps the same assistant message id when a live run becomes a cancelled historical run", () => {
|
||||
const liveMessages = buildIssueChatMessages({
|
||||
comments: [],
|
||||
|
||||
Reference in New Issue
Block a user