chore(web): address Copilot review on #2154

- Terminate the two banner-path `onToggleConnection` calls through a
  `retryConnect` helper. The toggle handles every handshake failure, but
  client construction runs ahead of its try/catch, so a throw there
  escaped into a discarded promise with the banner already dismissed.
  Recorded on `connectErrorMessage` rather than toasted, matching the
  deep-link phases' own catch, so the move stays inert.
- Add the unsettled-`/api/config` race test: a connect that starts before
  the sandbox answer is held at the gate and builds from the URL as of the
  release, which is what `sandboxUrlRef` exists for.
- Correct the harness's `client` doc, which described a
  last-constructed fallback the harness never implemented.

Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
cliffhall 2026-08-27 01:14:56 -04:00
commit 005e4c655a

View file

@ -862,6 +862,30 @@ export function useConnectionLifecycle({
recordConnectError,
]);
/**
* The banner's connect, terminated. `onToggleConnection` handles every
* failure the *handshake* can produce, but client construction runs ahead of
* its try/catch — so a throw there (a wedged store teardown, a config the
* `InspectorClient` constructor rejects) escapes it. Both banner call sites
* discard the promise, which would make that an unhandled rejection with the
* banner already dismissed and nothing left to explain it.
*
* Recorded on `connectErrorMessage` rather than toasted, matching the
* deep-link phases' own catch: the toggle already toasts everything it
* handles, so a toast here would be new user-visible behavior in what is
* otherwise an inert move.
*/
const retryConnect = useCallback(
async (serverId: string) => {
try {
await onToggleConnection(serverId);
} catch (err) {
recordConnectError(err instanceof Error ? err.message : String(err));
}
},
[onToggleConnection, recordConnectError],
);
const onReauthenticateFromBanner = useCallback(() => {
if (!reAuthBanner) return;
const serverId = reAuthBanner.serverId;
@ -901,7 +925,7 @@ export function useConnectionLifecycle({
return;
}
}
await onToggleConnection(serverId);
await retryConnect(serverId);
})();
return;
}
@ -944,16 +968,16 @@ export function useConnectionLifecycle({
return;
}
void onToggleConnection(serverId);
void retryConnect(serverId);
}, [
sessionRef,
reAuthBanner,
retryConnect,
activeServerId,
connectionStatus,
inspectorClient,
servers,
prepareOAuthRedirect,
onToggleConnection,
webOAuthStorage,
setReAuthBanner,
]);