Commit graph

4 commits

Author SHA1 Message Date
AK
d3d35bcb42 perf(fullscreen): subscribe to SettingsUpdated, not every ctx NewState
The previous NewState listener fired on every change to the ctx model —
notifications, search history, library sync, streaming-server URL — and
each fire triggered a getState('ctx') round-trip to the worker just to
re-read escExitFullscreen.

Switch to the CoreEvent / SettingsUpdated channel (same pattern App.js
uses for interfaceLanguage/quitOnClose), reading the new value straight
from the event payload. Initial seed still uses getState('ctx') once
on mount.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-28 01:26:42 -04:00
AK
90e2cbff15 chore(fullscreen): drop ts-expect-error, type ctx + NewState properly
useServices is already typed via src/services/ServicesContext/useServices.d.ts,
so the @ts-expect-error suppression on the import was unnecessary and
masked two real type holes that surfaced once it was removed:

- core.transport.getState('ctx') returns Promise<object>; cast to the
  ambient Ctx type so escExitFullscreen is read through a typed path.
- CoreTransport.on/off types listeners as () => void, but the 'NewState'
  event actually emits a string[]. Use a (...args: unknown[]) wrapper +
  Array.isArray narrowing so the call site stays type-safe without
  weakening the ambient transport signature.

No behavior change.

Made-with: Cursor
2026-04-28 00:57:53 -04:00
AK
2e13a60007 fix(fullscreen): read settings via core.transport, not useSettings
FullscreenProvider sits above the router, but useSettings() ->
useProfile() -> useModelState() requires CoreSuspenderContext which is
only provided by withCoreSuspender below the router. Mounting the
provider therefore crashed with "Cannot read properties of null
(reading 'getState')".

Switch the provider to read profile.settings.escExitFullscreen directly
from core.transport.getState('ctx') and refresh on the 'NewState' event
when 'ctx' changes. core is available via useServices(), whose provider
sits at the very top of the tree and is always reachable here.

Behavior is preserved: ESC still exits fullscreen iff the user has the
escExitFullscreen setting enabled, and updates to that setting from the
Settings tab take effect on the next ctx NewState push.

Made-with: Cursor
2026-04-27 01:56:02 -04:00
AK
60df6860d7 feat(common): add FullscreenProvider + context module
Introduce a single, app-root-owned source of truth for fullscreen state,
mirroring the existing provider pattern (ToastProvider, FileDropProvider).
The provider centralizes the fullscreenchange / win-visibility-changed /
keydown listeners and exposes the same [fullscreen, requestFullscreen,
exitFullscreen, toggleFullscreen] tuple that consumers already destructure.

Not yet wired up - both the legacy src/common/useFullscreen hook and the
new module coexist. Subsequent commits mount the provider in App.js and
switch consumers over.

Made-with: Cursor
2026-04-27 01:50:14 -04:00