Merge branch 'v2/main' into v2/fix/2217-oauth-clear-shared-url

This commit is contained in:
Cliff Hall 2026-09-04 08:52:42 -04:00 • committed by GitHub
commit 7897d68cab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -441,13 +441,31 @@ export function useOAuthRecovery({
}
let cancelled = false;
// Reads are concurrent — an `oauthComplete` can start a second one while
// the first is still in flight — and nothing makes them settle in order.
// Only the newest read may write, so a slow earlier one cannot overwrite
// (or, on rejection, clear) a newer result.
let latest = 0;
const refresh = (): void => {
void inspectorClient.getOAuthState().then((state) => {
if (cancelled) return;
setConnectionInfoOAuthWhenConnected(
state ? oauthDetailsFromConnectionState(state) : undefined,
);
});
const seq = ++latest;
// void: a synchronous useEffect body cannot await. The chain is
// terminated below, so the rejection is handled rather than discarded.
void inspectorClient
.getOAuthState()
.then((state) => {
if (cancelled || seq !== latest) return;
setConnectionInfoOAuthWhenConnected(
state ? oauthDetailsFromConnectionState(state) : undefined,
);
})
.catch(() => {
// The read failed (backend down, 401 on the API token, malformed
// stored state). Clear rather than keep the last successful read —
// a stale answer is indistinguishable from a fresh one in the panel.
if (cancelled || seq !== latest) return;
setConnectionInfoOAuthWhenConnected(undefined);
});
};
const onAmbientAuthChallenge = (): void => {