The best way to control Claude Code, Codex and more from any computer or phone
fix(web): new-thread defaults ignored for remote environments (#4276)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Theo Browne committed
Jul 23, 2026 at 02:06 UTC
16491a84b9bb2842ad6db41635d087647fc2df5b
3 files changed
+27
-23
apps/web/src/components/ChatView.tsx
+8
-3
@@ -189,6 +189,7 @@ import { useEnvironmentQuery } from "../state/query";
189
import {
190
primaryServerAvailableEditorsAtom,
191
primaryServerKeybindingsAtom,
192
+ primaryServerSettingsAtom,
193
serverEnvironment,
194
} from "../state/server";
195
import { terminalEnvironment } from "../state/terminal";
@@ -1153,6 +1154,10 @@ function ChatViewContent(props: ChatViewProps) {
1154
(store) => store.threadLastVisitedAtById[routeThreadKey],
1155
);
1156
const settings = useEnvironmentSettings(environmentId);
1157
+ // New-thread defaults live in the primary environment's settings.json (the
1158
+ // settings UI never writes to remote environments), so read them from the
1159
+ // primary server rather than the thread's environment.
1160
+ const primaryServerSettings = useAtomValue(primaryServerSettingsAtom);
1161
const setStickyComposerModelSelection = useComposerDraftStore(
1162
(store) => store.setStickyModelSelection,
1163
);
@@ -3785,7 +3790,7 @@ function ChatViewContent(props: ChatViewProps) {
3790
? (draftThread?.startFromOrigin ?? false)
3791
: canOverrideServerThreadEnvMode
3792
? (pendingServerThreadStartFromOriginByThreadId[activeThread?.id ?? ""] ??
3788
- settings.newWorktreesStartFromOrigin)
3793
+ primaryServerSettings.newWorktreesStartFromOrigin)
3794
: false;
3795
const sendEnvMode = resolveSendEnvMode({
3796
requestedEnvMode: envMode,
@@ -5254,7 +5259,7 @@ function ChatViewContent(props: ChatViewProps) {
5259
envMode: mode,
5260
startFromOrigin: resolveNewDraftStartFromOrigin({
5261
envMode: mode,
5257
- newWorktreesStartFromOrigin: settings.newWorktreesStartFromOrigin,
5262
+ newWorktreesStartFromOrigin: primaryServerSettings.newWorktreesStartFromOrigin,
5263
}),
5264
...(mode === "worktree" && draftThread?.worktreePath ? { worktreePath: null } : {}),
5265
});
@@ -5266,7 +5271,7 @@ function ChatViewContent(props: ChatViewProps) {
5271
composerDraftTarget,
5272
draftThread?.worktreePath,
5273
isLocalDraftThread,
5269
- settings.newWorktreesStartFromOrigin,
5274
+ primaryServerSettings.newWorktreesStartFromOrigin,
5275
setPendingServerThreadEnvMode,
5276
scheduleComposerFocus,
5277
setDraftThreadContext,
apps/web/src/components/Sidebar.tsx
+6
-8
@@ -43,7 +43,6 @@ import { restrictToFirstScrollableAncestor, restrictToVerticalAxis } from "@dnd-
43
import { CSS } from "@dnd-kit/utilities";
44
import {
45
type ContextMenuItem,
46
- DEFAULT_SERVER_SETTINGS,
46
ProjectId,
47
type ScopedThreadRef,
48
type ResolvedKeybindingsConfig,
@@ -81,7 +80,6 @@ import {
80
readThreadShell,
81
useProject,
82
useProjects,
84
- useServerConfigs,
83
useThreadShells,
84
useThreadShellsForProjectRefs,
85
} from "../state/entities";
@@ -203,7 +201,7 @@ import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";
201
import { useIsMobile } from "~/hooks/useMediaQuery";
202
import { CommandDialogTrigger } from "./ui/command";
203
import { useClientSettings, useUpdateClientSettings } from "~/hooks/useSettings";
206
-import { primaryServerKeybindingsAtom } from "../state/server";
204
+import { primaryServerKeybindingsAtom, primaryServerSettingsAtom } from "../state/server";
205
import {
206
derivePhysicalProjectKey,
207
deriveProjectGroupingOverrideKey,
@@ -1113,7 +1111,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
1111
(settings) => settings.confirmThreadArchive,
1112
);
1113
const projectGroupingSettings = useClientSettings(selectProjectGroupingSettings);
1116
- const serverConfigs = useServerConfigs();
1114
+ const primaryServerSettings = useAtomValue(primaryServerSettingsAtom);
1115
const deleteProject = useAtomCommand(projectEnvironment.delete, {
1116
reportFailure: false,
1117
});
@@ -1901,10 +1899,10 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
1899
: null;
1900
const seedContext = resolveSidebarNewThreadSeedContext({
1901
projectId: member.id,
1902
+ // The default env mode is a user preference stored on the primary
1903
+ // environment's settings.json; remote environments never carry it.
1904
defaultEnvMode: resolveSidebarNewThreadEnvMode({
1905
- defaultEnvMode:
1906
- serverConfigs.get(member.environmentId)?.settings.defaultThreadEnvMode ??
1907
- DEFAULT_SERVER_SETTINGS.defaultThreadEnvMode,
1905
+ defaultEnvMode: primaryServerSettings.defaultThreadEnvMode,
1906
}),
1907
activeThread:
1908
currentActiveThread && currentActiveThread.projectId === member.id
@@ -1953,7 +1951,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
1951
}
1952
})();
1953
},
1956
- [handleNewThread, isMobile, router, serverConfigs, setOpenMobile],
1954
+ [handleNewThread, isMobile, primaryServerSettings.defaultThreadEnvMode, router, setOpenMobile],
1955
);
1956
1957
const handleCreateThreadClick = useCallback(
apps/web/src/hooks/useHandleNewThread.ts
+13
-12
@@ -1,13 +1,10 @@
1
+import { useAtomValue } from "@effect/atom-react";
2
import {
3
scopedProjectKey,
4
scopeProjectRef,
5
scopeThreadRef,
6
} from "@t3tools/client-runtime/environment";
6
-import {
7
- DEFAULT_RUNTIME_MODE,
8
- DEFAULT_SERVER_SETTINGS,
9
- type ScopedProjectRef,
10
-} from "@t3tools/contracts";
7
+import { DEFAULT_RUNTIME_MODE, type ScopedProjectRef } from "@t3tools/contracts";
8
import { useParams, useRouter } from "@tanstack/react-router";
9
import { useCallback, useMemo } from "react";
10
import {
@@ -23,15 +20,21 @@ import {
20
getProjectOrderKey,
21
selectProjectGroupingSettings,
22
} from "../logicalProject";
26
-import { readThreadShell, useProjects, useServerConfigs, useThread } from "../state/entities";
23
+import { readThreadShell, useProjects, useThread } from "../state/entities";
24
import { resolveNewDraftStartFromOrigin } from "../lib/chatThreadActions";
25
+import { primaryServerSettingsAtom } from "../state/server";
26
import { resolveThreadRouteTarget } from "../threadRoutes";
27
import { legacyProjectCwdPreferenceKey, useUiStateStore } from "../uiStateStore";
28
import { useClientSettings } from "./useSettings";
29
30
export function useNewThreadHandler() {
31
const projects = useProjects();
34
- const serverConfigs = useServerConfigs();
32
+ // New-thread defaults are a user preference, and the settings UI only ever
33
+ // edits the primary environment's settings.json. Reading the target
34
+ // environment's own settings here would silently reset remote projects to
35
+ // the decoded defaults ("local" mode, current branch), since nothing can
36
+ // set those values on a remote server.
37
+ const primaryServerSettings = useAtomValue(primaryServerSettingsAtom);
38
const projectGroupingSettings = useClientSettings(selectProjectGroupingSettings);
39
const router = useRouter();
40
const getCurrentRouteTarget = useCallback(() => {
@@ -64,8 +67,6 @@ export function useNewThreadHandler() {
67
candidate.id === projectRef.projectId &&
68
candidate.environmentId === projectRef.environmentId,
69
);
67
- const environmentSettings =
68
- serverConfigs.get(projectRef.environmentId)?.settings ?? DEFAULT_SERVER_SETTINGS;
70
const logicalProjectKey = project
71
? deriveLogicalProjectKeyFromSettings(project, projectGroupingSettings)
72
: scopedProjectKey(projectRef);
@@ -161,7 +162,7 @@ export function useNewThreadHandler() {
162
const draftId = newDraftId();
163
const threadId = newThreadId();
164
const createdAt = new Date().toISOString();
164
- const initialEnvMode = options?.envMode ?? environmentSettings.defaultThreadEnvMode;
165
+ const initialEnvMode = options?.envMode ?? primaryServerSettings.defaultThreadEnvMode;
166
return (async () => {
167
setLogicalProjectDraftThreadId(logicalProjectKey, projectRef, draftId, {
168
threadId,
@@ -173,7 +174,7 @@ export function useNewThreadHandler() {
174
options?.startFromOrigin ??
175
resolveNewDraftStartFromOrigin({
176
envMode: initialEnvMode,
176
- newWorktreesStartFromOrigin: environmentSettings.newWorktreesStartFromOrigin,
177
+ newWorktreesStartFromOrigin: primaryServerSettings.newWorktreesStartFromOrigin,
178
}),
179
runtimeMode: DEFAULT_RUNTIME_MODE,
180
});
@@ -186,7 +187,7 @@ export function useNewThreadHandler() {
187
});
188
})();
189
},
189
- [getCurrentRouteTarget, projectGroupingSettings, projects, router, serverConfigs],
190
+ [getCurrentRouteTarget, primaryServerSettings, projectGroupingSettings, projects, router],
191
);
192
}
193