The best way to control Claude Code, Codex and more from any computer or phone
fix(desktop,web): Open in runs locally for a background service sharing the desktop's T3 home (#21661)
Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Kinan Lakhdar committed
Nov 11, 2026 at 12:02 UTC
52d621a6f10f5a80ec433e3f3515eafbeabac74b
10 files changed
+114
-22
apps/web/src/components/ChatMarkdown.tsx
+3
@@ -152,6 +152,8 @@ import {
152
import { isMarkdownFileLinkLabel } from "@t3tools/shared/markdownLinks";
153
import { isElectron } from "../env";
154
import { readLocalApi } from "../localApi";
155
+import { appAtomRegistry } from "../rpc/atomRegistry";
156
+import { hostEnvironmentIdAtom } from "../state/primaryEnvironment";
157
import { cn } from "../lib/utils";
158
import { resolveRemoteOpenState, useRemoteOpenResolution } from "../remoteOpen";
159
import { useRightPanelStore } from "../rightPanelStore";
@@ -619,6 +621,7 @@ function useChatMarkdownState({
621
sshTarget: null,
622
remoteOpenTargets: undefined,
623
isDesktopRenderer: window.desktopBridge !== undefined,
624
+ hostEnvironmentId: appAtomRegistry.get(hostEnvironmentIdAtom),
625
}).mode !== "local-exec"
626
) {
627
description = `The file was not found on ${target.label} at ${error.checkedPath ?? error.resource.path}.`;
apps/web/src/components/ChatView.logic.test.ts
+23
@@ -1,3 +1,4 @@
1
+import { shouldShowOpenInPicker } from "./chat/OpenInPicker.logic";
2
import {
3
boundAttachmentIds,
4
buildExpiredTerminalContextToastCopy,
@@ -1216,3 +1217,25 @@ describe("deriveAvailableRevertTurnCounts", () => {
1217
expect(deriveAvailableRevertTurnCounts(null).size).toBe(0);
1218
});
1219
});
1220
+
1221
+describe("Open in for the host environment", () => {
1222
+ it("shows both local environments when the primary has a separate WSL home", () => {
1223
+ const primaryEnvironmentId = EnvironmentId.make("wsl");
1224
+ const hostEnvironmentId = EnvironmentId.make("host");
1225
+ for (const [activeThreadEnvironmentId, visible] of [
1226
+ [primaryEnvironmentId, true],
1227
+ [hostEnvironmentId, true],
1228
+ [EnvironmentId.make("other"), false],
1229
+ ] as const) {
1230
+ expect(
1231
+ shouldShowOpenInPicker({
1232
+ activeProjectName: "Project",
1233
+ activeThreadEnvironmentId,
1234
+ primaryEnvironmentId,
1235
+ hostEnvironmentId,
1236
+ remoteOpenMode: "local-exec",
1237
+ }),
1238
+ ).toBe(visible);
1239
+ }
1240
+ });
1241
+});
apps/web/src/components/ChatView.tsx
+11
-11
@@ -231,11 +231,8 @@ import { selectThreadTerminalUiState, useTerminalUiStateStore } from "../termina
231
import { useKnownTerminalSessions, useThreadRunningTerminalIds } from "../state/terminalSessions";
232
import { useEnvironmentQueryRefresh } from "../state/query";
233
import { useEnvironmentScope } from "~/state/session";
234
-import {
235
- primaryServerAvailableEditorsAtom,
236
- primaryServerKeybindingsAtom,
237
- serverEnvironment,
238
-} from "../state/server";
234
+import { primaryServerKeybindingsAtom, serverEnvironment } from "../state/server";
235
+import { hostEnvironmentIdAtom } from "../state/primaryEnvironment";
236
import { threadEnvironment } from "../state/threads";
237
import { resolveProviderSkillsForCwd } from "@t3tools/client-runtime/providerSkills";
238
import { chatGitStatusAtom, NO_CHAT_GIT_STATUS_ATOM, vcsEnvironment } from "../state/vcs";
@@ -1157,7 +1154,6 @@ export default function ChatView(props: ChatViewProps) {
1154
useRightPanelStore.getState().reconcileFileSurfaces(activeThreadRef, activeProject !== null);
1155
}, [activeEnvironmentBootstrapComplete, activeProject, activeThreadRef]);
1156
1160
- const primaryEnvironmentId = primaryEnvironment?.environmentId ?? null;
1157
const activeEnvironment =
1158
activeThread == null ? null : (environmentById.get(activeThread.environmentId) ?? null);
1159
const activeEnvironmentUnavailable =
@@ -1612,17 +1608,21 @@ export default function ChatView(props: ChatViewProps) {
1608
const scriptKeybindings =
1609
useAtomValue(serverEnvironment.configValueAtom(environmentId))?.keybindings ??
1610
DEFAULT_RESOLVED_KEYBINDINGS;
1615
- const availableEditors = useAtomValue(primaryServerAvailableEditorsAtom);
1616
- const remoteOpenState = useRemoteOpenState(activeThread?.environmentId ?? environmentId);
1611
+ const openInEnvironmentId = activeThread?.environmentId ?? environmentId;
1612
+ const availableEditors =
1613
+ useAtomValue(serverEnvironment.configValueAtom(openInEnvironmentId))?.availableEditors ?? [];
1614
+ const hostEnvironmentId = useAtomValue(hostEnvironmentIdAtom);
1615
+ const remoteOpenState = useRemoteOpenState(openInEnvironmentId);
1616
const showOpenInPicker = shouldShowOpenInPicker({
1617
activeProjectName: activeProject?.title,
1619
- activeThreadEnvironmentId: activeThread?.environmentId ?? environmentId,
1620
- primaryEnvironmentId,
1618
+ activeThreadEnvironmentId: openInEnvironmentId,
1619
+ primaryEnvironmentId: primaryEnvironment?.environmentId ?? null,
1620
+ hostEnvironmentId,
1621
remoteOpenMode: remoteOpenState.mode,
1622
});
1623
useOpenFavoriteEditorShortcut({
1624
enabled: showOpenInPicker && !backgroundThread,
1625
- environmentId: activeThread?.environmentId ?? environmentId,
1625
+ environmentId: openInEnvironmentId,
1626
keybindings,
1627
availableEditors,
1628
openInCwd: gitCwd,
apps/web/src/components/chat/OpenInPicker.logic.test.ts
new
+26
@@ -0,0 +1,26 @@
1
+import { EnvironmentId } from "@t3tools/contracts";
2
+import { describe, expect, it } from "vite-plus/test";
3
+
4
+import { shouldShowOpenInPicker } from "./OpenInPicker.logic";
5
+
6
+describe("shouldShowOpenInPicker", () => {
7
+ it("shows both local environments when the primary has a separate WSL home", () => {
8
+ const primaryEnvironmentId = EnvironmentId.make("wsl");
9
+ const hostEnvironmentId = EnvironmentId.make("host");
10
+ for (const [activeThreadEnvironmentId, visible] of [
11
+ [primaryEnvironmentId, true],
12
+ [hostEnvironmentId, true],
13
+ [EnvironmentId.make("other"), false],
14
+ ] as const) {
15
+ expect(
16
+ shouldShowOpenInPicker({
17
+ activeProjectName: "Project",
18
+ activeThreadEnvironmentId,
19
+ primaryEnvironmentId,
20
+ hostEnvironmentId,
21
+ remoteOpenMode: "local-exec",
22
+ }),
23
+ ).toBe(visible);
24
+ }
25
+ });
26
+});
apps/web/src/components/chat/OpenInPicker.logic.ts
+3
-2
@@ -6,12 +6,13 @@ export function shouldShowOpenInPicker(input: {
6
readonly activeProjectName: string | undefined;
7
readonly activeThreadEnvironmentId: EnvironmentId;
8
readonly primaryEnvironmentId: EnvironmentId | null;
9
+ readonly hostEnvironmentId: string | null;
10
readonly remoteOpenMode: RemoteOpenMode;
11
}): boolean {
12
if (!input.activeProjectName) return false;
13
if (
13
- input.primaryEnvironmentId !== null &&
14
- input.activeThreadEnvironmentId === input.primaryEnvironmentId
14
+ input.activeThreadEnvironmentId === input.primaryEnvironmentId ||
15
+ input.activeThreadEnvironmentId === input.hostEnvironmentId
16
) {
17
return true;
18
}
apps/web/src/components/files/FilePreviewPanel.tsx
+5
-1
@@ -71,6 +71,7 @@ import { buildFileReviewComment } from "~/reviewCommentContext";
71
import { assetEnvironment } from "~/state/assets";
72
import { usePreviewAvailable } from "~/browser/previewRuntime";
73
import { useEnvironmentHttpBaseUrl, usePrimaryEnvironmentId } from "~/state/environments";
74
+import { hostEnvironmentIdAtom } from "~/state/primaryEnvironment";
75
import { previewEnvironment } from "~/state/preview";
76
import { serverEnvironment } from "~/state/server";
77
import { useEnvironmentScope } from "~/state/session";
@@ -1025,6 +1026,7 @@ export default function FilePreviewPanel({
1026
const wordWrap = wordWrapOverride ?? defaultWordWrap;
1027
const canOperatePreview = useEnvironmentScope(environmentId, AuthPreviewOperateScope);
1028
const primaryEnvironmentId = usePrimaryEnvironmentId();
1029
+ const hostEnvironmentId = useAtomValue(hostEnvironmentIdAtom);
1030
const remoteOpenState = useRemoteOpenState(environmentId);
1031
const serverConfig = useAtomValue(serverEnvironment.configValueAtom(environmentId));
1032
const environmentHttpBaseUrl = useEnvironmentHttpBaseUrl(environmentId);
@@ -1281,7 +1283,9 @@ export default function FilePreviewPanel({
1283
</div>
1284
</ScrollArea>
1285
{absolutePath &&
1284
- (environmentId === primaryEnvironmentId || remoteOpenState.mode !== "local-exec") ? (
1286
+ (environmentId === primaryEnvironmentId ||
1287
+ environmentId === hostEnvironmentId ||
1288
+ remoteOpenState.mode !== "local-exec") ? (
1289
<OpenInPicker
1290
environmentId={environmentId}
1291
keybindings={keybindings}
apps/web/src/remoteOpen.test.ts
+36
@@ -31,6 +31,7 @@ describe("resolveRemoteOpenState", () => {
31
sshTarget: null,
32
isDesktopRenderer: false,
33
remoteOpenTargets: TAILSCALE_TARGETS,
34
+ hostEnvironmentId: null,
35
}),
36
).toEqual({ mode: "local-exec" });
37
});
@@ -42,6 +43,7 @@ describe("resolveRemoteOpenState", () => {
43
sshTarget: null,
44
isDesktopRenderer: false,
45
remoteOpenTargets: TAILSCALE_TARGETS,
46
+ hostEnvironmentId: null,
47
}),
48
).toEqual({
49
mode: "remote-links",
@@ -57,10 +59,40 @@ describe("resolveRemoteOpenState", () => {
59
sshTarget: null,
60
isDesktopRenderer: true,
61
remoteOpenTargets: TAILSCALE_TARGETS,
62
+ hostEnvironmentId: null,
63
}),
64
).toEqual({ mode: "local-exec" });
65
});
66
67
+ it("keeps exec behavior for the environment that owns the desktop's T3 home", () => {
68
+ // With Local environment off, a background service on this machine can own the
69
+ // desktop's home and still be reached through T3 Connect.
70
+ expect(
71
+ resolveRemoteOpenState({
72
+ target: new RelayConnectionTarget({ environmentId, label: "sol" }),
73
+ sshTarget: null,
74
+ isDesktopRenderer: true,
75
+ remoteOpenTargets: TAILSCALE_TARGETS,
76
+ hostEnvironmentId: environmentId,
77
+ }),
78
+ ).toEqual({ mode: "local-exec" });
79
+ });
80
+
81
+ it("uses deep links for other environments when the desktop home has its own", () => {
82
+ expect(
83
+ resolveRemoteOpenState({
84
+ target: new RelayConnectionTarget({ environmentId, label: "sol" }),
85
+ sshTarget: null,
86
+ isDesktopRenderer: true,
87
+ remoteOpenTargets: TAILSCALE_TARGETS,
88
+ hostEnvironmentId: EnvironmentId.make("environment-host"),
89
+ }),
90
+ ).toEqual({
91
+ mode: "remote-links",
92
+ host: { kind: "tailscale", host: "sol.tail1234.ts.net" },
93
+ });
94
+ });
95
+
96
it("leaves a bare desktop SSH alias for the editor to resolve through SSH config", () => {
97
const state = resolveRemoteOpenState({
98
target: new SshConnectionTarget({ environmentId, label: "sol", connectionId: "ssh-1" }),
@@ -69,6 +101,7 @@ describe("resolveRemoteOpenState", () => {
101
remoteOpenTargets: [
102
{ kind: "tailscale", host: "sol.tail1234.ts.net", username: "server-user" },
103
],
104
+ hostEnvironmentId: null,
105
});
106
expect(state).toEqual({ mode: "remote-links", host: { kind: "ssh-alias", host: "sol" } });
107
if (state.mode !== "remote-links") throw new Error("Expected a remote link");
@@ -97,6 +130,7 @@ describe("resolveRemoteOpenState", () => {
130
sshTarget,
131
isDesktopRenderer: true,
132
remoteOpenTargets: TAILSCALE_TARGETS,
133
+ hostEnvironmentId: null,
134
});
135
expect(state.mode).toBe("remote-links");
136
if (state.mode !== "remote-links") throw new Error("Expected a remote link");
@@ -121,6 +155,7 @@ describe("resolveRemoteOpenState", () => {
155
remoteOpenTargets: [
156
{ kind: "tailscale", host: "server.tail1234.ts.net", username: "admin-user" },
157
],
158
+ hostEnvironmentId: null,
159
});
160
expect(state.mode).toBe("remote-links");
161
if (state.mode !== "remote-links") throw new Error("Expected a remote link");
@@ -137,6 +172,7 @@ describe("resolveRemoteOpenState", () => {
172
sshTarget: null,
173
isDesktopRenderer: false,
174
remoteOpenTargets,
175
+ hostEnvironmentId: null,
176
}),
177
).toEqual({ mode: "remote-unavailable" });
178
}
apps/web/src/remoteOpen.ts
+4
-1
@@ -14,6 +14,7 @@ import { isDesktopLocalConnectionTarget } from "~/connection/desktopLocal";
14
import { isLoopbackHostname } from "~/environments/primary/target";
15
import { useLocalStorage } from "~/hooks/useLocalStorage";
16
import { environmentPresentations } from "~/state/presentation";
17
+import { hostEnvironmentIdAtom } from "~/state/primaryEnvironment";
18
19
export interface RemoteOpenHost {
20
readonly kind: "ssh-alias" | RemoteOpenTarget["kind"];
@@ -53,9 +54,10 @@ export function resolveRemoteOpenState(input: {
54
readonly sshTarget: { readonly alias: string; readonly username: string | null } | null;
55
readonly remoteOpenTargets: ReadonlyArray<RemoteOpenTarget> | undefined;
56
readonly isDesktopRenderer: boolean;
57
+ readonly hostEnvironmentId: string | null;
58
}): RemoteOpenState {
59
const { target } = input;
58
- if (target === null) {
60
+ if (target === null || target.environmentId === input.hostEnvironmentId) {
61
return LOCAL_EXEC;
62
}
63
if (target._tag === "PrimaryConnectionTarget") {
@@ -120,6 +122,7 @@ const remoteOpenResolutionAtom = Atom.family((environmentId: EnvironmentId) =>
122
profile !== null && profile._tag === "SshConnectionProfile" ? profile.target : null,
123
remoteOpenTargets: presentation?.serverConfig?.remoteOpenTargets,
124
isDesktopRenderer: window.desktopBridge !== undefined,
125
+ hostEnvironmentId: get(hostEnvironmentIdAtom),
126
}),
127
isResolved: true,
128
};
apps/web/src/state/server.ts
-7
@@ -1,6 +1,5 @@
1
import {
2
DEFAULT_SERVER_SETTINGS,
3
- type EditorId,
3
type EnvironmentId,
4
type EnvironmentTheme,
5
type ServerConfig,
@@ -53,7 +52,6 @@ interface PrimaryServerState {
52
readonly welcome: ServerLifecycleWelcomePayload | null;
53
}
54
56
-const EMPTY_AVAILABLE_EDITORS: ReadonlyArray<EditorId> = [];
55
export const EMPTY_SERVER_PROVIDERS: ReadonlyArray<ServerProvider> = [];
56
const EMPTY_PRIMARY_SERVER_STATE: PrimaryServerState = {
57
config: null,
@@ -166,11 +164,6 @@ export const primaryServerKeybindingsAtom = createShortcutKeybindingsAtom({
164
environmentsAtom: environmentConnectionsAtom,
165
}).pipe(Atom.withLabel("web-primary-server-keybindings"));
166
169
-export const primaryServerAvailableEditorsAtom = Atom.make(
170
- (get): ReadonlyArray<EditorId> =>
171
- get(primaryServerConfigAtom)?.availableEditors ?? EMPTY_AVAILABLE_EDITORS,
172
-).pipe(Atom.withLabel("web-primary-server-available-editors"));
173
-
167
const EMPTY_ENVIRONMENT_THEMES: ReadonlyArray<EnvironmentTheme> = [];
168
169
const themeServerConfigAtom = Atom.make((get): ServerConfig | null => {
docs/user/remote-access.md
+3
@@ -465,6 +465,9 @@ desktop app, open **Settings → Environments** and switch off **Local
465
environment**. T3 Code restarts without a local server: no local agents or terminals run, WSL
466
backends stay off, and other devices can no longer connect to this computer. Your projects,
467
history, and saved connections are kept, and you keep working through pairing, T3 Connect, or SSH.
468
+If a [background service](./background-service.md) on this computer uses the same T3 home, the
469
+app still treats it as this computer: **Open in** and file reveal for its projects run here,
470
+whichever connection you reach it through.
471
472
Switch **Local environment** back on in the same place to restart with your previous local
473
settings.