@devries-cameron20 / t3code-1 / commits / ee7f8dc02c
Fork 0

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

fix(web): open remote preview files in VS Code (#19898)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

fixfon committed Oct 20, 2026 at 07:16 UTC ee7f8dc02cbd61ceb047736d9cfca979c5e59fc5
6 files changed +89 -4
apps/web/src/components/chat/OpenInPicker.tsx
+3
@@ -208,6 +208,7 @@ export const OpenInPicker = memo(function OpenInPicker({
208 keybindings,
209 availableEditors,
210 openInCwd,
211 + openInCwdIsFile = false,
212 presentation = "toolbar",
213 compact = false,
214 enableShortcut = true,
@@ -218,6 +219,7 @@ export const OpenInPicker = memo(function OpenInPicker({
219 keybindings: ResolvedKeybindingsConfig;
220 availableEditors: ReadonlyArray<EditorId>;
221 openInCwd: string | null;
222 + openInCwdIsFile?: boolean;
223 presentation?: "toolbar" | "menu";
224 compact?: boolean;
225 enableShortcut?: boolean;
@@ -251,6 +253,7 @@ export const OpenInPicker = memo(function OpenInPicker({
253 editor,
254 host: remote.host.host,
255 absolutePath: openInCwd,
256 + isFile: openInCwdIsFile,
257 });
258 if (url === undefined) return;
259 // Only record hint-seen/preferred when the shell actually accepted
apps/web/src/components/files/FilePreviewPanel.tsx
+1
@@ -1243,6 +1243,7 @@ export default function FilePreviewPanel({
1243 availableEditors={availableEditors}
1244 enableShortcut={openInShortcutEnabled}
1245 openInCwd={absolutePath}
1246 + openInCwdIsFile={file.isFile}
1247 compact
1248 revealFileManager={revealsInFileManager}
1249 />
apps/web/src/components/files/projectFilesQueryState.test.tsx
+46
@@ -8,6 +8,7 @@ import {
8 } from "@t3tools/contracts";
9 import * as Cause from "effect/Cause";
10 import * as Effect from "effect/Effect";
11 +import * as Option from "effect/Option";
12 import * as Schema from "effect/Schema";
13 import { AsyncResult, Atom, AtomRegistry } from "effect/reactivity";
14 import { beforeEach, describe, expect, it, vi } from "vite-plus/test";
@@ -506,6 +507,51 @@ describe("project query refresh", () => {
507 }
508 });
509
510 + it("confirms files from reads and preserves that identity until a definitive folder result", () => {
511 + const contents = file("# readme");
512 + const success = AsyncResult.success(contents);
513 + const failure = (kind: ProjectReadFileError["failure"], cached = false) =>
514 + AsyncResult.failure(
515 + Cause.fail(
516 + new ProjectReadFileError({ cwd: "/repo", relativePath: "src/preview.ts", failure: kind }),
517 + ),
518 + { previousSuccess: cached ? Option.some(success) : Option.none() },
519 + );
520 + const states = [
521 + ["initial read", AsyncResult.initial(true), false, false, null],
522 + ["unknown path", failure("operation_failed"), false, false, null],
523 + ["binary file", failure("binary_file"), true, false, null],
524 + ["read success", success, true, false, contents],
525 + ["pending refresh", AsyncResult.waiting(success), true, false, contents],
526 + ["transient refresh failure", failure("operation_failed", true), true, false, contents],
527 + ["became a folder", failure("path_not_file", true), false, true, contents],
528 + ] as const;
529 + const readAtom = Atom.make<
530 + AsyncResult.AsyncResult<ProjectReadFileResult, ProjectReadFileError>
531 + >(AsyncResult.initial(true));
532 + const registry = AtomRegistry.make();
533 + const unmount = registry.mount(readAtom);
534 + projectMocks.readFile.mockReturnValue(readAtom);
535 + projectMocks.optimisticFile.mockReturnValue(Atom.make(null));
536 + atomHooks.registry = registry;
537 +
538 + try {
539 + for (const [label, result, isFile, isNotFile, data] of states) {
540 + registry.set(readAtom, result);
541 + reactHooks.beginRender();
542 + const query = useProjectFileQuery(environmentId, "/repo", "src/preview.ts");
543 + expect(query.isFile, label).toBe(isFile);
544 + expect(query.isNotFile, label).toBe(isNotFile);
545 + expect(query.data, label).toBe(data);
546 + expect(query.isPending, label).toBe(result.waiting);
547 + }
548 + } finally {
549 + unmount();
550 + registry.dispose();
551 + atomHooks.registry = null;
552 + }
553 + });
554 +
555 it("retains decoded read failure context for the connected environment", async () => {
556 const error = decodeReadError({
557 _tag: "ProjectReadFileError",
apps/web/src/components/files/projectFilesQueryState.ts
+9 -3
@@ -50,6 +50,7 @@ interface ProjectQueryState<A> {
50 interface ProjectFileQueryState extends ProjectQueryState<ProjectReadFileResult> {
51 readonly readError: ProjectReadFileError | null;
52 readonly isNotFile: boolean;
53 + readonly isFile: boolean;
54 }
55
56 function getProjectEntriesQueryAtom(
@@ -258,16 +259,19 @@ export function useProjectFileQuery(
259 const result = useAtomValue(atom);
260 const refreshAtom = useAtomRefresh(atom);
261 const refresh = () => refreshAtom();
261 - const data = Option.getOrNull(AsyncResult.value(result));
262 const optimisticResult = useAtomValue(
263 optimisticFileAtom(environmentId, cwd, relativePath ?? EMPTY_PROJECT_FILE_PATH),
264 );
265 const optimisticFile = relativePath === null ? null : optimisticResult;
266 const cause = failureCause(result);
267 const readError = isProjectReadFileError(cause) ? cause : null;
268 + const data = canReadFiles
269 + ? (optimisticFile?.data ?? Option.getOrNull(AsyncResult.value(result)))
270 + : null;
271 + const isNotFile = readError?.failure === "path_not_file";
272
273 return {
270 - data: canReadFiles ? (optimisticFile?.data ?? data) : null,
274 + data,
275 error:
276 !isQueryEnabled || fileAccess.isPending
277 ? null
@@ -276,7 +280,9 @@ export function useProjectFileQuery(
280 : (fileAccess.error ?? "This connection cannot read host files."),
281 isPending: isQueryEnabled && (fileAccess.isPending || result.waiting),
282 readError,
279 - isNotFile: readError?.failure === "path_not_file",
283 + isNotFile,
284 + // A folder error overrides cached contents retained across failed refreshes.
285 + isFile: !isNotFile && (data !== null || readError?.failure === "binary_file"),
286 refresh,
287 };
288 }
apps/web/src/remoteOpen.test.ts
+27
@@ -177,6 +177,33 @@ describe("buildRemoteOpenUrl", () => {
177 );
178 });
179
180 + it("adds a file position only for confirmed VS Code-family file targets", () => {
181 + const targets = [
182 + ["vscode", true, "vscode://vscode-remote/ssh-remote+sol/tmp/my%20file.md:1:1"],
183 + ["cursor", true, "cursor://vscode-remote/ssh-remote+sol/tmp/my%20file.md:1:1"],
184 + ["vscode", false, "vscode://vscode-remote/ssh-remote+sol/tmp/my%20file.md"],
185 + ["vscode", undefined, "vscode://vscode-remote/ssh-remote+sol/tmp/my%20file.md"],
186 + ["zed", true, "zed://ssh/sol/tmp/my%20file.md"],
187 + [
188 + "pycharm",
189 + true,
190 + "jetbrains://gateway/ssh/environment?h=sol&launchIde=true&ideHint=PY&projectHint=%2Ftmp%2Fmy+file.md",
191 + ],
192 + ] as const;
193 +
194 + for (const [editor, isFile, expected] of targets) {
195 + expect(
196 + buildRemoteOpenUrl({
197 + editor,
198 + host: "sol",
199 + absolutePath: "/tmp/my file.md",
200 + ...(isFile === undefined ? {} : { isFile }),
201 + }),
202 + `${editor}, isFile=${isFile}`,
203 + ).toBe(expected);
204 + }
205 + });
206 +
207 it("returns undefined for editors without remote support", () => {
208 expect(buildRemoteOpenUrl({ editor: "kiro", host: "sol", absolutePath: "/tmp/x" })).toBe(
209 undefined,
packages/contracts/src/editor.ts
+3 -1
@@ -181,6 +181,7 @@ export const buildRemoteOpenUrl = (input: {
181 readonly editor: EditorId;
182 readonly host: string;
183 readonly absolutePath: string;
184 + readonly isFile?: boolean;
185 }): string | undefined => {
186 const scheme = remoteSchemeForEditor(input.editor);
187 if (scheme === undefined) {
@@ -210,7 +211,8 @@ export const buildRemoteOpenUrl = (input: {
211 return `${scheme}://ssh/${encodedHost}${encodedZedPath}`;
212 }
213 const encodedPath = rootedPath.split("/").map(encodeURIComponent).join("/");
213 - return `${scheme}://vscode-remote/ssh-remote+${encodedHost}${encodedPath}`;
214 + // VS Code opens a bare vscode-remote path as a folder; a trailing position makes it open the file.
215 + return `${scheme}://vscode-remote/ssh-remote+${encodedHost}${encodedPath}${input.isFile ? ":1:1" : ""}`;
216 };
217
218 export const RemoteOpenTargetKind = Schema.Literals(["tailscale", "mdns"]);