@@ -71,6 +71,7 @@ import {
7171 markdownImageSourceFragment ,
7272} from "@t3tools/client-runtime/markdown-images" ;
7373import { mediaFileReference , mediaUrlReference } from "@t3tools/client-runtime/media-reference" ;
74+ import { MISSING_FILE_ACCESS_MESSAGE } from "@t3tools/client-runtime/state/assets" ;
7475import { mediaKindFromPath , mediaMimeTypeFromExtension } from "@t3tools/shared/filePreview" ;
7576import * as Cause from "effect/Cause" ;
7677import { AsyncResult } from "effect/reactivity" ;
@@ -1349,13 +1350,15 @@ function expandableMarkdownImageProps(
13491350function ChatMarkdownMediaUnavailableLabel ( props : {
13501351 readonly alt : string ;
13511352 readonly kind ?: "image" | "video" | undefined ;
1353+ /** Why the media is unavailable, when the cause is known. */
1354+ readonly detail ?: string | undefined ;
13521355} ) {
13531356 const label = props . kind === "video" ? "Video unavailable" : "Image unavailable" ;
13541357 return (
13551358 // Find indexes no image text, so this fallback must not highlight either.
13561359 < span data-thread-find-ignore className = "inline-flex items-center gap-1.5" >
13571360 < TriangleAlertIcon aria-hidden className = "size-3.5 shrink-0" />
1358- { props . alt . length > 0 ? ` ${ label } · ${ props . alt } ` : label }
1361+ { [ label , props . alt , props . detail ] . filter ( Boolean ) . join ( " · " ) }
13591362 </ span >
13601363 ) ;
13611364}
@@ -1366,6 +1369,7 @@ function ChatMarkdownImageFallback(props: {
13661369 readonly copyMarkdown ?: string | undefined ;
13671370 readonly kind ?: "image" | "video" ;
13681371 readonly actionsSource ?: MediaActionSource | undefined ;
1372+ readonly detail ?: string | undefined ;
13691373} ) {
13701374 const content = (
13711375 < span
@@ -1375,7 +1379,7 @@ function ChatMarkdownImageFallback(props: {
13751379 "rounded-md border border-border/40 bg-muted/40 px-2 py-1 text-xs text-muted-foreground" ,
13761380 ) }
13771381 >
1378- < ChatMarkdownMediaUnavailableLabel alt = { props . alt } kind = { props . kind } />
1382+ < ChatMarkdownMediaUnavailableLabel alt = { props . alt } kind = { props . kind } detail = { props . detail } />
13791383 </ span >
13801384 ) ;
13811385 return props . actionsSource ? (
@@ -1408,6 +1412,8 @@ function ChatMarkdownImage(props: {
14081412 /** Null while the URL is being resolved; the last decoded image stays up. */
14091413 readonly src : string | null ;
14101414 readonly sourceFailed ?: boolean | undefined ;
1415+ /** Why the source failed, when the cause is known. */
1416+ readonly unavailableDetail ?: string | undefined ;
14111417 readonly alt : string ;
14121418 readonly copyMarkdown : string | undefined ;
14131419 readonly standalone : boolean ;
@@ -1481,6 +1487,7 @@ function ChatMarkdownImage(props: {
14811487 alt = { props . alt }
14821488 copyMarkdown = { props . copyMarkdown }
14831489 actionsSource = { props . actionsSource }
1490+ detail = { props . unavailableDetail }
14841491 />
14851492 ) : (
14861493 < span
@@ -1509,7 +1516,7 @@ function ChatMarkdownImage(props: {
15091516 >
15101517 { failed ? (
15111518 < span className = "flex size-full items-center justify-center p-2 text-center text-xs text-muted-foreground" >
1512- < ChatMarkdownMediaUnavailableLabel alt = { props . alt } />
1519+ < ChatMarkdownMediaUnavailableLabel alt = { props . alt } detail = { props . unavailableDetail } />
15131520 </ span >
15141521 ) : src !== null ? (
15151522 < img
@@ -1676,6 +1683,13 @@ export const ChatMarkdownAssetImage = memo(function ChatMarkdownAssetImage(props
16761683 key = { JSON . stringify ( [ props . environmentId , props . resource , props . srcFragment ] ) }
16771684 src = { src }
16781685 sourceFailed = { assetUrl . _tag === "Failure" && fallbackSrc === undefined }
1686+ unavailableDetail = {
1687+ assetUrl . _tag === "Failure" &&
1688+ assetUrl . reason === "missing-file-access" &&
1689+ fallbackSrc === undefined
1690+ ? MISSING_FILE_ACCESS_MESSAGE
1691+ : undefined
1692+ }
16791693 alt = { props . alt }
16801694 copyMarkdown = { props . copyMarkdown }
16811695 standalone = { props . standalone ?? true }
0 commit comments