mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-17 23:01:36 +00:00
Refactor the Control UI around route-owned page lifecycle and state while preserving existing behavior and design.
Prepared head SHA: bd51b6fa76
Co-authored-by: Shakker <165377636+shakkernerd@users.noreply.github.com>
Reviewed-by: @shakkernerd
21 lines
939 B
TypeScript
21 lines
939 B
TypeScript
// Control UI shared Gateway error helpers.
|
|
import { ConnectErrorDetailCodes } from "../../../packages/gateway-protocol/src/connect-error-details.js";
|
|
import { GatewayRequestError, resolveGatewayErrorDetailCode } from "../api/gateway.ts";
|
|
|
|
export function isMissingOperatorReadScopeError(err: unknown): boolean {
|
|
if (!(err instanceof GatewayRequestError)) {
|
|
return false;
|
|
}
|
|
const detailCode = resolveGatewayErrorDetailCode(err);
|
|
// AUTH_UNAUTHORIZED is the current server signal for scope failures in RPC responses.
|
|
// The message-based branch catches responses that do not include a structured detail code yet.
|
|
return (
|
|
detailCode === ConnectErrorDetailCodes.AUTH_UNAUTHORIZED ||
|
|
err.message.includes("missing scope: operator.read")
|
|
);
|
|
}
|
|
|
|
export function formatMissingOperatorReadScopeMessage(feature: string): string {
|
|
return `This connection is missing operator.read, so ${feature} cannot be loaded yet.`;
|
|
}
|