@@ -11,6 +11,8 @@ import "../index.css";
1111import { useTheme } from "../hooks/useTheme" ;
1212import { applyThemeColorPreview , getStandardThemeColors } from "../themePalette" ;
1313
14+ import { readLocalApi } from "../localApi" ;
15+ import { toastManager } from "./ui/toast" ;
1416import { filesystemEnvironment } from "../state/filesystem" ;
1517import { useRightPanelStore } from "../rightPanelStore" ;
1618import { getSyntaxHighlighterPromise } from "../lib/syntaxHighlighting" ;
@@ -1262,6 +1264,60 @@ describe("ChatMarkdown thread find", () => {
12621264 ) ;
12631265} ) ;
12641266
1267+ it . each ( [
1268+ {
1269+ name : "Windows drive paths on a Mac client" ,
1270+ platform : "MacIntel" ,
1271+ cwd : "C:/repo" ,
1272+ href : "C:/repo/reports/Device Users.csv:12:3" ,
1273+ full : String . raw `C:\repo\reports\Device Users.csv:12:3` ,
1274+ relative : String . raw `reports\Device Users.csv:12:3` ,
1275+ } ,
1276+ {
1277+ name : "UNC paths on a Mac client" ,
1278+ platform : "MacIntel" ,
1279+ cwd : String . raw `\\server\share\repo` ,
1280+ href : "file://server/share/repo/reports/report.csv" ,
1281+ full : String . raw `\\server\share\repo\reports\report.csv` ,
1282+ relative : String . raw `reports\report.csv` ,
1283+ } ,
1284+ {
1285+ name : "POSIX paths on a Windows client" ,
1286+ platform : "Win32" ,
1287+ cwd : "/home/repo" ,
1288+ href : "/home/repo/reports/report.csv" ,
1289+ full : "/home/repo/reports/report.csv" ,
1290+ relative : "reports/report.csv" ,
1291+ } ,
1292+ ] ) ( "copies $name and shows the copied text" , async ( { platform, cwd, href, full, relative } ) => {
1293+ vi . spyOn ( navigator , "platform" , "get" ) . mockReturnValue ( platform ) ;
1294+ vi . stubGlobal ( "ClipboardItem" , undefined ) ;
1295+ const writeText = vi . spyOn ( navigator . clipboard , "writeText" ) . mockResolvedValue ( undefined ) ;
1296+ const toast = vi . spyOn ( toastManager , "add" ) ;
1297+ const api = readLocalApi ( ) ;
1298+ if ( ! api ) throw new Error ( "Local API unavailable" ) ;
1299+ const choose = vi . spyOn ( api . contextMenu , "show" ) ;
1300+ const container = await renderText ( `[File](<${ href } >)` , {
1301+ cwd,
1302+ environmentId : EnvironmentId . make ( "env-file-copy" ) ,
1303+ } ) ;
1304+ const link = container . querySelector ( ".chat-markdown-file-link" ) ;
1305+ if ( ! link ) throw new Error ( "File link unavailable" ) ;
1306+ for ( const [ action , expected ] of [
1307+ [ "copy-full" , full ] ,
1308+ [ "copy-relative" , relative ] ,
1309+ ] as const ) {
1310+ choose . mockResolvedValue ( action ) ;
1311+ await act ( async ( ) => {
1312+ link . dispatchEvent ( new MouseEvent ( "contextmenu" , { bubbles : true } ) ) ;
1313+ } ) ;
1314+ expect ( writeText ) . toHaveBeenLastCalledWith ( expected ) ;
1315+ expect ( toast ) . toHaveBeenLastCalledWith (
1316+ expect . objectContaining ( { type : "success" , description : expected } ) ,
1317+ ) ;
1318+ }
1319+ } ) ;
1320+
12651321describe ( "ChatMarkdown math" , ( ) => {
12661322 const renderMath = async (
12671323 text : string ,
0 commit comments