Skip to content

Commit c6271a2

Browse files
tellahonpub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6w
authored andcommitted
fix(agents): render formatted prompt bubbles
- Render user prompt transcript bubbles through the shared Markdown component so bullets, line breaks, and inline formatting display like normal messages - Preserve multi-line Buzz event Content fields when parsing ACP prompt payloads, stopping before harness metadata such as Tags and Parsed fields - Add transcript helper coverage for a multi-line mention prompt to guard against flattening formatted responses back to one line
1 parent 812384e commit c6271a2

3 files changed

Lines changed: 65 additions & 4 deletions

File tree

desktop/src/features/agents/ui/AgentSessionTranscriptList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ function PromptUserMessage({
291291
/>
292292
<div className="group relative flex max-w-[85%] min-w-0 flex-col items-end gap-1">
293293
<div className="w-full min-w-0 rounded-2xl bg-muted p-2.5 text-sm leading-relaxed text-foreground">
294-
<p className="whitespace-pre-wrap wrap-break-word">{text}</p>
294+
<Markdown content={text || " "} tight />
295295
{contextOpen && context ? (
296296
<PromptContextSections sections={context.sections} setup={setup} />
297297
) : null}
@@ -607,7 +607,7 @@ function MessageItem({
607607
<Markdown compact content={text || " "} />
608608
) : (
609609
<>
610-
<p className="whitespace-pre-wrap wrap-break-word">{text}</p>
610+
<Markdown content={text || " "} tight />
611611
<TranscriptTimestamp timestamp={item.timestamp} />
612612
</>
613613
)}

desktop/src/features/agents/ui/agentSessionTranscriptHelpers.test.mjs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,37 @@ test("parsePromptText extracts content, hex pubkey, and a title-cased kind", ()
6565
);
6666
});
6767

68+
test("parsePromptText preserves multiline event content in the user bubble text", () => {
69+
const text = [
70+
"[Buzz event: @mention]",
71+
"Event ID: event-1",
72+
"Channel: agents",
73+
`From: tho (hex: ${HEX})`,
74+
"Time: 2026-06-15T17:15:00Z",
75+
"Content: @Ned",
76+
"",
77+
"- remove that stray cherry pick if it's not adding value here",
78+
"- help me understand what that e2eBridge change does",
79+
"- we'd want the e2e seed path as a separate pull request",
80+
'Tags: [["h","agents"]]',
81+
"Parsed: mentions=[Ned]",
82+
].join("\n");
83+
84+
const result = parsePromptText(text);
85+
86+
assert.equal(
87+
result.userText,
88+
[
89+
"@Ned",
90+
"",
91+
"- remove that stray cherry pick if it's not adding value here",
92+
"- help me understand what that e2eBridge change does",
93+
"- we'd want the e2e seed path as a separate pull request",
94+
].join("\n"),
95+
);
96+
assert.equal(result.userPubkey, HEX);
97+
});
98+
6899
test("parsePromptText lowercases the extracted hex pubkey", () => {
69100
const text = [
70101
"[Buzz event: dm]",

desktop/src/features/agents/ui/agentSessionTranscriptHelpers.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,39 @@ function parsePromptSections(text: string): PromptSection[] {
8585
return sections;
8686
}
8787

88+
const EVENT_CONTENT_BOUNDARY_RE =
89+
/^(?:Event ID|Channel|Kind|From|Time|Tags|Parsed):\s*/;
90+
const EVENT_BLOCK_BOUNDARY_RE = /^--- Event \d+\b/;
91+
8892
function extractEventContent(body: string): string {
89-
const contentMatch = body.match(/^Content:\s*(.*)$/m);
90-
return contentMatch?.[1]?.trim() ?? "";
93+
const lines = body.split(/\r?\n/);
94+
const chunks: string[] = [];
95+
96+
for (let i = 0; i < lines.length; i++) {
97+
const match = lines[i].match(/^Content:\s?(.*)$/);
98+
if (!match) {
99+
continue;
100+
}
101+
102+
const contentLines = [match[1] ?? ""];
103+
for (let j = i + 1; j < lines.length; j++) {
104+
const line = lines[j];
105+
if (
106+
EVENT_CONTENT_BOUNDARY_RE.test(line) ||
107+
EVENT_BLOCK_BOUNDARY_RE.test(line)
108+
) {
109+
break;
110+
}
111+
contentLines.push(line);
112+
}
113+
114+
const content = contentLines.join("\n").trim();
115+
if (content) {
116+
chunks.push(content);
117+
}
118+
}
119+
120+
return chunks.join("\n\n");
91121
}
92122

93123
function extractEventAuthorPubkey(body: string): string | null {

0 commit comments

Comments
 (0)