Target server settings by environment #4559
Closedcolonelpanic8(GitHub profile, opens in a new tab)wants to merge 13 commits into
main fromrefs/pull/4559/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/web/src/components/settings/SettingsPanels.tsx line 511Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -508,4 +509,3 @@508509509510 export function GeneralSettingsPanel() {510511 const { theme, setTheme } = useTheme();511- const settings = usePrimarySettings();apps/desktop/src/ipc/methods/backendMode.ts line 70Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +40,21 @@40+ result: DesktopBackendModeStateSchema,41+ handler: Effect.fn("desktop.ipc.backendMode.set")(function* (mode) {42+ const launchMode = yield* DesktopBackendMode.DesktopBackendMode;43+ const lifecycle = yield* DesktopLifecycle.DesktopLifecycle;44+ const settings = yield* DesktopAppSettings.DesktopAppSettings;45+ const previousMode = (yield* settings.get).backendMode;46+ const change = yield* settings.setBackendMode(mode);47+ const launchState = yield* launchMode.get;48+ const state = {49+ ...launchState,50+ configuredMode: change.settings.backendMode,51+ };52+ if (53+ change.changed &&54+ launchState.cliOverride === null &&55+ launchState.effectiveMode !== change.settings.backendMode56+ ) {57+ yield* lifecycle58+ .relaunch(`backendMode=${mode}`)59+ .pipe(Effect.tapError(() => settings.setBackendMode(previousMode)));60+ }apps/web/src/components/settings/DiagnosticsSettings.tsx line 1135Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1132,4 +1255,3 @@11321255 />11331256 <StatBlock11341257 label="Parse Errors"1135- value={data ? formatCount(data.parseErrorCount) : "..."}
- apps/web/src/components/settings/SettingsPanels.tsx line 402Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -389,10 +391,12 @@389391390392 export function useSettingsRestore(onRestored?: () => void) {391393 const { theme, setTheme } = useTheme();392- const settings = usePrimarySettings();393- const updateSettings = useUpdatePrimarySettings();394+ const { environmentId, environment } = useSettingsEnvironment();395+ const settings = useEnvironmentSettings(environmentId);396+ const updateSettings = useUpdateEnvironmentSettings(environmentId);394397395398 const isTextGenerationModelDirty = !Equal.equals(396399 settings.textGenerationModelSelection ?? null,397400 DEFAULT_UNIFIED_SETTINGS.textGenerationModelSelection ?? null,398401 );402+ const hasChangedServerSettings = hasChangedGeneralServerSettings(settings);apps/web/src/components/AppSidebarLayout.tsx line 62Resolvedby colonelpanic8(GitHub profile, opens in a new tab)@@ -59,4 +59,4 @@5959 }60606161 function SidebarControl() {62- const keybindings = useAtomValue(primaryServerKeybindingsAtom);62+ const keybindings = useDefaultServerConfig()?.keybindings ?? DEFAULT_RESOLVED_KEYBINDINGS;apps/web/src/hooks/useHandleNewThread.ts line 105OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -105,3 +102,4 @@105102 candidate.id === projectRef.projectId &&106103 candidate.environmentId === projectRef.environmentId,107104 );105+ const targetServerSettings =apps/desktop/src/ipc/methods/backendMode.ts line 59OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +39,21 @@39+ payload: DesktopBackendModeSchema,40+ result: DesktopBackendModeStateSchema,41+ handler: Effect.fn("desktop.ipc.backendMode.set")(function* (mode) {42+ const launchMode = yield* DesktopBackendMode.DesktopBackendMode;43+ const lifecycle = yield* DesktopLifecycle.DesktopLifecycle;44+ const settings = yield* DesktopAppSettings.DesktopAppSettings;45+ const previousMode = (yield* settings.get).backendMode;46+ const change = yield* settings.setBackendMode(mode);47+ const launchState = yield* launchMode.get;48+ const state = {49+ ...launchState,50+ configuredMode: change.settings.backendMode,51+ };52+ if (53+ change.changed &&54+ launchState.cliOverride === null &&55+ launchState.effectiveMode !== change.settings.backendMode56+ ) {57+ yield* lifecycle58+ .relaunch(`backendMode=${mode}`)59+ .pipe(Effect.tapError(() => settings.setBackendMode(previousMode)));
- apps/web/src/components/settings/SettingsPanels.tsx line 404OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -389,10 +391,14 @@389391390392 export function useSettingsRestore(onRestored?: () => void) {391393 const { theme, setTheme } = useTheme();392- const settings = usePrimarySettings();393- const updateSettings = useUpdatePrimarySettings();394+ const { environmentId, environment } = useSettingsEnvironment();395+ const settings = useEnvironmentSettings(environmentId);396+ const updateSettings = useUpdateEnvironmentSettings(environmentId);394397395398 const isTextGenerationModelDirty = !Equal.equals(396399 settings.textGenerationModelSelection ?? null,397400 DEFAULT_UNIFIED_SETTINGS.textGenerationModelSelection ?? null,398401 );402+ const hasChangedServerSettings = hasChangedGeneralServerSettings(settings);403+ const canRestoreDefaults =404+ !hasChangedServerSettings || environment?.connection.phase === "connected";
- apps/web/src/state/entities.ts line 120Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -116,3 +116,4 @@116116 return useAtomValue(environmentServerConfigsAtom);117117 }118118119+export async function waitForServerConfig(environmentId: EnvironmentId): Promise<ServerConfig> {
- @@ -118,0 +120,21 @@120+ const readConfig = () => appAtomRegistry.get(environmentServerConfigsAtom).get(environmentId);121+ const current = readConfig();122+ if (current !== undefined) {123+ return current;124+ }125+126+ return await new Promise<ServerConfig>((resolve) => {127+ const unsubscribe = appAtomRegistry.subscribe(environmentServerConfigsAtom, (configs) => {128+ const config = configs.get(environmentId);129+ if (config === undefined) return;130+ unsubscribe();131+ resolve(config);132+ });133+134+ const config = readConfig();135+ if (config !== undefined) {136+ unsubscribe();137+ resolve(config);138+ }139+ });140+}
Sign in to join this conversation.


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 Plus
Run ID:
aad25f0c-63bf-47b6-98ec-13cf5784b5c5You 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)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share