Skip to content

Commit 0b08666

Browse files
fix(web,mobile): host videos without file access explain why instead of offering a retry
A chat video pointing at a host file over a connection without file access showed "Video unavailable" with a Retry button that could never succeed. Show the existing missing-file-access reason, as images already do, and drop the retry for that case. Mobile inline tiles and the video link preview (Android modal and iOS native alert) get the same reason. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 670ea85 commit 0b08666

6 files changed

Lines changed: 42 additions & 15 deletions

File tree

‎apps/mobile/src/components/MediaVideoPlayer.tsx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ interface MediaVideoPlayerProps {
115115
readonly thumbnailKey: string;
116116
readonly thumbnailVisible?: boolean;
117117
readonly unavailable?: boolean;
118+
readonly unavailableDetail?: string | undefined;
118119
readonly expanded?: boolean;
119120
readonly autoPlay?: boolean;
120121
readonly paused?: boolean;
@@ -126,6 +127,9 @@ function MediaVideoPlayerContent(props: MediaVideoPlayerProps) {
126127
const [playbackUri, setPlaybackUri] = useState<string | null>(props.expanded ? props.uri : null);
127128
// Keep an opened player mounted while signing or reconnecting temporarily has no usable URL.
128129
if (playbackUri === null && props.expanded && props.uri !== null) setPlaybackUri(props.uri);
130+
const unavailableText = props.unavailableDetail
131+
? `Video unavailable. ${props.unavailableDetail}`
132+
: "Video unavailable";
129133

130134
return (
131135
<View
@@ -144,7 +148,9 @@ function MediaVideoPlayerContent(props: MediaVideoPlayerProps) {
144148
<MediaActionsMenu media={mediaActions} inModal={props.expanded} style={{ flex: 1 }}>
145149
<Pressable
146150
accessibilityRole="button"
147-
accessibilityLabel={`Play ${props.name}`}
151+
accessibilityLabel={
152+
props.unavailable ? `${props.name}. ${unavailableText}` : `Play ${props.name}`
153+
}
148154
accessibilityHint={
149155
mediaActions.actions.length > 0 ? "Touch and hold for media actions" : undefined
150156
}
@@ -163,7 +169,7 @@ function MediaVideoPlayerContent(props: MediaVideoPlayerProps) {
163169
/>
164170
) : null}
165171
{props.unavailable ? (
166-
<AppText className="text-sm text-white/80">Video unavailable</AppText>
172+
<AppText className="text-center text-sm text-white/80">{unavailableText}</AppText>
167173
) : props.uri === null ? (
168174
<AppActivityIndicator color="#ffffff" accessibilityLabel="Loading video" />
169175
) : (

‎apps/mobile/src/components/VideoPreviewModal.ios.tsx‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as Dialog from "./ui/Dialog";
22
import { useIsFocused } from "@react-navigation/native";
33
import { requireNativeModule } from "expo";
4+
import { MISSING_FILE_ACCESS_MESSAGE } from "@t3tools/client-runtime/state/assets";
45
import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
56
import { AsyncResult } from "effect/reactivity";
67
import { useEffect, useEffectEvent, useId, useState } from "react";
@@ -49,9 +50,11 @@ function NativeVideoPreview(props: {
4950
resource !== null && playbackUrl === null
5051
? preparedConnection._tag === "None"
5152
? "Reconnect to this environment and open the video again."
52-
: assetUrl._tag === "Failure"
53-
? "Could not load this video. Check the connection and try again."
54-
: null
53+
: assetUrl._tag === "Failure" && assetUrl.reason === "missing-file-access"
54+
? MISSING_FILE_ACCESS_MESSAGE
55+
: assetUrl._tag === "Failure"
56+
? "Could not load this video. Check the connection and try again."
57+
: null
5558
: null;
5659

5760
useEffect(() => Keyboard.dismiss(), []);

‎apps/mobile/src/components/VideoPreviewModal.tsx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useIsFocused } from "@react-navigation/native";
2+
import { MISSING_FILE_ACCESS_MESSAGE } from "@t3tools/client-runtime/state/assets";
23
import { videoMimeType } from "@t3tools/shared/video";
34
import { useEffect, useEffectEvent, useState } from "react";
45
import { Keyboard, Modal, Pressable, View } from "react-native";
@@ -29,6 +30,7 @@ interface PlaybackState {
2930
readonly uri: string | null;
3031
readonly resolvePlaybackUri?: () => Promise<string | null>;
3132
readonly unavailable: boolean;
33+
readonly unavailableDetail?: string | undefined;
3234
readonly error: string | null;
3335
readonly actionsSource: MediaActionsSource | undefined;
3436
}
@@ -49,6 +51,10 @@ function useMediaPlayback(source: MediaVideoPreviewSource): PlaybackState {
4951
uri === null &&
5052
environmentId !== null &&
5153
(connection._tag === "None" || asset._tag === "Failure"),
54+
unavailableDetail:
55+
asset._tag === "Failure" && asset.reason === "missing-file-access"
56+
? MISSING_FILE_ACCESS_MESSAGE
57+
: undefined,
5258
error: null,
5359
actionsSource: source.actionsSource,
5460
};
@@ -177,6 +183,7 @@ function OpenVideoPreviewModal(props: {
177183
name={props.name}
178184
thumbnailKey={props.thumbnailKey}
179185
unavailable={playback.unavailable}
186+
unavailableDetail={playback.unavailableDetail}
180187
paused={mediaActions.sharing}
181188
expanded
182189
autoPlay

‎apps/mobile/src/features/threads/ThreadMarkdownVideo.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { MISSING_FILE_ACCESS_MESSAGE } from "@t3tools/client-runtime/state/assets";
12
import { createContext, useContext } from "react";
23
import { MediaVideoPlayer } from "../../components/MediaVideoPlayer";
34
import { useAssetUrlState, useRefreshAssetUrl } from "../../state/assets";
@@ -39,6 +40,11 @@ export function ThreadMarkdownVideo(props: {
3940
thumbnailKey={thumbnailKey}
4041
thumbnailVisible={visible}
4142
unavailable={"resource" in source && asset._tag === "Failure"}
43+
unavailableDetail={
44+
asset._tag === "Failure" && asset.reason === "missing-file-access"
45+
? MISSING_FILE_ACCESS_MESSAGE
46+
: undefined
47+
}
4248
actionsSource={source.actionsSource}
4349
/>
4450
);

‎apps/web/src/components/chat/ChatMarkdownMedia.tsx‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ export function ChatMarkdownVideo(props: {
274274
readonly copyMarkdown: string | undefined;
275275
readonly originalUrl?: string | undefined;
276276
readonly sourceFailed?: boolean | undefined;
277+
readonly unavailableDetail?: string | undefined;
277278
readonly style?: CSSProperties | undefined;
278279
readonly mediaIdentity?: string | undefined;
279280
readonly actionsSource?: MediaActionSource | undefined;
@@ -284,6 +285,7 @@ export function ChatMarkdownVideo(props: {
284285
key={props.mediaIdentity ?? props.copyMarkdown ?? props.src}
285286
src={props.src}
286287
sourceFailed={props.sourceFailed}
288+
unavailableDetail={props.unavailableDetail}
287289
label={props.alt}
288290
originalUrl={props.originalUrl}
289291
style={props.style}
@@ -385,6 +387,11 @@ export const ChatMarkdownAssetImage = memo(function ChatMarkdownAssetImage(props
385387
: undefined;
386388
const relativePath = reference?.kind === "file" ? reference.relativePath : undefined;
387389
const fallbackSrc = assetUrl._tag === "Failure" ? props.fallbackSrc : undefined;
390+
const missingFileAccess =
391+
assetUrl._tag === "Failure" &&
392+
assetUrl.reason === "missing-file-access" &&
393+
fallbackSrc === undefined;
394+
const unavailableDetail = missingFileAccess ? MISSING_FILE_ACCESS_MESSAGE : undefined;
388395
const src =
389396
assetUrl._tag === "Success"
390397
? assetUrl.url + (props.srcFragment ?? "")
@@ -426,12 +433,14 @@ export const ChatMarkdownAssetImage = memo(function ChatMarkdownAssetImage(props
426433
<ChatMarkdownVideo
427434
src={src}
428435
sourceFailed={assetUrl._tag === "Failure" && fallbackSrc === undefined}
436+
unavailableDetail={unavailableDetail}
429437
alt={props.alt}
430438
copyMarkdown={props.copyMarkdown}
431439
originalUrl={props.originalUrl}
432440
style={props.style}
433441
mediaIdentity={JSON.stringify([props.environmentId, props.resource, props.srcFragment])}
434-
onRetry={refreshAssetUrl}
442+
// Re-signing cannot grant the file access this connection lacks.
443+
onRetry={missingFileAccess ? undefined : refreshAssetUrl}
435444
actionsSource={actionsSource}
436445
/>
437446
);
@@ -442,13 +451,7 @@ export const ChatMarkdownAssetImage = memo(function ChatMarkdownAssetImage(props
442451
key={JSON.stringify([props.environmentId, props.resource, props.srcFragment])}
443452
src={src}
444453
sourceFailed={assetUrl._tag === "Failure" && fallbackSrc === undefined}
445-
unavailableDetail={
446-
assetUrl._tag === "Failure" &&
447-
assetUrl.reason === "missing-file-access" &&
448-
fallbackSrc === undefined
449-
? MISSING_FILE_ACCESS_MESSAGE
450-
: undefined
451-
}
454+
unavailableDetail={unavailableDetail}
452455
alt={props.alt}
453456
copyMarkdown={props.copyMarkdown}
454457
standalone={props.standalone ?? true}

‎apps/web/src/components/media/MediaVideoPlayer.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface MediaVideoPlayerProps {
1313
readonly src: string | null;
1414
readonly label: string;
1515
readonly sourceFailed?: boolean | undefined;
16+
readonly unavailableDetail?: string | undefined;
1617
readonly originalUrl?: string | undefined;
1718
readonly revision?: string | null | undefined;
1819
readonly preload?: "visible" | "metadata" | undefined;
@@ -31,6 +32,7 @@ export function MediaVideoPlayer({
3132
src: latestSrc,
3233
label,
3334
sourceFailed = false,
35+
unavailableDetail,
3436
originalUrl,
3537
revision = null,
3638
preload = "visible",
@@ -140,9 +142,9 @@ export function MediaVideoPlayer({
140142
stateClassName,
141143
)}
142144
>
143-
<span className="inline-flex items-center gap-1.5">
145+
<span data-thread-find-ignore className="inline-flex items-center gap-1.5">
144146
<TriangleAlertIcon aria-hidden className="size-3.5 shrink-0" />
145-
Video unavailable{label ? ` · ${label}` : ""}
147+
{["Video unavailable", label, unavailableDetail].filter(Boolean).join(" · ")}
146148
</span>
147149
<span className="flex flex-wrap items-center justify-center gap-2">
148150
{latestSrc !== null || onRetry ? (

0 commit comments

Comments
 (0)