fix: welcome dialog Save overwriting user's agent pick (#4)
The Save button fired both onSave and onClose. onClose's closed-over `config` still held the bootstrap default (agentId: 'claude'), so it re-ran setConfig with the stale value right after onSave wrote the user's choice — leaving the user with Claude Code even when they had clicked Codex on first run. Split the responsibilities: Save now owns close (handleConfigSave calls setSettingsOpen(false)); onClose stays scoped to dismiss flows (Skip / backdrop) where the stale-config write is harmless.
This commit is contained in:
@@ -116,6 +116,7 @@ export function App() {
|
|||||||
const withOnboarding: AppConfig = { ...next, onboardingCompleted: true };
|
const withOnboarding: AppConfig = { ...next, onboardingCompleted: true };
|
||||||
saveConfig(withOnboarding);
|
saveConfig(withOnboarding);
|
||||||
setConfig(withOnboarding);
|
setConfig(withOnboarding);
|
||||||
|
setSettingsOpen(false);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleModeChange = useCallback(
|
const handleModeChange = useCallback(
|
||||||
|
|||||||
@@ -276,10 +276,7 @@ export function SettingsDialog({
|
|||||||
type="button"
|
type="button"
|
||||||
className="primary"
|
className="primary"
|
||||||
disabled={!canSave}
|
disabled={!canSave}
|
||||||
onClick={() => {
|
onClick={() => onSave(cfg)}
|
||||||
onSave(cfg);
|
|
||||||
onClose();
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{welcome ? t('settings.getStarted') : t('common.save')}
|
{welcome ? t('settings.getStarted') : t('common.save')}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user