@devries-cameron20 / t3code Mirror · read-only / commits / cf382b0c44
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 16:00 UTC

fix(web,mobile): explain missing file access for host videos (#24637)

Julius Marminge committed Nov 13, 2026 at 16:26 UTC cf382b0c44eb619cfa7f14a8ec279fd8138c90f2
6 files changed +64 -12
apps/mobile/src/components/MediaVideoPlayer.tsx
+8 -2
@@ -138,6 +138,7 @@ interface MediaVideoPlayerProps {
138 readonly thumbnailVisible?: boolean;
139 readonly visible?: boolean;
140 readonly unavailable?: boolean;
141 + readonly unavailableDetail?: string | undefined;
142 readonly expanded?: boolean;
143 /** Fill the parent and size the frame to the video's shape instead of a fixed 16:9 slot. */
144 readonly fitToVideo?: boolean;
@@ -154,6 +155,9 @@ function MediaVideoPlayerContent(props: MediaVideoPlayerProps) {
155 const [playbackUri, setPlaybackUri] = useState<string | null>(props.expanded ? props.uri : null);
156 // Keep an opened player mounted while signing or reconnecting temporarily has no usable URL.
157 if (playbackUri === null && props.expanded && props.uri !== null) setPlaybackUri(props.uri);
158 + const unavailableText = props.unavailableDetail
159 + ? `Video unavailable. ${props.unavailableDetail}`
160 + : "Video unavailable";
161 const [videoSize, setVideoSize] = useState<{ width: number; height: number } | null>(null);
162 const [bounds, setBounds] = useState<{ width: number; height: number } | null>(null);
163 const sizeSource = props.fitToVideo && isFocused && videoSize === null ? props.uri : null;
@@ -201,7 +205,9 @@ function MediaVideoPlayerContent(props: MediaVideoPlayerProps) {
205 <MediaActionsMenu media={mediaActions} inModal={props.expanded} style={{ flex: 1 }}>
206 <Pressable
207 accessibilityRole="button"
204 - accessibilityLabel={`Play ${props.name}`}
208 + accessibilityLabel={
209 + props.unavailable ? `${props.name}. ${unavailableText}` : `Play ${props.name}`
210 + }
211 accessibilityHint={
212 mediaActions.actions.length > 0 ? "Touch and hold for media actions" : undefined
213 }
@@ -223,7 +229,7 @@ function MediaVideoPlayerContent(props: MediaVideoPlayerProps) {
229 />
230 ) : null}
231 {props.unavailable ? (
226 - <AppText className="text-sm text-white/80">Video unavailable</AppText>
232 + <AppText className="text-center text-sm text-white/80">{unavailableText}</AppText>
233 ) : props.uri === null ? (
234 <AppActivityIndicator color="#ffffff" accessibilityLabel="Loading video" />
235 ) : (
apps/mobile/src/components/ui/VideoPreviewModal.android.tsx
+7
@@ -1,3 +1,4 @@
1 +import { MISSING_FILE_ACCESS_MESSAGE } from "@t3tools/client-runtime/state/assets";
2 import { videoMimeType } from "@t3tools/shared/video";
3 import { Modal, Pressable, View } from "react-native";
4 import { useSafeAreaInsets } from "react-native-safe-area-context";
@@ -26,6 +27,7 @@ interface PlaybackState {
27 readonly uri: string | null;
28 readonly resolvePlaybackUri?: () => Promise<string | null>;
29 readonly unavailable: boolean;
30 + readonly unavailableDetail?: string | undefined;
31 readonly error: string | null;
32 readonly actionsSource: MediaActionsSource | undefined;
33 }
@@ -46,6 +48,10 @@ function useMediaPlayback(source: MediaVideoPreviewSource): PlaybackState {
48 uri === null &&
49 environmentId !== null &&
50 (connection._tag === "None" || asset._tag === "Failure"),
51 + unavailableDetail:
52 + asset._tag === "Failure" && asset.reason === "missing-file-access"
53 + ? MISSING_FILE_ACCESS_MESSAGE
54 + : undefined,
55 error: null,
56 actionsSource: source.actionsSource,
57 };
@@ -134,6 +140,7 @@ function OpenVideoPreviewModal(props: {
140 name={props.name}
141 thumbnailKey={props.thumbnailKey}
142 unavailable={playback.unavailable}
143 + unavailableDetail={playback.unavailableDetail}
144 paused={mediaActions.sharing}
145 expanded
146 autoPlay
apps/mobile/src/features/threads/ThreadMarkdownVideo.tsx
+6
@@ -1,3 +1,4 @@
1 +import { MISSING_FILE_ACCESS_MESSAGE } from "@t3tools/client-runtime/state/assets";
2 import { createContext, useContext } from "react";
3 import { MediaVideoPlayer } from "../../components/MediaVideoPlayer";
4 import { useAssetUrlState, useRefreshAssetUrl } from "../../state/assets";
@@ -43,6 +44,11 @@ export function ThreadMarkdownVideo(props: {
44 visible={visible}
45 onPlaybackStart={props.onPlaybackStart}
46 unavailable={"resource" in source && asset._tag === "Failure"}
47 + unavailableDetail={
48 + asset._tag === "Failure" && asset.reason === "missing-file-access"
49 + ? MISSING_FILE_ACCESS_MESSAGE
50 + : undefined
51 + }
52 actionsSource={source.actionsSource}
53 borderRadius={props.borderRadius}
54 />
apps/web/src/components/ChatMarkdown.browser.test.tsx
+28
@@ -1,3 +1,4 @@
1 +import { MISSING_FILE_ACCESS_MESSAGE } from "@t3tools/client-runtime/state/assets";
2 import { EnvironmentId, ThreadId } from "@t3tools/contracts";
3 import { AsyncResult } from "effect/reactivity";
4 import { type ReactElement } from "react";
@@ -74,6 +75,17 @@ vi.mock(import("../state/session"), async (original) => {
75 readEnvironmentScope: hasScope as never,
76 };
77 });
78 +const deniedEnvironmentId = vi.hoisted(() => "denied-environment");
79 +vi.mock(import("../state/filesystem"), async (original) => {
80 + const actual = await original();
81 + return {
82 + ...actual,
83 + useFilesystemReadAccess: ((environmentId: EnvironmentId | null) =>
84 + environmentId === deniedEnvironmentId
85 + ? { canReadFiles: false, isPending: false, error: null }
86 + : actual.useFilesystemReadAccess(environmentId)) as never,
87 + };
88 +});
89 vi.mock(import("../remoteOpen"), async (original) => ({
90 ...(await original()),
91 useRemoteOpenResolution: () => ({ state: { mode: "local-exec" }, isResolved: true }) as never,
@@ -742,3 +754,19 @@ describe("ChatMarkdown Windows file links", () => {
754 }
755 });
756 });
757 +
758 +describe("ChatMarkdown host media", () => {
759 + it("explains a host video the connection cannot read instead of offering a retry", async () => {
760 + setup();
761 + await using screen = await renderText("![Demo](/tmp/demo.mp4)", {
762 + threadRef: {
763 + environmentId: EnvironmentId.make(deniedEnvironmentId),
764 + threadId: ThreadId.make("thread"),
765 + },
766 + });
767 + await vi.waitFor(() =>
768 + expect(screen.container.textContent).toContain(MISSING_FILE_ACCESS_MESSAGE),
769 + );
770 + expect(screen.container.textContent).not.toContain("Retry video");
771 + });
772 +});
apps/web/src/components/chat/ChatMarkdownMedia.tsx
+11 -8
@@ -297,6 +297,7 @@ export function ChatMarkdownVideo(props: {
297 readonly copyMarkdown: string | undefined;
298 readonly originalUrl?: string | undefined;
299 readonly sourceFailed?: boolean | undefined;
300 + readonly unavailableDetail?: string | undefined;
301 readonly style?: CSSProperties | undefined;
302 readonly mediaIdentity?: string | undefined;
303 readonly actionsSource?: MediaActionSource | undefined;
@@ -307,6 +308,7 @@ export function ChatMarkdownVideo(props: {
308 key={props.mediaIdentity ?? props.copyMarkdown ?? props.src}
309 src={props.src}
310 sourceFailed={props.sourceFailed}
311 + unavailableDetail={props.unavailableDetail}
312 label={props.alt}
313 originalUrl={props.originalUrl}
314 style={props.style}
@@ -413,6 +415,11 @@ export const ChatMarkdownAssetImage = memo(function ChatMarkdownAssetImage(props
415 );
416 const refreshAssetUrl = useAssetUrlRefresh(props.environmentId, resource);
417 const fallbackSrc = assetUrl._tag === "Failure" ? props.fallbackSrc : undefined;
418 + const missingFileAccess =
419 + assetUrl._tag === "Failure" &&
420 + assetUrl.reason === "missing-file-access" &&
421 + fallbackSrc === undefined;
422 + const unavailableDetail = missingFileAccess ? MISSING_FILE_ACCESS_MESSAGE : undefined;
423 const src =
424 assetUrl._tag === "Success"
425 ? assetUrl.url + (props.srcFragment ?? "")
@@ -444,12 +451,14 @@ export const ChatMarkdownAssetImage = memo(function ChatMarkdownAssetImage(props
451 <ChatMarkdownVideo
452 src={src}
453 sourceFailed={assetUrl._tag === "Failure" && fallbackSrc === undefined}
454 + unavailableDetail={unavailableDetail}
455 alt={props.alt}
456 copyMarkdown={props.copyMarkdown}
457 originalUrl={props.originalUrl}
458 style={props.style}
459 mediaIdentity={JSON.stringify([props.environmentId, props.resource, props.srcFragment])}
452 - onRetry={refreshAssetUrl}
460 + // Re-signing cannot grant the file access this connection lacks.
461 + onRetry={missingFileAccess ? undefined : refreshAssetUrl}
462 actionsSource={actionsSource}
463 />
464 );
@@ -460,13 +469,7 @@ export const ChatMarkdownAssetImage = memo(function ChatMarkdownAssetImage(props
469 key={JSON.stringify([props.environmentId, props.resource, props.srcFragment])}
470 src={src}
471 sourceFailed={assetUrl._tag === "Failure" && fallbackSrc === undefined}
463 - unavailableDetail={
464 - assetUrl._tag === "Failure" &&
465 - assetUrl.reason === "missing-file-access" &&
466 - fallbackSrc === undefined
467 - ? MISSING_FILE_ACCESS_MESSAGE
468 - : undefined
469 - }
472 + unavailableDetail={unavailableDetail}
473 alt={props.alt}
474 copyMarkdown={props.copyMarkdown}
475 standalone={props.standalone ?? true}
apps/web/src/components/media/MediaVideoPlayer.tsx
+4 -2
@@ -14,6 +14,7 @@ interface MediaVideoPlayerProps {
14 readonly src: string | null;
15 readonly label: string;
16 readonly sourceFailed?: boolean | undefined;
17 + readonly unavailableDetail?: string | undefined;
18 readonly originalUrl?: string | undefined;
19 readonly revision?: string | null | undefined;
20 readonly preload?: "visible" | "metadata" | undefined;
@@ -32,6 +33,7 @@ export function MediaVideoPlayer({
33 src: latestSrc,
34 label,
35 sourceFailed = false,
36 + unavailableDetail,
37 originalUrl,
38 revision = null,
39 preload = "visible",
@@ -136,9 +138,9 @@ export function MediaVideoPlayer({
138 stateClassName,
139 )}
140 >
139 - <span className="inline-flex items-center gap-1.5">
141 + <span data-thread-find-ignore className="inline-flex items-center gap-1.5">
142 <TriangleAlertIcon aria-hidden className="size-3.5 shrink-0" />
141 - Video unavailable{label ? ` · ${label}` : ""}
143 + {["Video unavailable", label, unavailableDetail].filter(Boolean).join(" · ")}
144 </span>
145 <span className="flex flex-wrap items-center justify-center gap-2">
146 {latestSrc !== null || onRetry ? (