clients/apps/cli/src
Andreas Coroiu 35d25b7f8e
[PM-24047] Make popout windows respect vault timeout when unfocused (#19019)
* PM-24047: Make popout windows respect vault timeout when unfocused

Replace the heartbeat message-passing mechanism for popup detection
with direct browser API queries (getContexts on MV3, getExtensionViews
on MV2/Safari) that can distinguish focused from unfocused popout
windows. Unfocused popout windows no longer prevent vault timeout.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* PM-24047: Add isAnyViewFocused(), revert isPopupOpen() to simple popup detection

Addresses PR review feedback by separating focus-aware logic from the
isPopupOpen() semantics, which other callers depend on for simple
popup detection:

- BrowserApi.isPopupOpen(): reverted to return views.length > 0 for
  popup-type views only (original behavior)
- BrowserApi.isAnyViewFocused(): new method that checks popup views
  (always focused), sidebar tab views (always focused), and popout
  tab views (focused only if document.hasFocus() is true)
- BrowserPlatformUtilsService.isPopupOpen(): simplified MV3 path
  uses getContexts({ contextTypes: ['POPUP'] })
- BrowserPlatformUtilsService.isAnyViewFocused(): new method with
  MV3 (POPUP/SIDE_PANEL/focused TAB) and MV2/Safari paths
- PlatformUtilsService: adds isAnyViewFocused() to the interface
- Web/Desktop/CLI stubs return false (no popout windows)
- VaultTimeoutService now calls isAnyViewFocused() instead of
  isPopupOpen() so unfocused popouts don't block vault timeout

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* PM-24047: Move MV3/MV2 routing into BrowserApi

isPopupOpen() and isAnyViewFocused() now use feature detection for
chrome.runtime.getContexts to select the right API internally,
rather than having the routing in BrowserPlatformUtilsService.
This means BrowserApi is the single owner of view-detection logic,
and the service methods are simple one-line delegations.

Using typeof getContexts === "function" rather than isManifestVersion()
handles Safari naturally: if Safari doesn't support getContexts it
falls back to getExtensionViews, without needing an explicit isSafari()
exclusion.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* PM-24047: Scope MV3/MV2 routing refactor to isAnyViewFocused only

isPopupOpen() keeps its existing pattern (MV3/MV2 routing in the
service, simple getExtensionViews in BrowserApi) to avoid touching
unrelated code. Only isAnyViewFocused() has its routing moved into
BrowserApi via feature detection.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* PM-24047: Restore isPopupOpen to main branch implementation

isPopupOpen() and its tests are restored exactly to the main branch
version (heartbeat-based approach). Only isAnyViewFocused is new code.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* PM-24047: Refactor isPopupOpen() to use getContexts/getViews instead of heartbeat

Replaces the message-passing heartbeat approach with the same
chrome.runtime.getContexts() (MV3) / chrome.extension.getViews() (MV2/Safari)
introspection pattern used by isAnyViewFocused(). This eliminates the need
for a heartbeat listener in the popup and makes both methods consistent.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* PM-24047: Simplify isAnyViewFocused() using Array.some()

Collapse the two separate POPUP/SIDE_PANEL checks into a single .some()
call, and replace the synchronous MV2/Safari tab view loop with .some().
The async TAB/popout window check stays as a for loop.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* PM-24047: improve tabs loop readability somewhat

* PM-24047: Fix MV3 popout focus check using wrong uilocation filter

The TAB context filter was checking for `uilocation=sidebar` instead of
`uilocation=popout`. In MV3, sidebars are SIDE_PANEL contexts (already
handled above), so this filter never matched, causing focused popout
windows to be silently ignored and the vault to timeout while a user was
actively viewing one.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* PM-24047: Rename isViewOpen to isViewFocused for semantic accuracy

The variable and parameter previously named isViewOpen reflected
the old "is any view open?" semantics. After the refactor to
isAnyViewFocused(), the naming is updated to match the actual
behavior: checking whether a view is focused, not merely open.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-11 14:10:32 +01:00
..
admin-console [PM-26485] Add member status validation to CLI confirm command (#18557) 2026-02-09 11:38:00 +00:00
auth/commands [PM-31406] fix: TypeScript 5.9 type compatibility fixes for auth-owned code (#19187) 2026-03-04 19:12:44 -07:00
commands [PM-32442] Enforce tsc-strict on desktop and CLI apps (#19058) 2026-02-24 09:20:44 +01:00
key-management [PM-31049] Enable unlock via SDK (#18907) 2026-03-10 11:47:04 +01:00
locales/en [PM-31731] [Defect] No error is returned when entering an invalid email + an invalid verification code (#18913) 2026-02-18 14:08:57 -08:00
models [PM-18576] Fix missing user id on remove password (#13777) 2025-05-19 08:51:46 +02:00
platform [PM-24047] Make popout windows respect vault timeout when unfocused (#19019) 2026-03-11 14:10:32 +01:00
service-container [PM-31049] Enable unlock via SDK (#18907) 2026-03-10 11:47:04 +01:00
tools [PM-24102] Remove encstring decrypt function (#17108) 2026-03-03 14:57:05 +01:00
vault [PM-31406] fix: TypeScript 5.9 type compatibility fixes for vault-owned code (#19191) 2026-02-25 10:04:23 +01:00
base-program.ts [PM-31049] Enable unlock via SDK (#18907) 2026-03-10 11:47:04 +01:00
bw.ts Improve SDK direct function usage (#13353) 2025-02-26 09:08:42 +01:00
oss-serve-configurator.ts [PM-31049] Enable unlock via SDK (#18907) 2026-03-10 11:47:04 +01:00
program.ts [PM-31049] Enable unlock via SDK (#18907) 2026-03-10 11:47:04 +01:00
register-oss-programs.ts [PM-30922] Client changes to encrypt send access email list (#18486) 2026-01-28 14:31:48 -07:00
serve.program.ts [BEEEP: PM-10190] Use strict TS checks in CLI service container (#10298) 2024-08-05 11:39:08 -04:00
utils.ts [PM-32442] Enforce tsc-strict on desktop and CLI apps (#19058) 2026-02-24 09:20:44 +01:00
vault.program.ts [PM-22434] Remove CreateDefaultLocation feature flag references and definition (#18057) 2026-01-05 16:25:57 -06:00