From 04e727fa8632595a1c8ec4be3330ea680158ec0a Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sun, 6 Sep 2026 14:12:24 -0700 Subject: [PATCH] refactor(ui): fold the sidebar overlay exemption into the selector Match the existing self-exclusion convention used by useWorkspaceBoardPanel and AgentDashboardDrawer instead of a separate matches() guard, and drop the non-null assertion from the test. No behavior change. --- src/renderer/src/lib/visible-overlay.test.ts | 2 +- src/renderer/src/lib/visible-overlay.ts | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/renderer/src/lib/visible-overlay.test.ts b/src/renderer/src/lib/visible-overlay.test.ts index 5b486450ce7..4fa99e0be23 100644 --- a/src/renderer/src/lib/visible-overlay.test.ts +++ b/src/renderer/src/lib/visible-overlay.test.ts @@ -35,7 +35,7 @@ describe('hasVisibleOverlay', () => { expect(hasVisibleOverlay()).toBe(false) - document.querySelector('[data-worktree-sidebar]')!.innerHTML = '
' + mount('
') expect(hasVisibleOverlay()).toBe(true) }) diff --git a/src/renderer/src/lib/visible-overlay.ts b/src/renderer/src/lib/visible-overlay.ts index 6892010b4df..44dc14a514a 100644 --- a/src/renderer/src/lib/visible-overlay.ts +++ b/src/renderer/src/lib/visible-overlay.ts @@ -1,4 +1,6 @@ -const OVERLAY_SELECTOR = '[role="dialog"], [role="alertdialog"], [role="listbox"], [role="menu"]' +// The always-mounted worktree sidebar is page chrome, not an Escape-owning popup. +const OVERLAY_SELECTOR = + '[role="dialog"], [role="alertdialog"], [role="listbox"]:not([data-worktree-sidebar]), [role="menu"]' type VisibleOverlayOptions = { /** Overlays inside a match are treated as page content, not as a layer above it. */ @@ -15,10 +17,6 @@ export function hasVisibleOverlay(options?: VisibleOverlayOptions): boolean { if (!(element instanceof HTMLElement)) { return false } - // The persistent workspace list is page chrome, not an Escape-owning popup. - if (element.matches('[role="listbox"][data-worktree-sidebar]')) { - return false - } if (element.closest('[aria-hidden="true"]')) { return false }