Add support for clickable links

This commit is contained in:
John Cummings 2025-12-19 09:01:49 -07:00
parent 427157c683
commit 2caa6bd84c

View file

@ -66,9 +66,18 @@ import stripAnsi from "strip-ansi"
import { Footer } from "./footer.tsx"
import { usePromptRef } from "../../context/prompt"
import { Filesystem } from "@/util/filesystem"
import open from "open"
addDefaultParsers(parsers.parsers)
/**
* Handle alt+click or ctrl+click on links in markdown content
* Opens URLs in the default browser
*/
function handleLinkClick(url: string) {
open(url).catch(() => {})
}
class CustomSpeedScroll implements ScrollAcceleration {
constructor(private speed: number) {}
@ -1208,6 +1217,7 @@ function ReasoningPart(props: { last: boolean; part: ReasoningPart; message: Ass
content={"_Thinking:_ " + content()}
conceal={ctx.conceal()}
fg={theme.textMuted}
onLinkClick={handleLinkClick}
/>
</box>
</Show>
@ -1228,6 +1238,7 @@ function TextPart(props: { last: boolean; part: TextPart; message: AssistantMess
content={props.part.text.trim()}
conceal={ctx.conceal()}
fg={theme.text}
onLinkClick={handleLinkClick}
/>
</box>
</Show>
@ -1461,6 +1472,7 @@ ToolRegistry.register<typeof WriteTool>({
filetype={filetype(props.input.filePath!)}
syntaxStyle={syntax()}
content={code()}
onLinkClick={handleLinkClick}
/>
</line_number>
</Show>