Glass: no flicker on bar morphs, tab switches, hovers or typing (#287) #383

Merged
kayg merged 8 commits from issue/287-glass-flicker-2 into dev 2026-10-15 01:40:25 +00:00
Owner

Closes #287. Replaces #374: the same work with current dev (63ef0f6, after #376 / train #381) merged in. Conflicts are resolved keeping both sides: the PhoneStack note screen (#285, #294), Settings' {active} bar (no toasts in the hidden tab), the keyboard room (#290), plainRgb in theme-color (#304), the input-source signal (#344), and dev's tabs and keyboard test fixes. Morph keeps #376's keyboard early returns in enter and exit.

Causes, proven on the issue (frame data, CDP LayerTree, Animation and a per-frame watcher): #287

  1. Tab switch (Notes ⇄ Settings): opacity faded the whole tab layer, which is a backdrop root for every pane. The panes showed the sharp photo for the whole fade, then snapped back to frosted.
  2. Coming back from visibility: hidden: the first frame's glass blurs nothing, so there was one dark frame on every switch.
  3. Bar glass held its contents: hover tints repainted the glass layer (21 repaints → 0), the morph fades gained and lost child layers inside it, and the halo flipped in and out of its own layer. The bar also sat inside the Settings card's glass (glass in glass), and the phone note screen had a needless blur that made it a backdrop root.
  4. Browser chrome flicker: every route change replaced route.query and woke the theme and backdrop effects. They rewrote theme-color and the root's vars on every bar morph (4–8 writes) and on every key in search (40 theme-color writes + 80 root style changes + 20 replaceState per 20 characters).
  5. Mockup grain still used mix-blend-mode (crbug 1348920).

Fix

  • Tabs: the glass switches at once and only what sits on it fades. The hidden screen is opacity: 0 + inert + aria-hidden.
  • Morph: the glass is a childless .morph-glass, the contents are on .morph-clip, the halo always has its own layer, and the away fade is on the glass layers rather than a parent. The springy morph is unchanged, and the bar looks the same (pixel difference < 0.2/255 in every mode, Chromium and WebKit, 1440/390/320).
  • Settings: the bar sits beside the card. Phone note screen: no blur behind its paper.
  • Route: changes are applied in place. A burst of changes to the same keys writes the address once as it starts and once when it stops.
  • New @calternal/ui/lib/page-chrome (setThemeColor, setRootVar, setRootData, applyRoute): it writes only on a real change. Used by the theme, backdrop, keyboard and input flag in both apps.
  • Mockup grain: plain paint, as in the app.

Guards: glass.spec checks every frame for backdrop roots (including animated ones), that the bar glass has no children, one-frame flashes on the panes and halo, and frames in between on a tab switch. All three new checks fail before this change and pass after. page-chrome.spec: typing 20 characters and a bar morph cause 0 theme-color writes, no root changes, and at most 1 address write after typing stops. tabs.spec now takes the note's address once the editor is live.

Merge follow-ups:

  • page-dim's data-dim now uses setRootData, which now takes null to remove a key.
  • The phone stack's data-edge is written only on change and removed only when the stack goes.
  • glass.spec's at-rest check also ignores the hidden tab at opacity 0 (opacityProperty).
  • The glass and clip layers carry data-morph-until like the capsule, so the layout-shift checks in editor.spec and prefs-offline.spec treat them as the morph.

Tests: glass, page-chrome, tabs, keyboard, bar-stable, bar-stays, phone-bars, phone-edges, safe-areas, toast-bar, prefs and prefs-offline ran on chromium and webkit at 390 and 1440: 853 passed. Two failed:

  • bar-stays.spec:77 on webkit-390, the link-chip tap. It fails 3 of 3 on dev here as well.
  • prefs-offline:107 on prefs-chromium, a layout shift on .morph-glass. That one is mine and is fixed in the last commit. I reran prefs-offline once after the fix, on prefs-chromium only (prefs-webkit not run), and it passed. editor.spec passed 3 of 3 on chromium-390 and webkit-390.

safe-areas.spec:142, the box-shadow caught mid-transition, passes 3 of 3 on chromium-390 and 3 of 3 on webkit-390. It also passed in the full run. It is skipped at 1440 by design.

Perf: CSS and a few small JS changes. Less work while typing and on morphs: no theme or backdrop effect re-runs, no root style writes, one history call per burst. The hidden tab is now painted at opacity 0 rather than skipped; it is static, so it costs nothing per frame.

kayg, please confirm on the Mac: the steps are on the issue (tab switching, bar hover and morph, typing).

🤖 Generated with Claude Code

https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T

Closes #287. Replaces #374: the same work with current `dev` (63ef0f6, after #376 / train #381) merged in. Conflicts are resolved keeping both sides: the PhoneStack note screen (#285, #294), Settings' `{active}` bar (no toasts in the hidden tab), the keyboard room (#290), `plainRgb` in theme-color (#304), the input-source signal (#344), and dev's tabs and keyboard test fixes. Morph keeps #376's keyboard early returns in enter and exit. **Causes, proven on the issue** (frame data, CDP LayerTree, Animation and a per-frame watcher): https://git.kayg.org/kayg/calternal/issues/287 1. **Tab switch (Notes ⇄ Settings):** `opacity` faded the whole tab layer, which is a backdrop root for every pane. The panes showed the sharp photo for the whole fade, then snapped back to frosted. 2. **Coming back from `visibility: hidden`:** the first frame's glass blurs nothing, so there was one dark frame on every switch. 3. **Bar glass held its contents:** hover tints repainted the glass layer (21 repaints → 0), the morph fades gained and lost child layers inside it, and the halo flipped in and out of its own layer. The bar also sat inside the Settings card's glass (glass in glass), and the phone note screen had a needless blur that made it a backdrop root. 4. **Browser chrome flicker:** every route change replaced `route.query` and woke the theme and backdrop effects. They rewrote `theme-color` and the root's vars on every bar morph (4–8 writes) and on every key in search (40 theme-color writes + 80 root style changes + 20 `replaceState` per 20 characters). 5. **Mockup grain still used `mix-blend-mode`** (crbug 1348920). **Fix** - Tabs: the glass switches at once and only what sits on it fades. The hidden screen is `opacity: 0` + `inert` + `aria-hidden`. - `Morph`: the glass is a childless `.morph-glass`, the contents are on `.morph-clip`, the halo always has its own layer, and the away fade is on the glass layers rather than a parent. The springy morph is unchanged, and the bar looks the same (pixel difference < 0.2/255 in every mode, Chromium and WebKit, 1440/390/320). - Settings: the bar sits beside the card. Phone note screen: no blur behind its paper. - Route: changes are applied in place. A burst of changes to the same keys writes the address once as it starts and once when it stops. - New `@calternal/ui/lib/page-chrome` (`setThemeColor`, `setRootVar`, `setRootData`, `applyRoute`): it writes only on a real change. Used by the theme, backdrop, keyboard and input flag in both apps. - Mockup grain: plain paint, as in the app. **Guards:** `glass.spec` checks every frame for backdrop roots (including animated ones), that the bar glass has no children, one-frame flashes on the panes and halo, and frames in between on a tab switch. All three new checks fail before this change and pass after. `page-chrome.spec`: typing 20 characters and a bar morph cause 0 theme-color writes, no root changes, and at most 1 address write after typing stops. `tabs.spec` now takes the note's address once the editor is live. **Merge follow-ups:** - `page-dim`'s `data-dim` now uses `setRootData`, which now takes `null` to remove a key. - The phone stack's `data-edge` is written only on change and removed only when the stack goes. - glass.spec's at-rest check also ignores the hidden tab at opacity 0 (`opacityProperty`). - The glass and clip layers carry `data-morph-until` like the capsule, so the layout-shift checks in editor.spec and prefs-offline.spec treat them as the morph. **Tests:** glass, page-chrome, tabs, keyboard, bar-stable, bar-stays, phone-bars, phone-edges, safe-areas, toast-bar, prefs and prefs-offline ran on chromium and webkit at 390 and 1440: 853 passed. Two failed: - `bar-stays.spec:77` on webkit-390, the link-chip tap. It fails 3 of 3 on `dev` here as well. - `prefs-offline:107` on prefs-chromium, a layout shift on `.morph-glass`. That one is mine and is fixed in the last commit. I reran prefs-offline once after the fix, on prefs-chromium only (prefs-webkit not run), and it passed. editor.spec passed 3 of 3 on chromium-390 and webkit-390. `safe-areas.spec:142`, the box-shadow caught mid-transition, passes 3 of 3 on chromium-390 and 3 of 3 on webkit-390. It also passed in the full run. It is skipped at 1440 by design. **Perf:** CSS and a few small JS changes. Less work while typing and on morphs: no theme or backdrop effect re-runs, no root style writes, one history call per burst. The hidden tab is now painted at opacity 0 rather than skipped; it is static, so it costs nothing per frame. **kayg, please confirm on the Mac:** the steps are on the issue (tab switching, bar hover and morph, typing). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Causes found and fixed:
- Tab switch (Notes/Settings) faded the whole screen with opacity, a backdrop root
  for every pane: the panes showed the sharp photo for the fade, then snapped back.
  Now each part fades on its own (glass fades itself), and the hidden screen is kept
  at opacity 0 rather than visibility: hidden, whose first frame back blurred nothing.
- The bar's glass held its contents: hover tints and morph fades repainted and
  re-layered the glass itself. The glass is now a childless layer under the contents.
- The bar sat inside Settings' glass card (glass in glass); phone note screen had a
  needless blur that made it a backdrop root. Both gone.
- Route updates replaced the whole query, waking the theme and backdrop effects on
  every bar morph and keystroke: theme-color and root styles were rewritten each time
  (the browser chrome flicker). Route state now changes in place, query writes reach
  the address once typing stops, and theme-color / root vars are written only on change.
- Mockup grain still used mix-blend-mode (crbug 1348920); now plain paint as in the app.

Guards: glass.spec (backdrop roots every frame, childless bar glass, one-frame flashes,
tab switch frames), page-chrome.spec (0 theme-color writes, <=1 URL write).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Tabs: the glass switches at once, frosted on every frame; only what sits on it fades (#287)
Some checks failed
CI / server (pull_request) Successful in 20s
CI / rust (pull_request) Successful in 1m42s
CI / web (pull_request) Failing after 2m15s
8e679b3776
Opacity on a screen or on a pane fades its blur (the sharp photo showed through, then
snapped back); new glass over old stacks two tints and snaps lighter at the end. The
guard now also counts an animated opacity on a glass holder as a cut.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Morph: the glass and the clip carry the morph window too; layout-shift checks know them (#287)
Some checks failed
CI / server (pull_request) Successful in 19s
CI / rust (pull_request) Successful in 1m39s
CI / web (pull_request) Failing after 39m56s
42b7a8e043
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
kayg merged commit 1a0724ffff into dev 2026-10-15 01:40:25 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal!383
No description provided.