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 22, 08:15 UTC
perf(mobile): text files open in half the time on a remote host (#27850)
Cameron Chisholm committed
Nov 1, 2026 at 02:43 UTC
a62452a24bbeec32e67bf867fe433be518f09f17
3 files changed
+35
-9
apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx
+7
-9
@@ -68,6 +68,7 @@ import {
68
isMarkdownPreviewFile,
69
isSvgImagePreviewFile,
70
isVideoPreviewFile,
71
+ needsWorkspaceFileContents,
72
} from "./filePath";
73
import { useWorkspaceFileAssetUrlState } from "./workspaceFileAssetUrl";
74
@@ -707,15 +708,12 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
708
const handleRetryPreview = () => {
709
void assetPreview.refresh().finally(() => setPreviewRevision((current) => current + 1));
710
};
710
- const needsFileContents =
711
- !metadataPending &&
712
- directoryPath === null &&
713
- relativePath !== null &&
714
- !isVideoFile &&
715
- !isAudioFile &&
716
- (resolvedActiveMode === "source" ||
717
- isMarkdownPreviewFile(relativePath) ||
718
- filePreviewDelimiter({ name: relativePath }) !== null);
711
+ // Metadata is needed only to distinguish directories; file contents can load concurrently.
712
+ const needsFileContents = needsWorkspaceFileContents({
713
+ relativePath,
714
+ metadataKind: metadata.data?.kind,
715
+ activeMode: resolvedActiveMode,
716
+ });
717
const fileQuery = useEnvironmentQuery(
718
canReadFiles &&
719
environmentId !== null &&
apps/mobile/src/features/files/filePath.test.ts
+9
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vite-plus/test";
2
3
import {
4
fileRoutePathSegments,
5
+ needsWorkspaceFileContents,
6
resolveFileLinkPath,
7
resolveWorkspaceRelativeFilePath,
8
} from "./filePath";
@@ -49,3 +50,11 @@ describe("resolveWorkspaceRelativeFilePath", () => {
50
expect(resolveWorkspaceRelativeFilePath(null, "/repo/main.ts")).toBeNull();
51
});
52
});
53
+
54
+describe("needsWorkspaceFileContents", () => {
55
+ it("reads a text file while its metadata is still pending, but not a directory", () => {
56
+ const input = { relativePath: "package.json", activeMode: "source" } as const;
57
+ expect(needsWorkspaceFileContents({ ...input, metadataKind: undefined })).toBe(true);
58
+ expect(needsWorkspaceFileContents({ ...input, metadataKind: "directory" })).toBe(false);
59
+ });
60
+});
apps/mobile/src/features/files/filePath.ts
+19
@@ -1,3 +1,5 @@
1
+import type { FilesystemEntryMetadata } from "@t3tools/contracts";
2
+import { filePreviewDelimiter } from "@t3tools/shared/delimitedPreview";
3
import { joinPath, resolvePathLinkTarget } from "@t3tools/shared/fileLinks";
4
import {
5
isWorkspaceAudioPreviewPath,
@@ -109,6 +111,23 @@ export function isMarkdownPreviewFile(path: string): boolean {
111
return /\.(?:md|mdx)$/i.test(path.split(/[?#]/, 1)[0] ?? "");
112
}
113
114
+export function needsWorkspaceFileContents(input: {
115
+ readonly relativePath: string | null;
116
+ readonly metadataKind: FilesystemEntryMetadata["kind"] | undefined;
117
+ readonly activeMode: "preview" | "source";
118
+}): boolean {
119
+ const path = input.relativePath;
120
+ return (
121
+ input.metadataKind !== "directory" &&
122
+ path !== null &&
123
+ !isVideoPreviewFile(path) &&
124
+ !isAudioPreviewFile(path) &&
125
+ (input.activeMode === "source" ||
126
+ isMarkdownPreviewFile(path) ||
127
+ filePreviewDelimiter({ name: path }) !== null)
128
+ );
129
+}
130
+
131
export function fileHeaderSubtitle(projectName: string, relativePath: string): string {
132
const parentDir = relativePath.slice(
133
0,