@@ -573,6 +573,42 @@ describe("AssetAccess", () => {
573573 } ) . pipe ( Effect . provide ( testLayer ) ) ,
574574 ) ;
575575
576+ it . effect ( "issues exact workspace URLs for PDF previews" , ( ) =>
577+ Effect . gen ( function * ( ) {
578+ const fileSystem = yield * FileSystem . FileSystem ;
579+ const path = yield * Path . Path ;
580+ const root = yield * fileSystem . makeTempDirectoryScoped ( {
581+ prefix : "t3-asset-pdf-workspace-" ,
582+ } ) ;
583+ const docsDirectory = path . join ( root , "docs" ) ;
584+ const pdfPath = path . join ( docsDirectory , "report.pdf" ) ;
585+ const siblingPath = path . join ( docsDirectory , "private.pdf" ) ;
586+ yield * fileSystem . makeDirectory ( docsDirectory , { recursive : true } ) ;
587+ yield * fileSystem . writeFileString ( pdfPath , "report" ) ;
588+ yield * fileSystem . writeFileString ( siblingPath , "private" ) ;
589+ const canonicalPdfPath = yield * fileSystem . realPath ( pdfPath ) ;
590+
591+ const result = yield * issueAssetUrl ( {
592+ resource : {
593+ _tag : "workspace-file" ,
594+ threadId : ThreadId . make ( "thread-1" ) ,
595+ path : pdfPath ,
596+ } ,
597+ workspaceRoot : root ,
598+ } ) ;
599+ const suffix = result . relativeUrl . slice ( `${ ASSET_ROUTE_PREFIX } /` . length ) ;
600+ const separatorIndex = suffix . indexOf ( "/" ) ;
601+ const token = suffix . slice ( 0 , separatorIndex ) ;
602+
603+ expect ( yield * resolveAsset ( token , "report.pdf" ) ) . toEqual ( {
604+ kind : "file" ,
605+ path : canonicalPdfPath ,
606+ } ) ;
607+ expect ( yield * resolveAsset ( token , "private.pdf" ) ) . toBeNull ( ) ;
608+ expect ( yield * resolveAsset ( token , "../report.pdf" ) ) . toBeNull ( ) ;
609+ } ) . pipe ( Effect . provide ( testLayer ) ) ,
610+ ) ;
611+
576612 it . effect ( "issues exact attachment capabilities by attachment id" , ( ) =>
577613 Effect . gen ( function * ( ) {
578614 const config = yield * ServerConfig . ServerConfig ;
0 commit comments