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

Closed
kayg wants to merge 0 commits from issue/287-glass-flicker into dev
Owner

Closes #287. Based on #283's head (issue/269-one-bar, which carries #280), because the bar now lives in the shared @calternal/ui/bar and Morph. Current dev is merged in (conflicts in theme.svelte.ts and Backdrop.svelte are resolved). Merge #283 first.

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.

Tests: glass, page-chrome, tabs, keyboard, bar-focus, editor and phone-bars pass in chromium-1440, chromium-390, webkit-1440 and webkit-390. Failures that also fail on dev or on #283's head here: switching.spec:68 (walk frames) and toast-bar.spec (#283's "Note info" test; webkit toast-bar:14 also fails on dev). bar-focus webkit-390 timed out once under load and passes alone.

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.

#304 (#293) adds syncThemeColor calls through page-dim.ts. syncThemeColor now writes only on change. page-dim's own root.dataset.dim toggle should use setRootData when it lands.

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. **Based on #283's head** (`issue/269-one-bar`, which carries #280), because the bar now lives in the shared `@calternal/ui/bar` and Morph. Current `dev` is merged in (conflicts in `theme.svelte.ts` and `Backdrop.svelte` are resolved). Merge #283 first. **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. **Tests:** glass, page-chrome, tabs, keyboard, bar-focus, editor and phone-bars pass in chromium-1440, chromium-390, webkit-1440 and webkit-390. Failures that also fail on `dev` or on #283's head here: `switching.spec:68` (walk frames) and `toast-bar.spec` (#283's "Note info" test; webkit toast-bar:14 also fails on dev). `bar-focus` webkit-390 timed out once under load and passes alone. **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. **#304 (#293)** adds `syncThemeColor` calls through `page-dim.ts`. `syncThemeColor` now writes only on change. `page-dim`'s own `root.dataset.dim` toggle should use `setRootData` when it lands. **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
Phone: text bar while typing; the bar never takes focus; sheets fit above the keyboard (#268)
Some checks failed
CI / server (pull_request) Successful in 22s
CI / web (pull_request) Failing after 24s
CI / rust (pull_request) Successful in 1m53s
4c15a581b2
- Caret in the text on a phone: the bar is the text bar. The note tools
  (Log, Insert, Style, Info, Source) show when the keyboard is down, or
  blocks are selected.
- Nothing in the bar or its sheets takes focus from the text: presses keep
  focus (pointerdown and mousedown), and actions only refocus the editor if
  it really lost focus. Focusing an already focused editor made iOS move
  its keyboard.
- B, I, S, code and highlight with just a caret start the mark right there.
- Sheets are never taller than what you can see above the bar
  (--sheet-room from the visual viewport).
- e2e/bar-focus: with a faked keyboard, every text-bar button and the
  Style sheet's controls keep focus in the text; the sheet fits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
e2e: on a phone, the note tools are there with the keyboard down (#268)
Some checks failed
CI / web (pull_request) Failing after 36s
CI / server (pull_request) Successful in 53s
CI / rust (pull_request) Successful in 1m33s
541d5bdacd
editor.spec and day.spec put the keyboard down before using the note tools
at phone width; keyboardDown lives in viewport.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
One bar for every mode: shared Bar, registered modes, one look (#269)
Some checks failed
CI / server (pull_request) Successful in 23s
CI / web (pull_request) Failing after 24s
CI / rust (pull_request) Successful in 1m44s
f42f3c59d4
- @calternal/ui/bar: Bar (the capsule frame: Morph with its glass, halo
  and spring, the keep-focus rule from #268, the phone scrim), barModes
  (each mode a registered plugin: role, label, component) and pick.ts
  (#268's rule for which mode shows, unit tested).
- styles/bar.css: the rows, pills, tabs, toast and question styles, once,
  for the app and the mockup (the mockup's pill tabs on a phone).
- The app's modes are small files in components/bar (tabs, note tools, text
  bar, block bar, sheets, toast, ask); BottomBar only picks and hands them a
  context. The mockup's bar is the same Bar with the same styles.
- On a phone the question's answer no longer takes focus (#268).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: 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
Author
Owner

Replaced by #383: the same work with current dev (63ef0f6, after #376) merged in.

Replaced by #383: the same work with current dev (63ef0f6, after #376) merged in.
kayg closed this pull request 2026-10-14 23:37:32 +00:00
Some checks failed
CI / server (pull_request) Successful in 20s
CI / rust (pull_request) Successful in 1m42s
CI / web (pull_request) Failing after 2m15s

Pull request closed

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!374
No description provided.