fix: 修复settings.json内存状态溢出的问题

This commit is contained in:
claude-code-best
2026-04-20 09:40:07 +08:00
parent fedce003a5
commit 7d776b9dcd

View File

@@ -17,7 +17,6 @@ import {
notifySessionMetadataChanged, notifySessionMetadataChanged,
type SessionExternalMetadata, type SessionExternalMetadata,
} from '../utils/sessionState.js' } from '../utils/sessionState.js'
import { updateSettingsForSource } from '../utils/settings/settings.js'
import type { AppState } from './AppStateStore.js' import type { AppState } from './AppStateStore.js'
// Inverse of the push below — restore on worker restart. // Inverse of the push below — restore on worker restart.
@@ -91,23 +90,11 @@ export function onChangeAppState({
notifyPermissionModeChanged(newMode) notifyPermissionModeChanged(newMode)
} }
// mainLoopModel: remove it from settings? // mainLoopModel: session-scoped only (do NOT persist to userSettings).
if ( // Writing to settings.json would leak model changes into other running
newState.mainLoopModel !== oldState.mainLoopModel && // sessions (anthropics/claude-code#37596). Each process keeps its own
newState.mainLoopModel === null // model override in memory via setMainLoopModelOverride.
) { if (newState.mainLoopModel !== oldState.mainLoopModel) {
// Remove from settings
updateSettingsForSource('userSettings', { model: undefined })
setMainLoopModelOverride(null)
}
// mainLoopModel: add it to settings?
if (
newState.mainLoopModel !== oldState.mainLoopModel &&
newState.mainLoopModel !== null
) {
// Save to settings
updateSettingsForSource('userSettings', { model: newState.mainLoopModel })
setMainLoopModelOverride(newState.mainLoopModel) setMainLoopModelOverride(newState.mainLoopModel)
} }