Files
claude-code/src/components/FilePathLink.tsx
2026-04-07 16:17:48 +08:00

20 lines
592 B
TypeScript

import React from 'react'
import { pathToFileURL } from 'url'
import { Link } from '@anthropic/ink'
type Props = {
/** The absolute file path */
filePath: string
/** Optional display text (defaults to filePath) */
children?: React.ReactNode
}
/**
* Renders a file path as an OSC 8 hyperlink.
* This helps terminals like iTerm correctly identify file paths
* even when they appear inside parentheses or other text.
*/
export function FilePathLink({ filePath, children }: Props): React.ReactNode {
return <Link url={pathToFileURL(filePath).href}>{children ?? filePath}</Link>
}