fix(webui): complete Copilot device sign-in in the browser

Reuse the device-flow adapter from #5498, expose its prompt in the existing OAuth dialog, and keep credential persistence scoped to uncancelled completion.

Co-authored-by: chengyongru <chengyongru.ai@gmail.com>
This commit is contained in:
Xubin Renandchengyongru committed 2026-09-21 00:13:46 +08:00
1 parent aca59431fe
commit a44f28e656
24 files changed
+563 -39

No files matched your search

@@ -33,7 +33,7 @@ import { useSystemSettingsEffects } from "@/components/settings/system/useSystem
import { useSystemSettingsState } from "@/components/settings/system/useSystemSettingsState";
import { usePageVisibility } from "@/hooks/usePageVisibility";
import { useAutoSave } from "@/components/settings/shared/useAutoSave";
import { fetchSettings, fetchSettingsUsage } from "@/lib/api";
import { cancelProviderOAuth, fetchSettings, fetchSettingsUsage } from "@/lib/api";
import {
readLocalPreferences,
writeLocalPreferences,
@@ -174,13 +174,17 @@ export function useSettingsController({
const runtimeConfigState = useRuntimeConfigSettings(settings, client, applyPayload);
const closeProviderOAuthFlow = useCallback(() => {
const closeProviderOAuthFlow = useCallback((cancelPending = true) => {
const flow = providerOAuthFlowRef.current;
providerOAuthFlowRef.current = null;
if (cancelPending && flow?.completion_input === "device_code") {
void cancelProviderOAuth(client, flow.provider, flow.flow_id).catch(() => {});
}
setProviderOAuthFlow(null);
setProviderOAuthResponse("");
setProviderOAuthCompleting(false);
setProviderOAuthDialogError(null);
}, []);
}, [client]);
useProviderOAuthPolling({
state: modelState,
client,