feat(pi): preserve provider/model fields and sync Pi default provider/model on switch
- Fix stale configRef in useConfig so saves include the latest state. - Preserve Pi models.json fields (headers, compat, cost, maxTokens, thinkingLevelMap, authHeader, modelOverrides, provider name) across edits. - Add Pi settings.json I/O and update defaultProvider/defaultModel when activating a provider so Pi actually picks up the switch. - Add round-trip and settings serialization tests.
This commit is contained in:
@@ -48,7 +48,11 @@ export function useConfig(agent: Agent): UseConfigReturn {
|
||||
}, [refresh]);
|
||||
|
||||
const updateConfig = useCallback((updater: (config: Config) => Config) => {
|
||||
setConfig((prev) => (prev ? updater(prev) : prev));
|
||||
setConfig((prev) => {
|
||||
const next = prev ? updater(prev) : prev;
|
||||
configRef.current = next;
|
||||
return next;
|
||||
});
|
||||
setDirty(true);
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user