Skip to content

Commit c858b25

Browse files
committed
fix(webapp): trigger:// links in prose resolve to dashboard paths
Markdown renderers won't link an unknown scheme, so a cited trigger:// target rendered dead. Prose links now rewrite through the panel's resolver; while unresolved they degrade to their plain label.
1 parent 7a70045 commit c858b25

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

apps/webapp/app/components/dashboard-agent/DashboardAgentMessages.tsx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,29 @@ function withoutSupersededInvestigations(
172172
* would read as the agent ignoring the question. Citations are handled a level up,
173173
* where a run of them can be grouped into one row.
174174
*/
175-
function renderDashboardPart(part: UIMessage["parts"][number], i: number) {
175+
/**
176+
* Rewrite `[label](trigger://…)` links in prose to their resolved dashboard
177+
* paths. Markdown renderers won't link an unknown scheme, so a raw trigger://
178+
* target renders dead; while the resolver hasn't answered (or can't), the link
179+
* degrades to its plain label — never a dead href.
180+
*/
181+
const TRIGGER_MD_LINK = /\[([^\]]+)\]\((trigger:\/\/[^\s)]+)\)/g;
182+
function resolveTriggerLinks(
183+
text: string,
184+
resolveUri?: (uri: string) => ResolvedUri | null
185+
): string {
186+
if (!text.includes("trigger://")) return text;
187+
return text.replace(TRIGGER_MD_LINK, (whole, label: string, uri: string) => {
188+
const resolved = resolveUri?.(uri);
189+
return resolved ? `[${label}](${resolved.url})` : label;
190+
});
191+
}
192+
193+
function renderDashboardPart(
194+
part: UIMessage["parts"][number],
195+
i: number,
196+
resolveUri?: (uri: string) => ResolvedUri | null
197+
) {
176198
const p = part as {
177199
type: string;
178200
text?: string;
@@ -183,7 +205,7 @@ function renderDashboardPart(part: UIMessage["parts"][number], i: number) {
183205
const type = part.type as string;
184206

185207
if (type === "text") {
186-
return p.text ? <ChatText key={i} text={p.text} /> : null;
208+
return p.text ? <ChatText key={i} text={resolveTriggerLinks(p.text, resolveUri)} /> : null;
187209
}
188210

189211
if (type.startsWith("tool-")) {
@@ -325,7 +347,7 @@ const DashboardAgentTurn = memo(function DashboardAgentTurn({
325347
continue;
326348
}
327349

328-
body.push(renderDashboardPart(part, i));
350+
body.push(renderDashboardPart(part, i, resolveUri));
329351
}
330352

331353
// A wake narration is identified by the message id the agent wrote it under,

0 commit comments

Comments
 (0)