@@ -71,6 +71,7 @@ import { Filesystem } from "@/util/filesystem"
7171import { PermissionPrompt } from "./permission"
7272import { DialogExportOptions } from "../../ui/dialog-export-options"
7373import { formatTranscript } from "../../util/transcript"
74+ import { FilePathLink } from "../../ui/link"
7475
7576addDefaultParsers ( parsers . parsers )
7677
@@ -1483,7 +1484,12 @@ function InlineTool(props: {
14831484 )
14841485}
14851486
1486- function BlockTool ( props : { title : string ; children : JSX . Element ; onClick ?: ( ) => void ; part ?: ToolPart } ) {
1487+ function BlockTool ( props : {
1488+ title : string | JSX . Element
1489+ children : JSX . Element
1490+ onClick ?: ( ) => void
1491+ part ?: ToolPart
1492+ } ) {
14871493 const { theme } = useTheme ( )
14881494 const renderer = useRenderer ( )
14891495 const [ hover , setHover ] = createSignal ( false )
@@ -1554,7 +1560,14 @@ function Write(props: ToolProps<typeof WriteTool>) {
15541560 return (
15551561 < Switch >
15561562 < Match when = { props . metadata . diagnostics !== undefined } >
1557- < BlockTool title = { "# Wrote " + normalizePath ( props . input . filePath ! ) } part = { props . part } >
1563+ < BlockTool
1564+ title = {
1565+ < >
1566+ # Wrote < FilePathLink path = { props . input . filePath ! } > { normalizePath ( props . input . filePath ! ) } </ FilePathLink >
1567+ </ >
1568+ }
1569+ part = { props . part }
1570+ >
15581571 < line_number fg = { theme . textMuted } minWidth = { 3 } paddingRight = { 1 } >
15591572 < code
15601573 conceal = { false }
@@ -1577,7 +1590,7 @@ function Write(props: ToolProps<typeof WriteTool>) {
15771590 </ Match >
15781591 < Match when = { true } >
15791592 < InlineTool icon = "←" pending = "Preparing write..." complete = { props . input . filePath } part = { props . part } >
1580- Write { normalizePath ( props . input . filePath ! ) }
1593+ Write < FilePathLink path = { props . input . filePath ! } > { normalizePath ( props . input . filePath ! ) } </ FilePathLink >
15811594 </ InlineTool >
15821595 </ Match >
15831596 </ Switch >
@@ -1587,7 +1600,10 @@ function Write(props: ToolProps<typeof WriteTool>) {
15871600function Glob ( props : ToolProps < typeof GlobTool > ) {
15881601 return (
15891602 < InlineTool icon = "✱" pending = "Finding files..." complete = { props . input . pattern } part = { props . part } >
1590- Glob "{ props . input . pattern } " < Show when = { props . input . path } > in { normalizePath ( props . input . path ) } </ Show >
1603+ Glob "{ props . input . pattern } "{ " " }
1604+ < Show when = { props . input . path } >
1605+ in < FilePathLink path = { props . input . path ! } > { normalizePath ( props . input . path ) } </ FilePathLink > { " " }
1606+ </ Show >
15911607 < Show when = { props . metadata . count } > ({ props . metadata . count } matches)</ Show >
15921608 </ InlineTool >
15931609 )
@@ -1596,38 +1612,40 @@ function Glob(props: ToolProps<typeof GlobTool>) {
15961612function Read ( props : ToolProps < typeof ReadTool > ) {
15971613 return (
15981614 < InlineTool icon = "→" pending = "Reading file..." complete = { props . input . filePath } part = { props . part } >
1599- Read { normalizePath ( props . input . filePath ! ) } { input ( props . input , [ "filePath" ] ) }
1615+ Read < FilePathLink path = { props . input . filePath ! } > { normalizePath ( props . input . filePath ! ) } </ FilePathLink > { " " }
1616+ { input ( props . input , [ "filePath" ] ) }
16001617 </ InlineTool >
16011618 )
16021619}
16031620
16041621function Grep ( props : ToolProps < typeof GrepTool > ) {
16051622 return (
16061623 < InlineTool icon = "✱" pending = "Searching content..." complete = { props . input . pattern } part = { props . part } >
1607- Grep "{ props . input . pattern } " < Show when = { props . input . path } > in { normalizePath ( props . input . path ) } </ Show >
1624+ Grep "{ props . input . pattern } "{ " " }
1625+ < Show when = { props . input . path } >
1626+ in < FilePathLink path = { props . input . path ! } > { normalizePath ( props . input . path ) } </ FilePathLink > { " " }
1627+ </ Show >
16081628 < Show when = { props . metadata . matches } > ({ props . metadata . matches } matches)</ Show >
16091629 </ InlineTool >
16101630 )
16111631}
16121632
16131633function List ( props : ToolProps < typeof ListTool > ) {
1614- const dir = createMemo ( ( ) => {
1615- if ( props . input . path ) {
1616- return normalizePath ( props . input . path )
1617- }
1618- return ""
1619- } )
16201634 return (
16211635 < InlineTool icon = "→" pending = "Listing directory..." complete = { props . input . path !== undefined } part = { props . part } >
1622- List { dir ( ) }
1636+ List{ " " }
1637+ < Show when = { props . input . path } >
1638+ < FilePathLink path = { props . input . path ! } > { normalizePath ( props . input . path ) } </ FilePathLink >
1639+ </ Show >
16231640 </ InlineTool >
16241641 )
16251642}
16261643
16271644function WebFetch ( props : ToolProps < typeof WebFetchTool > ) {
1645+ const url = ( ) => ( props . input as any ) . url
16281646 return (
1629- < InlineTool icon = "%" pending = "Fetching from the web..." complete = { ( props . input as any ) . url } part = { props . part } >
1630- WebFetch { ( props . input as any ) . url }
1647+ < InlineTool icon = "%" pending = "Fetching from the web..." complete = { url ( ) } part = { props . part } >
1648+ WebFetch < a href = { url ( ) } > { url ( ) } </ a >
16311649 </ InlineTool >
16321650 )
16331651}
@@ -1730,7 +1748,15 @@ function Edit(props: ToolProps<typeof EditTool>) {
17301748 return (
17311749 < Switch >
17321750 < Match when = { props . metadata . diff !== undefined } >
1733- < BlockTool title = { "← Edit " + normalizePath ( props . input . filePath ! ) } part = { props . part } >
1751+ < BlockTool
1752+ title = {
1753+ < >
1754+ { "← Edit " }
1755+ < FilePathLink path = { props . input . filePath ! } > { normalizePath ( props . input . filePath ! ) } </ FilePathLink >
1756+ </ >
1757+ }
1758+ part = { props . part }
1759+ >
17341760 < box paddingLeft = { 1 } >
17351761 < diff
17361762 diff = { diffContent ( ) }
@@ -1768,7 +1794,8 @@ function Edit(props: ToolProps<typeof EditTool>) {
17681794 </ Match >
17691795 < Match when = { true } >
17701796 < InlineTool icon = "←" pending = "Preparing edit..." complete = { props . input . filePath } part = { props . part } >
1771- Edit { normalizePath ( props . input . filePath ! ) } { input ( { replaceAll : props . input . replaceAll } ) }
1797+ Edit < FilePathLink path = { props . input . filePath ! } > { normalizePath ( props . input . filePath ! ) } </ FilePathLink > { " " }
1798+ { input ( { replaceAll : props . input . replaceAll } ) }
17721799 </ InlineTool >
17731800 </ Match >
17741801 </ Switch >
0 commit comments