Skip to content

[codex] Make settings environment-scoped by default - #3216

Merged
juliusmarminge merged 2 commits into
mainfrom
t3code/fix-selected-environment-models
Jun 20, 2026
Merged

[codex] Make settings environment-scoped by default#3216
juliusmarminge merged 2 commits into
mainfrom
t3code/fix-selected-environment-models

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

What changed

  • make client-runtime's subscribed server config the authoritative live source for environment presentations, settings, and providers
  • rename the connection-session config atoms to initialConfig* so bootstrap state cannot be mistaken for current state
  • require an environment id for normal web settings reads and merge client-local preferences into that environment's live server settings
  • keep primary-environment reads and writes behind explicitly named APIs used by the settings UI
  • resolve new-thread environment defaults from the target project's environment instead of the primary environment
  • move both web and mobile model/config consumers onto the live environment source

Why

The model picker received provider snapshots from the selected remote environment but filtered them using settings from the primary environment. The same architecture also exposed an initial connection config and a live subscribed config under similarly generic names, making correctly scoped but stale reads possible on both web and mobile.

The new API makes the safe path the default: live data, keyed by environment. Client-only settings remain global and are merged only after the environment's server settings have been selected.

Impact

  • remote model pickers show the provider instances configured on that remote environment
  • provider and settings updates propagate through web and mobile without reconnecting
  • new threads use defaultThreadEnvMode and newWorktreesStartFromOrigin from their target environment
  • settings pages remain intentionally scoped to the primary environment

Validation

  • vp test — 490 files passed, 2 skipped; 3,683 tests passed
  • vp check — passed with existing repository warnings only
  • vp run typecheck — passed all 15 packages
  • vp run lint:mobile — passed native checks; SwiftLint skipped because it is not installed

Note

Medium Risk
Broad refactor of how settings are read and persisted across web, mobile, and client-runtime; intentional behavior changes in multi-environment scenarios (model list, new-thread defaults, add-project paths).

Overview
Fixes the model picker and related flows reading primary server settings while provider snapshots came from a remote environment.

Settings API: Replaces useSettings / useUpdateSettings with explicit hooks—useEnvironmentSettings(environmentId) and updaters for environment-scoped server patches, useClientSettings for local-only prefs (sidebar sort, favorites, diff UI), and usePrimarySettings for the settings UI. mergeEnvironmentSettings overlays client prefs on server settings for a given environment.

Runtime state: Session config is documented as bootstrap-only (initialConfigValueAtom); live config flows through serverEnvironment.configValueAtom / settingsValueAtom. Presentation and server-config maps wire through serverConfigValueAtom.

Chat / threads: ChatView uses useEnvironmentSettings(environmentId) and, when an active thread exists, does not fall back to the primary environment's serverConfig while the selected environment is loading. New-thread creation (useHandleNewThread, sidebar, command palette) takes defaultThreadEnvMode and worktree defaults from serverConfigs.get(environmentId), not global merged settings.

Call-site routing: UI that only needs client prefs migrates to useClientSettings; settings panels stay on usePrimarySettings. selectProjectGroupingSettings now reads from client settings only.

Reviewed by Cursor Bugbot for commit 9f21d61. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Scope settings to individual environments instead of a single global client setting

  • Introduces useEnvironmentSettings, useClientSettings, usePrimarySettings, and matching updater hooks in useSettings.ts to replace the single useSettings hook with environment-aware variants.
  • New thread drafts now derive defaultThreadEnvMode and newWorktreesStartFromOrigin from each target environment's server settings via useServerConfigs, removing the global client-side fallback.
  • Settings panels and dialogs that configure the primary environment now use usePrimarySettings/useUpdatePrimarySettings explicitly.
  • In server.ts, createServerEnvironmentAtoms gains settingsValueAtom and providersValueAtom derived from configValueAtom; session config is renamed to initialConfigValueAtom to clarify it is bootstrap-only.
  • Behavioral Change: ChatView no longer falls back to the primary environment's server config while a selected environment is still loading — it returns null instead.

Macroscope summarized 9f21d61.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Jun 20, 2026
@juliusmarminge
juliusmarminge marked this pull request as ready for review June 20, 2026 06:25
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fc120af9-647b-41ca-9712-cc2f5b9da521

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch t3code/fix-selected-environment-models

Comment @coderabbitai help to get the list of available commands and usage tips.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Primary settings used for model selection
    • Replaced settings with composerSettings in onProviderModelSelect so the model resolution uses the same environment-aware settings that the model picker displays, eliminating the mismatch that could cause selections to silently fail.

Create PR

Or push these changes by commenting:

@cursor push 41b3ef6c25
Preview (41b3ef6c25)
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx
--- a/apps/web/src/components/ChatView.tsx
+++ b/apps/web/src/components/ChatView.tsx
@@ -4449,7 +4449,7 @@
       }
       const resolvedModel = resolveAppModelSelectionForInstance(
         instanceId,
-        settings,
+        composerSettings,
         providerStatuses,
         model,
       );
@@ -4491,7 +4491,7 @@
       setComposerDraftModelSelection,
       setStickyComposerModelSelection,
       providerStatuses,
-      settings,
+      composerSettings,
     ],
   );
   const onEnvModeChange = useCallback(

You can send follow-ups to the cloud agent here.

Comment thread apps/web/src/components/ChatView.tsx
@macroscopeapp

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR changes settings resolution from global to environment-scoped, affecting runtime behavior for thread creation defaults and how settings are resolved across environments. The architectural shift in how defaultThreadEnvMode and newWorktreesStartFromOrigin are sourced warrants human review.

You can customize Macroscope's approvability policy. Learn more.

@juliusmarminge juliusmarminge changed the title [codex] Fix model picker environment settings [codex] Make settings environment-scoped by default Jun 20, 2026
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Jun 20, 2026
@juliusmarminge
juliusmarminge merged commit 79c5717 into main Jun 20, 2026
16 checks passed
@juliusmarminge
juliusmarminge deleted the t3code/fix-selected-environment-models branch June 20, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant