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 / newWorktreesStartFromOrigin are server settings persisted in settings.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_SETTINGS
Sidebar's createThreadForProjectMember — same per-environment lookup
ChatView'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) passes
vp test on Sidebar.logic.test.ts, chatThreadActions.test.ts, ChatView.logic.test.ts — 101 tests pass
- lint clean (remaining warnings pre-existing, unrelated files)
🤖 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’s settings.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), and useNewThreadHandler to use primaryServerSettingsAtom for those fields. Per-environment useServerConfigs / DEFAULT_SERVER_SETTINGS fallbacks are removed where they seeded new threads.
Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 65c9f078f797aae03bbf36d3fac04160cc1b3ca6. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).
Note
Fix new-thread defaults to use primary server settings for remote environments#
When creating a new thread, defaultThreadEnvMode and newWorktreesStartFromOrigin were 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 from primaryServerSettingsAtom instead.
Macroscope summarized 65c9f07.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
34265066-c2e0-40fe-9c5e-4a1ad0220c88You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands.