Skip to content

Commit 3fd3b8e

Browse files
feat: add data-snippet rendering in markdown export
Co-Authored-By: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>
1 parent d78ed36 commit 3fd3b8e

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

apps/web/app/api/shared/[shareId]/markdown/route.test.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,18 @@ let messageRows: Array<{ parts: unknown; role: string; createdAt: Date }> = [
3636
parts: {
3737
id: "m1",
3838
role: "user",
39-
parts: [{ type: "text", text: "Please debug the flaky tests." }],
39+
parts: [
40+
{ type: "text", text: "Please debug the flaky tests." },
41+
{
42+
type: "data-snippet",
43+
id: "snippet-1",
44+
data: {
45+
filename: "logs/test-output.txt",
46+
content:
47+
" FAIL tests/flaky.test.ts\nExpected 200 but received 500",
48+
},
49+
},
50+
],
4051
},
4152
role: "user",
4253
createdAt: new Date("2025-01-01T12:00:00Z"),
@@ -118,7 +129,18 @@ describe("GET /api/shared/:shareId/markdown", () => {
118129
parts: {
119130
id: "m1",
120131
role: "user",
121-
parts: [{ type: "text", text: "Please debug the flaky tests." }],
132+
parts: [
133+
{ type: "text", text: "Please debug the flaky tests." },
134+
{
135+
type: "data-snippet",
136+
id: "snippet-1",
137+
data: {
138+
filename: "logs/test-output.txt",
139+
content:
140+
" FAIL tests/flaky.test.ts\nExpected 200 but received 500",
141+
},
142+
},
143+
],
122144
},
123145
role: "user",
124146
createdAt: new Date("2025-01-01T12:00:00Z"),
@@ -187,6 +209,9 @@ describe("GET /api/shared/:shareId/markdown", () => {
187209
expect(body).toContain("pr_number: 123");
188210
expect(body).toContain('created_at: "2025-01-01T12:00:00.000Z"');
189211
expect(body).toContain("## User\nPlease debug the flaky tests.");
212+
expect(body).toContain(
213+
'<snippet filename="logs/test-output.txt">\n FAIL tests/flaky.test.ts\nExpected 200 but received 500\n</snippet>',
214+
);
190215
expect(body).toContain("<!-- tool_activity: duration=15m tool_calls=2 -->");
191216
expect(body).toContain("## Assistant\nI fixed the timeout handling.");
192217
expect(body).not.toContain("README.md");

apps/web/app/api/shared/[shareId]/markdown/route.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ function getMessageBody(message: WebAgentUIMessage): string {
6666
if (text.length > 0) {
6767
blocks.push(text);
6868
}
69+
continue;
70+
}
71+
72+
if (part.type === "data-snippet") {
73+
blocks.push(
74+
`<snippet filename=${JSON.stringify(part.data.filename)}>` +
75+
`\n${part.data.content}\n</snippet>`,
76+
);
6977
}
7078
}
7179

0 commit comments

Comments
 (0)