fix(web): new-thread defaults ignored for remote environments#4276
fix(web): new-thread defaults ignored for remote environments#4276t3dotgg wants to merge 1 commit into
Conversation
The "New threads" default (local vs. new worktree) and "start from
origin" are stored in the server-side settings.json, but the settings UI
only ever writes to the primary environment's settings. New-thread code
paths read the setting from the thread's own environment, so threads
created on remote environments always fell back to the decoded defaults
("local" mode on the current branch) no matter what the user picked.
Read the defaults from the primary server settings everywhere they seed
new drafts: useNewThreadHandler, the sidebar's per-project new-thread
seeding, and ChatView's env-mode/start-from-origin resolution.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved Straightforward bug fix that reads new-thread default settings from the primary environment (where the settings UI stores them) instead of from remote environments where they're never configured. Clear intent, limited scope, consistent changes across files. You can customize Macroscope's approvability policy. Learn more. |
Problem
Setting New threads → New worktree (and the nested "Start from origin" toggle) had no effect when creating threads on remote environments: new remote threads always started in local mode on the current branch/worktree.
Root cause:
defaultThreadEnvMode/newWorktreesStartFromOriginare server settings persisted insettings.json, and the settings UI only ever writes to the primary environment's settings (useUpdatePrimarySettings). But the code paths that seed new drafts read the setting from the target thread's environment:useNewThreadHandler—serverConfigs.get(projectRef.environmentId)?.settings ?? DEFAULT_SERVER_SETTINGSSidebar'screateThreadForProjectMember— same per-environment lookupChatView's env-mode toggle and start-from-origin resolution —useEnvironmentSettings(environmentId)Since nothing can write these preferences onto a remote server's
settings.json, remote environments always decoded the schema defaults (defaultThreadEnvMode: "local"), silently overriding the user's choice. Worse, with the sidebar's seed-context logic, the "local" default made new threads inherit the active thread's branch/worktree — hence "wrong branch every time".Fix
Treat new-thread defaults as what they are — a user preference — and read them from the primary environment's settings (
primaryServerSettingsAtom) in all three call sites. Remote environments no longer fall back to decoded defaults.Verification
bun run typecheck(web) passesvp testonSidebar.logic.test.ts,chatThreadActions.test.ts,ChatView.logic.test.ts— 101 tests pass🤖 Generated with Claude Code
Note
Low Risk
Targeted read-path change for draft seeding and env toggles; no auth or persistence changes, behavior aligns with where settings are already written.
Overview
New-thread defaults (
defaultThreadEnvMode, Start from origin for worktrees) are user preferences stored only on the primary environment’ssettings.json, but creation and composer flows were reading them from the target environment’s settings. Remote servers never get those values, so drafts always fell back to schema defaults (local mode / wrong branch).The PR switches ChatView, Sidebar (
createThreadForProjectMember), anduseNewThreadHandlerto useprimaryServerSettingsAtomfor those fields. Per-environmentuseServerConfigs/DEFAULT_SERVER_SETTINGSfallbacks are removed where they seeded new threads.Reviewed by Cursor Bugbot for commit 65c9f07. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix new-thread defaults to use primary server settings for remote environments
When creating a new thread,
defaultThreadEnvModeandnewWorktreesStartFromOriginwere resolved from per-environment server configs or hardcoded defaults, causing remote environment settings to be ignored. This fix updates ChatView.tsx, Sidebar.tsx, and useHandleNewThread.ts to read these values fromprimaryServerSettingsAtominstead.Macroscope summarized 65c9f07.