mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-23 07:11:12 +00:00
* feat(ui): replace Overview page with Connection settings and sidebar attention chips * feat(ui): open new-session drafts on the chat start screen hero * refactor(ui): drop old overview-hints paths after rename * chore(i18n): sync control-ui locale bundles for connection/palette/attention keys * test(ui): expect attention slot above the sidebar update card * chore(i18n): re-sync locale bundles after rebase onto main * test(ui): stub sidebar-attention RPCs in app-sidebar unit tests * test(ui): use a non-secret-shaped token fixture in connection view test * refactor(ui): destructure gateway connection in connection settings draft * refactor(ui): keep connection settings code out of secret-scanner shapes * test(ui): expect Connection in the settings Connections group * improve(ui): idle-refresh sidebar attention chips for always-visible windows * chore(i18n): refresh raw-copy baseline after rebase * docs(ui): note the unknown-route chat fallback covers retired paths
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
// Control UI module implements model auth behavior.
|
|
import type { GatewayBrowserClient } from "../api/gateway.ts";
|
|
import type { ModelAuthStatusProvider, ModelAuthStatusResult } from "../api/types.ts";
|
|
|
|
const EMPTY_AUTH_STATUS: ModelAuthStatusResult = { ts: 0, providers: [] };
|
|
|
|
/**
|
|
* True when a provider's auth should be actively monitored on the dashboard.
|
|
*
|
|
* Includes:
|
|
* - Providers with at least one OAuth or bearer-token profile (refreshable
|
|
* credentials that can expire and need rotation)
|
|
* - Providers with status="missing" (configured-but-not-logged-in — the
|
|
* server synthesizes these so the UI can prompt for login)
|
|
*
|
|
* Excludes API-key-only providers — their credentials don't expire on a
|
|
* schedule the dashboard can meaningfully monitor.
|
|
*
|
|
* Single source of truth for the chat composer and the sidebar attention
|
|
* chips. Keep consumers in sync by always routing through this helper.
|
|
*/
|
|
export function isMonitoredAuthProvider(p: ModelAuthStatusProvider): boolean {
|
|
if (p.status === "missing") {
|
|
return true;
|
|
}
|
|
if (!Array.isArray(p.profiles)) {
|
|
return false;
|
|
}
|
|
return p.profiles.some((prof) => prof.type === "oauth" || prof.type === "token");
|
|
}
|
|
|
|
export async function loadModelAuthStatus(
|
|
client: GatewayBrowserClient,
|
|
opts?: { refresh?: boolean },
|
|
): Promise<ModelAuthStatusResult> {
|
|
const params = opts?.refresh ? { refresh: true } : {};
|
|
return (
|
|
(await client.request<ModelAuthStatusResult>("models.authStatus", params)) ?? EMPTY_AUTH_STATUS
|
|
);
|
|
}
|