feat(settings): auto-set default provider after successful OAuth (#254)
This commit is contained in:
committed by
GitHub
Unverified
parent
19406757f1
commit
29ef9591cf
@@ -1347,6 +1347,8 @@ export class GatewayManager extends EventEmitter {
|
||||
const reasonStr = reason?.toString() || 'unknown';
|
||||
logger.warn(`Gateway WebSocket closed (code=${code}, reason=${reasonStr}, handshake=${handshakeComplete ? 'ok' : 'pending'})`);
|
||||
if (!handshakeComplete) {
|
||||
// If the socket closes before the handshake completes, it usually means the server is still starting or restarting.
|
||||
// Rejecting this promise will cause the caller (startProcess/reconnect logic) to retry cleanly.
|
||||
rejectOnce(new Error(`WebSocket closed before handshake: ${reasonStr}`));
|
||||
return;
|
||||
}
|
||||
@@ -1358,7 +1360,12 @@ export class GatewayManager extends EventEmitter {
|
||||
});
|
||||
|
||||
this.ws.on('error', (error) => {
|
||||
// Suppress noisy ECONNREFUSED/WebSocket handshake errors that happen during expected Gateway restarts.
|
||||
if (error.message?.includes('closed before handshake') || (error as NodeJS.ErrnoException).code === 'ECONNREFUSED') {
|
||||
logger.debug(`Gateway WebSocket connection error (transient): ${error.message}`);
|
||||
} else {
|
||||
logger.error('Gateway WebSocket error:', error);
|
||||
}
|
||||
if (!handshakeComplete) {
|
||||
rejectOnce(error);
|
||||
}
|
||||
|
||||
@@ -516,7 +516,14 @@ function AddProviderDialog({ existingTypes, onClose, onAdd, onValidateKey }: Add
|
||||
// If we call add() here with undefined baseUrl, it will overwrite and erase it!
|
||||
// So we just fetch the latest list from the backend to update the UI.
|
||||
try {
|
||||
await useProviderStore.getState().fetchProviders();
|
||||
const store = useProviderStore.getState();
|
||||
await store.fetchProviders();
|
||||
|
||||
// Auto-set as default if no default is currently configured
|
||||
if (!store.defaultProviderId && latestRef.current.selectedType) {
|
||||
// Provider type is expected to match provider ID for built-in OAuth providers
|
||||
await store.setDefaultProvider(latestRef.current.selectedType);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to refresh providers after OAuth:', err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user