Skip to content

Commit ac18201

Browse files
committed
fix(ui): gate settings Escape on the approval dialog's recorded open state
ClawSweeper caught that shouldIgnoreSettingsEscape still inferred an open approval dialog from queue non-emptiness; with passive approvals a pending queue no longer implies a visible dialog, so settings would swallow Escape. The exec-approval element now records dialogOpen as a fact and the guard reads it.
1 parent ffc54ab commit ac18201

4 files changed

Lines changed: 29 additions & 3 deletions

File tree

‎ui/src/app/app-host.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class OpenClawShell
137137
readonly execApprovalElement = EXEC_APPROVAL_ELEMENT;
138138
@query("openclaw-command-palette") commandPalette: CommandPaletteElement | undefined;
139139
@query("openclaw-exec-approval")
140-
approvalOverlay: (HTMLElement & { show(): void }) | undefined;
140+
approvalOverlay: (HTMLElement & { show(): void; dialogOpen?: boolean }) | undefined;
141141
commandPaletteTarget: CommandPaletteTargetDetail | undefined;
142142
navDrawerTrigger: HTMLElement | null = null;
143143
// Desktop and modal navigation are two slots for the same live sidebar.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export interface ShellChromeHost extends HTMLElement {
7474
readonly desktopPanelElement: OptionalCustomElement;
7575
readonly execApprovalElement: OptionalCustomElement;
7676
readonly commandPalette: CommandPaletteElement | undefined;
77-
readonly approvalOverlay: (HTMLElement & { show(): void }) | undefined;
77+
readonly approvalOverlay: (HTMLElement & { show(): void; dialogOpen?: boolean }) | undefined;
7878
routeState: ShellRouteState;
7979
navDrawerOpen: boolean;
8080
desktopNavigationExpanded: boolean;
@@ -407,7 +407,7 @@ export class ShellChromeOwner {
407407
if (
408408
host.commandPalette?.isOpen ||
409409
overlaySnapshot?.devicePairSetupOpen ||
410-
(overlaySnapshot?.approvalQueue.length ?? 0) > 0 ||
410+
host.approvalOverlay?.dialogOpen === true ||
411411
document.querySelector("dialog[open]")
412412
) {
413413
return true;

‎ui/src/components/exec-approval.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,25 @@ describe("openclaw-exec-approval", () => {
314314
expect(container.querySelector("openclaw-modal-dialog")).not.toBeNull();
315315
});
316316

317+
// Settings Escape guards read this fact; a pending queue alone must not
318+
// report an open dialog now that approvals surface passively.
319+
it("records dialogOpen only while the dialog is explicitly open", async () => {
320+
const { approval } = await renderApproval(createExecRequest());
321+
const element = approval as LitElement & { show(): void; dialogOpen: boolean };
322+
expect(element.dialogOpen).toBe(false);
323+
324+
element.show();
325+
await approval.updateComplete;
326+
expect(element.dialogOpen).toBe(true);
327+
328+
const { modal } = await getRenderedModalDialog(container);
329+
modal.dispatchEvent(
330+
new CustomEvent("modal-cancel", { bubbles: true, composed: true, cancelable: true }),
331+
);
332+
await approval.updateComplete;
333+
expect(element.dialogOpen).toBe(false);
334+
});
335+
317336
it("opens the full queue only on demand", async () => {
318337
const queue = [
319338
createExecRequest({ id: "approval-inline" }),

‎ui/src/components/exec-approval.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ class ExecApproval extends OpenClawLightDomContentsElement {
102102
void this.updateComplete.then(() => this.dialog?.show());
103103
}
104104

105+
/** Recorded fact for shell guards (settings Escape): the dialog renders in
106+
* shadow DOM, so `document.querySelector("dialog[open]")` cannot see it, and
107+
* a pending queue no longer implies a visible dialog. */
108+
get dialogOpen(): boolean {
109+
return this.explicitlyOpen && (this.props?.queue.length ?? 0) > 0;
110+
}
111+
105112
private handleKeydown(event: KeyboardEvent, active: ExecApprovalRequest): void {
106113
// A held chord auto-repeats: once a decision settles and the queue
107114
// advances, the repeat would apply the same decision to the next request.

0 commit comments

Comments
 (0)