PlotDirector/Docs/PWA/First-Paint.md
Nick Beckley e48889ac05 Complete desktop workspaces, context menus and plot health
Commit the pending application, help and browser regression work. Pin the patched PKCS dependency for the production release.
2026-10-31 09:27:04 +00:00

5.0 KiB
Raw Blame History

PWA first paint and contextual ribbon activation

Cause

Previously _Layout loaded both application-pwa.js and application-page-context.js with defer. The first established data-standalone only after HTML parsing. The second discovered declared regions by querying the completed main subtree, built their controls and only then marked browser furniture as accounted for. Until both ran, PWA CSS could not suppress that furniture. Content volume increased parser time and full-subtree discovery/observation work before this transition. There was no persistent display-mode state. Each full navigation repeated this lifecycle; individual page declarations were not themselves performing standalone detection.

Corrected lifecycle

  • application-display-mode.js is a small parser-blocking head bootstrap with no body/layout dependency. It seeds the shared shell state from window-scoped sessionStorage (plotdirector.displayMode) and immediately verifies it synchronously using display-mode: standalone / iOS navigator.standalone, before body paint. Authoritative detection always wins, even when storage is denied or a browser tab inherits a stale standalone hint. Media changes and pageshow revalidate; unchanged state does not reconstruct the ribbon. There is no unknown-mode content guard, spinner, animation or delay.
  • Razor already renders a view before its layout. RibbonContributionTagHelper records only explicitly declared contribution/identity regions during that render. The layout emits their inert snapshot immediately after the application header, and preloads/runs the existing composer there, before the workspace. No second command framework, database mode, auth cookie or second ribbon is introduced.
  • The same validation/composition logic prepares the snapshot's commands, semantic deduplication, icons, responsive sizing and exact CSS selectors for furniture positively accounted for. Those selectors are PWA-only and exist before the real workspace nodes are parsed. Unsupported forms and meaningful task content stay visible; browser mode never hides its headers while waiting for a reveal pass.
  • Actual contribution regions register themselves as they parse. At the end of main, the composer binds to these small source regions, retains original routes/forms/handlers/confirmations and removes the inert snapshot/temporary selector rules. It does not need to traverse manuscript/card content to discover initial commands. Early interactions resolve to the actual registered source when available. Existing explicit context events and mutation handling remain for partial replacement, with the existing fallback discovery for newly inserted regions.
  • Timing entries pd-ribbon-initial-compose and pd-ribbon-activate expose shell composition and binding time to browser tooling. No telemetry or user data is emitted.

Verification

The focused first-paint browser check pauses the parser after real Story Bible content plus 2,500 additional fixture cards, before main activation, deferred scripts and DOM-ready. It samples and screenshots that otherwise exposed intermediate paint, checks hidden browser identity/actions and an already composed visible ribbon/search, then releases parsing and compares command identity/order and workspace position. Scenarios cover cleared session state, subsequent PWA navigation, real reload, a stale standalone hint in a normal browser and browser reload. Separate display-mode checks cover denied storage, media changes and unchanged pageshow restoration. The existing 20-view/six-theme/responsive/form/permission/collapse suite remains the regression guard.

Final results (30 October 2026):

  • Solution build, Release publish and all 374 executable regressions pass. Existing package advisories remain unchanged.
  • Focused display-mode checks pass. Parser-paused checks pass in both the isolated Razor host and the real authenticated Dev layout. Live initial PWA composition measured 17.7–32 ms; cold, navigation and reload each measured 0 px of workspace movement across activation. Normal browser cold loads, stale-hint correction, navigation and reload retain conventional headers/actions with no reverse flash. These are targeted shell-transition measurements, not a claim of zero cumulative layout shift from every asynchronous workspace/image operation.
  • Existing 20-view, all-six-theme, 2560/1440/900 installed-PWA suite passes, including search, semantic deduplication, fragments, keyboard, forms, permissions, confirmations and collapse. Toolbar and sticky-shell suites pass.
  • Live normal-browser/installed-PWA smoke passes on 42 Dev routes, with 2560/1920/900 layout and all-six-theme checks. Inspected the actual parser-paused PWA/browser captures; the PWA ribbon is already visible while the document is still loading.
  • Dev release: 340c5e3-pwa-firstpaint-v1-worktree-20261030T152631Z. Published/deployed DLL hash matches. Temporary verification identity and owned project/book are removed with the normal account-deletion workflow. Production remains untouched.