Skip to content

Commit 48a2b45

Browse files
fix: stop limited access status from shifting page layouts (#127704)
* fix(ui): move limited access status into shell chrome * fix(ui): cover tablet limited access layout --------- Co-authored-by: RoboClaw <[email protected]>
1 parent 1bd5f22 commit 48a2b45

20 files changed

Lines changed: 776 additions & 570 deletions

‎docs/web/control-ui.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ If the browser retries pairing with changed auth details (role/scopes/public key
6666

6767
Switching an already-paired browser from read access to write/admin access through ordinary stored or shared credentials is treated as an approval upgrade, not a silent reconnect: OpenClaw keeps the old approval active, blocks the broader reconnect, and asks you to approve the new scope set explicitly. The narrow exception is a fresh owner handoff issued on the Gateway host by `openclaw dashboard` or graphical onboarding; it can upgrade only the same signed browser that redeems that one-time handoff.
6868

69-
When the connected Control UI reports limited access, click **Request admin** in the access banner. You can collapse the banner into a persistent **Limited access** chip and click the chip whenever you need the full explanation or request action again. The browser files the same pending device scope-upgrade request over its existing connection; approve it with `openclaw devices` on the Gateway host or from **Devices** in another admin-capable browser that also has `operator.pairing`. Keep the requesting tab connected while approval completes so it can receive and store the freshly rotated device token before reconnecting. **Retry** reattaches to the pending request. **Cancel** stops the local wait but does not reject the device request; if you cancel or disconnect before approval, use the normal pairing repair path on the next connection.
69+
When the connected Control UI reports limited access, select the shield-question status beside Search, then click **Request admin** in the access details. On mobile, those details open as a bottom sheet; narrow session chat keeps the same status inside its overflow menu. The browser files the pending device scope-upgrade request over its existing connection; approve it with `openclaw devices` on the Gateway host or from **Devices** in another admin-capable browser that also has `operator.pairing`. Keep the requesting tab connected while approval completes so it can receive and store the freshly rotated device token before reconnecting. **Retry** reattaches to the pending request. **Cancel** stops the local wait but does not reject the device request; if you cancel or disconnect before approval, use the normal pairing repair path on the next connection.
7070

7171
Once approved, the device is remembered and won't require re-approval unless you revoke it with `openclaw devices revoke --device <id> --role <role>`. See [Devices CLI](/cli/devices) for token rotation, revocation, and the Paperclip / `openclaw_gateway` first-run approval flow.
7272

‎ui/src/app/app-shell-view.ts‎

Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ import type { OutboxStoreRuntime, StoredOutboxScopeHost } from "./app-shell-gate
2828
import type { ApplicationRuntime } from "./bootstrap.ts";
2929
import type { ApplicationContext, ApplicationNavigationOptions } from "./context.ts";
3030
import { resolveControlUiAuthToken } from "./control-ui-auth.ts";
31-
import {
32-
hasDismissedScopeUpgradeBanner,
33-
readScopeUpgradeAvailability,
34-
} from "./device-scope-upgrade.ts";
3531
import {
3632
DEBUG_OVERLAY_ELEMENT,
3733
isOptionalElementDefined,
@@ -55,44 +51,15 @@ const EMPTY_SESSION_HAS_DRAFT = () => false;
5551
const PALETTE_SHORTCUT = /Mac|iP(hone|ad|od)/i.test(globalThis.navigator?.platform ?? "")
5652
? "⌘K"
5753
: "Ctrl K";
58-
59-
const SCOPE_UPGRADE_BANNER_ELEMENT = {
54+
const SCOPE_UPGRADE_SURFACE_ELEMENT = {
6055
tagName: "openclaw-device-scope-upgrade-banner",
61-
label: "device scope upgrade banner",
62-
loadModule: () => import("./device-scope-upgrade.runtime.ts"),
56+
label: t("connection.scopeUpgrade.status"),
57+
loadModule: () =>
58+
import("./device-scope-upgrade.runtime.ts").catch(
59+
() => import("./device-scope-upgrade-retry.runtime.ts"),
60+
),
6361
} satisfies OptionalCustomElement;
6462

65-
function renderScopeUpgradeBanner(
66-
host: ShellViewHost,
67-
snapshot: ApplicationContext["gateway"]["snapshot"],
68-
compact: boolean,
69-
) {
70-
const state = readScopeUpgradeAvailability(snapshot);
71-
if (
72-
state.phase === "hidden" ||
73-
(state.phase === "guidance" && hasDismissedScopeUpgradeBanner())
74-
) {
75-
return nothing;
76-
}
77-
host.lazyCustomElements.preload(SCOPE_UPGRADE_BANNER_ELEMENT);
78-
if (isOptionalElementDefined(SCOPE_UPGRADE_BANNER_ELEMENT)) {
79-
return html`<openclaw-device-scope-upgrade-banner
80-
.props=${{
81-
snapshot,
82-
compact,
83-
}}
84-
></openclaw-device-scope-upgrade-banner>`;
85-
}
86-
return html`<openclaw-update-banner
87-
.props=${{
88-
statusBanner: {
89-
tone: "warn",
90-
text: t("connection.scopeUpgrade.guidance"),
91-
},
92-
}}
93-
></openclaw-update-banner>`;
94-
}
95-
9663
export interface ShellViewHost {
9764
readonly context: ApplicationContext<RouteId> | undefined;
9865
readonly runtime: ApplicationRuntime | undefined;
@@ -314,11 +281,28 @@ export function renderApplicationShell(host: ShellViewHost) {
314281
);
315282
const navDrawerOpen = host.navDrawerOpen && !onboarding;
316283
const mobileNavLayout = isMobileNavLayout();
284+
const nativeWebChrome = isNativeWebChromeHost();
317285
const mergedChatChrome = shouldMergeChatChrome({
318286
mobileNavLayout,
319287
routeId: activeRoute,
320288
onboarding,
321289
});
290+
const showScopeUpgradeStatus =
291+
gatewayConnected &&
292+
gatewaySnapshot.hello?.auth?.scopes !== undefined &&
293+
!operatorAccess.canAdmin;
294+
if (showScopeUpgradeStatus) {
295+
host.lazyCustomElements.preload(SCOPE_UPGRADE_SURFACE_ELEMENT, { reportError: true });
296+
}
297+
const scopeUpgradeSurface = showScopeUpgradeStatus
298+
? html`<openclaw-device-scope-upgrade-banner
299+
.props=${{
300+
snapshot: gatewaySnapshot,
301+
mobile: mobileNavLayout,
302+
showTrigger: !mergedChatChrome,
303+
}}
304+
></openclaw-device-scope-upgrade-banner>`
305+
: null;
322306
// Drawer navigation always opens expanded; the desktop collapse preference
323307
// stays persisted for when the viewport returns to the desktop layout.
324308
// The settings sidebar has a fixed width, so the collapse state pauses too.
@@ -500,7 +484,7 @@ export function renderApplicationShell(host: ShellViewHost) {
500484
@theme-change=${(event: CustomEvent<ThemeModeChangeDetail>) => host.handleThemeChange(event)}
501485
>
502486
<a class="shell-skip-link" href="#control-ui-main"> ${t("common.skipToMainContent")} </a>
503-
${isNativeWebChromeHost() && !onboarding
487+
${nativeWebChrome && !onboarding
504488
? html`
505489
<openclaw-macos-titlebar-controls
506490
.navCollapsed=${host.nativeNavCollapsed()}
@@ -519,6 +503,9 @@ export function renderApplicationShell(host: ShellViewHost) {
519503
<openclaw-app-topbar
520504
.resourceBasePath=${context.resourceBasePath}
521505
.navDrawerOpen=${navDrawerOpen}
506+
.trailingActions=${mobileNavLayout && !onboarding && !mergedChatChrome
507+
? scopeUpgradeSurface
508+
: nothing}
522509
.onOpenPalette=${() => host.openPalette()}
523510
.onToggleDrawer=${(trigger: HTMLElement) => host.toggleNavigationSurface(trigger)}
524511
></openclaw-app-topbar>
@@ -581,6 +568,7 @@ export function renderApplicationShell(host: ShellViewHost) {
581568
</div>
582569
`
583570
: nothing}
571+
${!mobileNavLayout || onboarding || mergedChatChrome ? scopeUpgradeSurface : nothing}
584572
<div class="shell-nav" ?inert=${navigationSurfaceHidden}>
585573
${mobileNavLayout
586574
? html`<openclaw-modal-dialog
@@ -617,7 +605,6 @@ export function renderApplicationShell(host: ShellViewHost) {
617605
: ""} ${activeRoute === "workboard" ? "content--workboard" : ""}"
618606
.tabIndex=${-1}
619607
>
620-
${renderScopeUpgradeBanner(host, gatewaySnapshot, mergedChatChrome)}
621608
${renderFloatingUpdateCard({
622609
navigationSurfaceHidden,
623610
mobileNavLayout,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { isGatewayMethodAdvertised } from "../lib/gateway-methods.ts";
2+
import type { ApplicationGatewaySnapshot } from "./gateway.ts";
3+
import { hasOperatorAdminAccess } from "./operator-access.ts";
4+
5+
export type ScopeUpgradeState =
6+
| { phase: "hidden" }
7+
| { phase: "guidance" }
8+
| { phase: "available" }
9+
| { phase: "requesting" }
10+
| { phase: "pending"; requestId: string }
11+
| { phase: "rejected"; requestId: string; expired: boolean }
12+
| { phase: "error"; message: string };
13+
14+
export function readScopeUpgradeAvailability(
15+
snapshot: ApplicationGatewaySnapshot,
16+
): ScopeUpgradeState {
17+
const auth = snapshot.hello?.auth;
18+
if (
19+
snapshot.phase !== "connected" ||
20+
auth?.scopes === undefined ||
21+
hasOperatorAdminAccess(auth)
22+
) {
23+
return { phase: "hidden" };
24+
}
25+
return isGatewayMethodAdvertised(snapshot, "device.scopes.requestUpgrade") === true &&
26+
isGatewayMethodAdvertised(snapshot, "device.scopes.waitUpgrade") === true &&
27+
snapshot.client?.scopeUpgradeReady === true
28+
? { phase: "available" }
29+
: { phase: "guidance" };
30+
}

0 commit comments

Comments
 (0)