mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
Add support for clickable links
This commit is contained in:
parent
427157c683
commit
2caa6bd84c
1 changed files with 12 additions and 0 deletions
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue