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

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

fix(web): allow folder references on saved local desktop servers (#27785)

Co-authored-by: PR Batch Tester <agent@local.test> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

shivam committed Nov 2, 2026 at 07:06 UTC e925dd681904f8a1ead0502ecca3f65f5bc28146
3 files changed +116 -7
apps/web/src/components/chat/ChatComposer.tsx
+4 -2
@@ -261,7 +261,7 @@ import { useMediaQuery } from "../../hooks/useMediaQuery";
261 import { useSoftwareKeyboardOpen } from "../../hooks/useSoftwareKeyboardOpen";
262 import { useStableCallback } from "../../hooks/useStableCallback";
263 import { usePanelAnimationSettings } from "../../panelAnimations";
264 -import { readEnvironmentScope } from "../../state/session";
264 +import { readEnvironmentScope, readPreparedConnection } from "../../state/session";
265 import type { ReviewCommentContext } from "../../reviewCommentContext";
266 import { useComposerRestingTransition } from "./useComposerRestingTransition";
267 import { ComposerCommandMenuLayer } from "./ComposerCommandMenuLayer";
@@ -2522,11 +2522,13 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
2522 localEnvironmentDisabled: isLocalEnvironmentDisabled(),
2523 environmentId,
2524 primaryEnvironmentId,
2525 + connection: readPreparedConnection(environmentId),
2526 + isDesktopRenderer: window.desktopBridge !== undefined,
2527 });
2528 if (target === "remote") {
2529 toastManager.add({
2530 type: "error",
2529 - title: "Folders can only be referenced in the local desktop environment",
2531 + title: "Folders can only be referenced on a server running on this computer",
2532 });
2533 return;
2534 }
apps/web/src/components/chat/folderDrop.test.ts new
+82
@@ -0,0 +1,82 @@
1 +import {
2 + BearerConnectionTarget,
3 + RelayConnectionTarget,
4 + SshConnectionTarget,
5 +} from "@t3tools/client-runtime/connection";
6 +import { EnvironmentId } from "@t3tools/contracts";
7 +import { describe, expect, it } from "vite-plus/test";
8 +
9 +import { folderDropTarget } from "./folderDrop";
10 +
11 +const environmentId = EnvironmentId.make("saved-local");
12 +const base = { environmentId, label: "server" };
13 +const savedServer = (httpBaseUrl: string, connectionId = "saved-1") => ({
14 + target: new BearerConnectionTarget({ ...base, connectionId }),
15 + httpBaseUrl,
16 +});
17 +const thinClient = {
18 + localEnvironmentDisabled: true,
19 + environmentId,
20 + primaryEnvironmentId: null,
21 + isDesktopRenderer: true,
22 +};
23 +
24 +describe("folderDropTarget", () => {
25 + it.each([
26 + [
27 + "the bundled primary",
28 + {
29 + ...thinClient,
30 + localEnvironmentDisabled: false,
31 + primaryEnvironmentId: environmentId,
32 + connection: null,
33 + },
34 + "local",
35 + ],
36 + [
37 + "a saved loopback server on desktop",
38 + { ...thinClient, connection: savedServer("http://127.0.0.1:3773") },
39 + "local",
40 + ],
41 + [
42 + "a saved LAN server",
43 + { ...thinClient, connection: savedServer("http://192.168.1.20:3773") },
44 + "remote",
45 + ],
46 + [
47 + "a saved loopback server in a browser",
48 + { ...thinClient, isDesktopRenderer: false, connection: savedServer("http://localhost:3773") },
49 + "remote",
50 + ],
51 + [
52 + "a desktop WSL backend",
53 + { ...thinClient, connection: savedServer("http://127.0.0.1:3774", "local:wsl-ubuntu") },
54 + "remote",
55 + ],
56 + [
57 + "an SSH forward on loopback",
58 + {
59 + ...thinClient,
60 + connection: {
61 + target: new SshConnectionTarget({ ...base, connectionId: "ssh-1" }),
62 + httpBaseUrl: "http://127.0.0.1:41000",
63 + },
64 + },
65 + "remote",
66 + ],
67 + [
68 + "a relay connection",
69 + {
70 + ...thinClient,
71 + connection: {
72 + target: new RelayConnectionTarget(base),
73 + httpBaseUrl: "https://relay.t3.codes",
74 + },
75 + },
76 + "remote",
77 + ],
78 + ["an unprepared connection", { ...thinClient, connection: null }, "remote"],
79 + ] as const)("targets %s", (_name, input, expected) => {
80 + expect(folderDropTarget(input)).toBe(expected);
81 + });
82 +});
apps/web/src/components/chat/folderDrop.ts
+30 -5
@@ -1,18 +1,43 @@
1 +import type { PreparedConnection } from "@t3tools/client-runtime/connection";
2 import type { EnvironmentId } from "@t3tools/contracts";
3
4 +import { isDesktopLocalConnectionTarget } from "~/connection/desktopLocal";
5 +import { isLoopbackHostname } from "~/environments/primary/target";
6 +
7 export function folderDropTarget(input: {
8 localEnvironmentDisabled: boolean;
9 environmentId: EnvironmentId;
10 primaryEnvironmentId: EnvironmentId | null;
11 + connection: Pick<PreparedConnection, "target" | "httpBaseUrl"> | null;
12 + isDesktopRenderer: boolean;
13 }): "local" | "remote" {
14 if (
9 - input.localEnvironmentDisabled ||
10 - input.primaryEnvironmentId === null ||
11 - input.environmentId !== input.primaryEnvironmentId
15 + !input.localEnvironmentDisabled &&
16 + input.primaryEnvironmentId !== null &&
17 + input.environmentId === input.primaryEnvironmentId
18 ) {
13 - return "remote";
19 + return "local";
20 + }
21 + return input.isDesktopRenderer &&
22 + input.connection !== null &&
23 + isSavedLoopbackConnection(input.connection)
24 + ? "local"
25 + : "remote";
26 +}
27 +
28 +// A direct saved connection to loopback shares the desktop's filesystem; WSL backends and SSH forwards do not.
29 +function isSavedLoopbackConnection({
30 + target,
31 + httpBaseUrl,
32 +}: Pick<PreparedConnection, "target" | "httpBaseUrl">): boolean {
33 + if (target._tag !== "BearerConnectionTarget" || isDesktopLocalConnectionTarget(target)) {
34 + return false;
35 + }
36 + try {
37 + return isLoopbackHostname(new URL(httpBaseUrl).hostname);
38 + } catch {
39 + return false;
40 }
15 - return "local";
41 }
42
43 export function resolveDroppedFolderPath(