Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(glass): glass never fades while it opens; both trap guards see motion (visual QA round 4 N4-H1, code review 6 #5-#7)
iceclatterWT9bd9b60ff6e2
diff --git a/scripts/glass-trap-probe.mjs b/scripts/glass-trap-probe.mjsindex f8a0fee99..dad41420e 100644--- a/scripts/glass-trap-probe.mjs+++ b/scripts/glass-trap-probe.mjs@@ -8,20 +8,53 @@* - it floats (absolute/fixed/sticky) over the nearest blurred or solid ancestor's content —* that content is sharp, and a blur inside a blurred ancestor samples only its pixels, or* - it has its own blur but sits inside a BACKDROP ROOT (an ancestor with backdrop-filter, filter,- * opacity < 1, mask, clip-path or a blend mode) and reaches outside that root's box: the part- * outside samples nothing, so whatever is behind it reads sharp through the tint.+ * opacity < 1, mask, mask-border, clip-path or a blend mode) and either reaches outside that+ * root's box, or the root paints no blur of its own and nothing opaque lies between them: the+ * blur then samples only the root's own pixels, and the page behind the root reads sharp+ * through it (visual QA round 4, N4-H1: a scrim fading its opacity turned the palette inside it+ * into clear glass for the whole fade).* `transform` and `isolation` are not backdrop roots (the React Flow viewport, `.dock`).+ * A fill is the background colour or any colour in a gradient `background-image`; `::before` and+ * `::after` layers are checked like elements.+ *+ * Two passes, both by default:+ * - at rest: what is on screen now;+ * - mid-animation: every finite CSS animation on the page is restarted, every animation is paused+ * at half its duration, the page is scanned, then each is finished or resumed as it was. The+ * open animations of overlays are 120–160 ms long; a probe that only looks at rest never sees+ * them (QA round 4: both probes reported 0 with the palette scrim at opacity 0.17).** Usage (a dev build with remote debugging, e.g. `--remote-debugging-port=9333`):- * node scripts/glass-trap-probe.mjs [--port 9333 | --ws ws://…] [--json]- * Open the overlay under test first; the probe checks what is on screen. Exits 1 on any trap.- * It only reads computed styles — it never clicks, types or changes state.+ * node scripts/glass-trap-probe.mjs [--port 9333 | --ws ws://…] [--rest | --mid-anim] [--json]+ * Open the overlay under test first; the probe checks what is on screen. Exits 1 on any trap, 2+ * when it could not check anything (no page, Liquid Glass off, nothing scanned) — never a silent 0.+ * It only reads computed styles and replays animations the page already declares; it never clicks,+ * types or changes app state.*/+import { realpathSync } from 'node:fs'+import { fileURLToPath } from 'node:url'++/** Intentional full-window dims behind a modal, not glass. `styles.glass-traps.test.ts` reads this+ * list too: a scrim around glass may fade its colour, never its opacity. */+export const SCRIMS = [+ '.palette-overlay',+ '.drawer-overlay',+ '.kanban-modal-scrim',+ '.confirm-overlay',+ '.sc-overlay',+ '.pubdlg-overlay',+ '.consent-overlay',+ '.mlaunch__backdrop',+ '.label-picker__scrim',+ '.phone-pair__backdrop',+ '.tab-backdrop',+ '.ctx-backdrop',+ '.dock-backdrop',+]+// Runs in the page (serialised with toString). Keep it self-contained.-export function glassTrapProbe() {- // Intentional full-window dims behind a modal, not glass.- const SCRIMS = ['.palette-overlay', '.drawer-overlay', '.kanban-modal-scrim', '.confirm-overlay', '.tab-backdrop', '.ctx-backdrop', '.dock-backdrop']+export function glassTrapProbe(SCRIMS, midAnim) {const MIN_AREA = 300const alphaOf = (c) => {if (!c || c === 'transparent') return 0@@ -31,25 +64,36 @@ export function glassTrapProbe() {if (m) return parseFloat(m[1].split(',')[3])return 1}+ // A gradient fill counts like a colour: its most opaque stop (an image `url()` is content, not glass).+ const fillAlpha = (cs) => {+ let a = alphaOf(cs.backgroundColor)+ const img = cs.backgroundImage || 'none'+ if (img !== 'none' && !/url\(/.test(img))+ for (const c of img.match(/rgba?\([^)]*\)/g) || []) a = Math.max(a, alphaOf(c))+ return a+ }const blurs = (cs) => !!cs && /blur\(/.test(cs.backdropFilter || cs.webkitBackdropFilter || '')- const beforeOf = (el) => {- const b = getComputedStyle(el, '::before')+ const pseudoOf = (el, p) => {+ const b = getComputedStyle(el, p)return b.content && b.content !== 'none' && b.display !== 'none' ? b : null}+ const none = (v) => !v || v === 'none'const isRoot = (el) => {const cs = getComputedStyle(el)return (- (cs.backdropFilter && cs.backdropFilter !== 'none') ||- cs.filter !== 'none' ||+ !none(cs.backdropFilter) ||+ !none(cs.filter) ||parseFloat(cs.opacity) < 1 ||- (cs.maskImage && cs.maskImage !== 'none') ||- (cs.webkitMaskImage && cs.webkitMaskImage !== 'none') ||- cs.clipPath !== 'none' ||+ !none(cs.maskImage) ||+ !none(cs.webkitMaskImage) ||+ !none(cs.maskBorderSource) ||+ !none(cs.webkitMaskBoxImageSource) ||+ !none(cs.clipPath) ||cs.mixBlendMode !== 'normal' ||/filter|opacity|mask|clip-path|mix-blend/.test(cs.willChange))}- const hasBlur = (el) => blurs(getComputedStyle(el)) || blurs(beforeOf(el))+ const hasBlur = (el) => blurs(getComputedStyle(el)) || blurs(pseudoOf(el, '::before'))const floats = (el) => /absolute|fixed|sticky/.test(getComputedStyle(el).position)const opaque = (e) => alphaOf(getComputedStyle(e).backgroundColor) >= 0.9const inside = (a, b) => a.left >= b.left - 1 && a.top >= b.top - 1 && a.right <= b.right + 1 && a.bottom <= b.bottom + 1@@ -62,19 +106,45 @@ export function glassTrapProbe() {}return true}++ // Mid-animation: replay every finite animation the page declares, freeze everything at half way.+ const replayed = []+ const frozen = []+ if (midAnim) {+ for (const el of document.body.querySelectorAll('*')) {+ const cs = getComputedStyle(el)+ if (none(cs.animationName) || /infinite/.test(cs.animationIterationCount) || cs.display === 'none') continue+ const prev = el.style.animationName+ el.style.animationName = 'none'+ void getComputedStyle(el).animationName+ el.style.animationName = prev+ replayed.push(el)+ }+ void document.body.offsetWidth+ for (const a of document.getAnimations()) {+ const t = a.effect?.getTiming?.()+ if (!t) continue+ const d = typeof t.duration === 'number' ? t.duration : a.effect.getComputedTiming().duration+ frozen.push({ a, wasRunning: a.playState === 'running', finite: t.iterations !== Infinity })+ a.pause()+ a.currentTime = (t.delay || 0) + (d || 0) / 2+ }+ }+const vw = innerWidthconst vh = innerHeightconst traps = []+ let checked = 0const check = (el, pseudo) => {if (SCRIMS.some((s) => el.matches(s))) return- const cs = pseudo ? beforeOf(el) : getComputedStyle(el)+ const cs = pseudo ? pseudoOf(el, pseudo) : getComputedStyle(el)if (!cs) return- const a = alphaOf(cs.backgroundColor)+ const a = fillAlpha(cs)if (a < 0.02 || a >= 0.9) return// What shows is the box clipped by scrolling/clipping ancestors (a long settings list scrolls// inside its sheet; the part past the sheet's edge is not painted).const b = el.getBoundingClientRect()- const r = { left: b.left, top: b.top, right: b.right, bottom: b.bottom, x: b.x, y: b.y, width: b.width, height: b.height }+ const r = { left: b.left, top: b.top, right: b.right, bottom: b.bottom }for (let e = el.parentElement; e; e = e.parentElement) {if (getComputedStyle(e).overflow === 'visible') continueconst c = e.getBoundingClientRect()@@ -86,14 +156,25 @@ export function glassTrapProbe() {const w = Math.min(r.right, vw) - Math.max(r.left, 0)const h = Math.min(r.bottom, vh) - Math.max(r.top, 0)if (w <= 0 || h <= 0 || w * h < MIN_AREA || !visible(el)) return- // The ::before paints inside its element: its ancestor chain starts at the element itself.+ checked+++ // A pseudo layer paints inside its element: its ancestor chain starts at the element itself.const chain = []for (let e = pseudo ? el : el.parentElement; e && e !== document.documentElement; e = e.parentElement) chain.push(e)const own = pseudo ? blurs(cs) : hasBlur(el)let why = nullif (own) {- const root = chain.find(isRoot)- if (root && !inside(r, root.getBoundingClientRect())) why = `blur escapes backdrop root ${name(root)}`+ const rootIdx = chain.findIndex(isRoot)+ const root = chain[rootIdx]+ // Its own opacity below 1 lays the page, sharp, under its blurred pixels.+ if (!pseudo && parseFloat(cs.opacity) < 0.99) why = `blurred surface fades its own opacity (${cs.opacity})`+ else if (root && !inside(r, root.getBoundingClientRect())) why = `blur escapes backdrop root ${name(root)}`+ else if (root && !blurs(getComputedStyle(root))) {+ // The root paints no blurred backdrop, so this blur sees only the root's own pixels: unless+ // something opaque lies under it inside the root, the page behind the root reads sharp.+ const between = chain.slice(pseudo ? 1 : 0, rootIdx + 1)+ if (!between.some((e) => opaque(e) && inside(r, e.getBoundingClientRect())))+ why = `blur inside see-through backdrop root ${name(root)} (opacity ${getComputedStyle(root).opacity})`+ }} else {// The nearest ancestor that paints something solid or blurred is what shows behind an// in-flow piece. A piece that FLOATS above that ancestor covers its content instead.@@ -108,17 +189,46 @@ export function glassTrapProbe() {}if (why)traps.push({- el: name(el) + (pseudo ? '::before' : ''),+ el: name(el) + (pseudo || ''),bg: cs.backgroundColor,why,box: [b.x, b.y, b.width, b.height].map(Math.round),})}- for (const el of document.body.querySelectorAll('*')) {- check(el, false)- check(el, true)+ try {+ for (const el of document.body.querySelectorAll('*')) {+ check(el, null)+ check(el, '::before')+ check(el, '::after')+ }+ } finally {+ for (const { a, wasRunning, finite } of frozen) {+ if (finite && replayed.includes(a.effect?.target)) a.finish()+ else if (wasRunning) a.play()+ }+ }+ return {+ glass: document.documentElement.dataset.ntGlass === 'on',+ pass: midAnim ? 'mid-animation' : 'rest',+ checked,+ animations: frozen.length,+ traps,}- return { glass: document.documentElement.dataset.ntGlass === 'on', traps }+}++async function evaluate(ws, expression) {+ const sock = new WebSocket(ws)+ return new Promise((resolve, reject) => {+ sock.onerror = () => reject(new Error(`cannot connect to ${ws}`))+ sock.onopen = () => sock.send(JSON.stringify({ id: 1, method: 'Runtime.evaluate', params: { expression, returnByValue: true } }))+ sock.onmessage = (m) => {+ const r = JSON.parse(m.data)+ if (r.id !== 1) return+ sock.close()+ if (r.result?.exceptionDetails) reject(new Error(r.result.exceptionDetails.exception?.description))+ else resolve(r.result.result.value)+ }+ })}async function main() {@@ -131,35 +241,35 @@ async function main() {ws = pages.find((p) => p.type === 'page' && !p.url.includes('hud'))?.webSocketDebuggerUrlif (!ws) throw new Error(`no app page on port ${port}`)}- const sock = new WebSocket(ws)- const result = await new Promise((resolve, reject) => {- sock.onerror = reject- sock.onopen = () =>- sock.send(- JSON.stringify({- id: 1,- method: 'Runtime.evaluate',- params: { expression: `(${glassTrapProbe.toString()})()`, returnByValue: true },- }),- )- sock.onmessage = (m) => {- const r = JSON.parse(m.data)- if (r.id !== 1) return- sock.close()- if (r.result?.exceptionDetails) reject(new Error(r.result.exceptionDetails.exception?.description))- else resolve(r.result.result.value)- }- })- if (args.includes('--json')) console.log(JSON.stringify(result))- else {- if (!result.glass) console.log('note: Liquid Glass is not on (data-nt-glass) — nothing glass to check')- console.log(`${result.traps.length} trap(s)`)- for (const t of result.traps) console.log(` ${t.el} ${t.bg} ${t.why} [${t.box.join(',')}]`)+ const passes = args.includes('--rest') ? [false] : args.includes('--mid-anim') ? [true] : [false, true]+ const results = []+ for (const mid of passes)+ results.push(await evaluate(ws, `(${glassTrapProbe.toString()})(${JSON.stringify(SCRIMS)}, ${mid})`))+ if (args.includes('--json')) console.log(JSON.stringify(results))+ let traps = 0+ let blind = false+ for (const r of results) {+ traps += r.traps.length+ if (!r.glass || r.checked === 0) blind = true+ if (args.includes('--json')) continue+ if (!r.glass) console.log('Liquid Glass is not on (data-nt-glass) — nothing glass to check')+ console.log(`${r.pass}: ${r.traps.length} trap(s) in ${r.checked} translucent surface(s)${r.pass === 'mid-animation' ? `, ${r.animations} animation(s) frozen at 50%` : ''}`)+ for (const t of r.traps) console.log(` ${t.el} ${t.bg} ${t.why} [${t.box.join(',')}]`)}- process.exit(result.traps.length ? 1 : 0)+ process.exit(traps ? 1 : blind ? 2 : 0)}-if (import.meta.url === `file://${process.argv[1]}`) main().catch((e) => {- console.error(e.message)- process.exit(2)-})+// Run only as a script — resolved through symlinks, so a linked or URL-encoded path is still+// recognised (a false "not main" used to exit 0 without checking anything).+const isMain = (() => {+ try {+ return !!process.argv[1] && realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url))+ } catch {+ return false+ }+})()+if (isMain)+ main().catch((e) => {+ console.error(e.message)+ process.exit(2)+ })diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex ab63df984..f992ca2d1 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -13806,6 +13806,97 @@ body.focus-mode .dock:hover {-webkit-backdrop-filter: var(--glass-text-blur);backdrop-filter: var(--glass-text-blur);}+/* Glass never fades (visual QA round 4, N4-H1). An element with opacity < 1 is a backdrop root, so+ while a scrim faded in, the palette/dialog/drawer inside it blurred only the dim scrim and the+ canvas read SHARP through the tint for 120–160 ms, then snapped to frosted; a menu fading its own+ opacity (the `::before`-hosted ones) laid the page sharp under its blur the same way. Under glass:+ scrims fade their COLOUR (a keyframe with only `from` animates to the scrim's own background),+ glass surfaces enter by transform alone, tooltips appear without motion (their transform is their+ placement), and the focus-mode dock slides instead of fading. `styles.glass-traps.test.ts` fails+ on an opacity animation or transition left on any glass surface or scrim; the probe's+ mid-animation pass checks the live page. Reduce Motion keeps `animation: none` (these sit in a+ no-preference query so their `animation-name` cannot re-enable what that rule switched off). */+@keyframes nt-glass-scrim-in {+ from {+ background-color: transparent;+ }+}+@keyframes nt-glass-pop {+ from {+ transform: scale(0.97) translateY(4px);+ }+}+@keyframes nt-glass-menu-in {+ from {+ transform: translateY(-3px);+ }+}+@keyframes nt-glass-drawer-in {+ from {+ transform: translateX(10px);+ }+}+@keyframes nt-glass-onb-menu {+ 0%,+ 19% {+ visibility: hidden;+ transform: scale(0.92);+ }+ 23%,+ 52% {+ visibility: visible;+ transform: scale(1);+ }+ 56%,+ 100% {+ visibility: hidden;+ transform: scale(0.97);+ }+}+@media (prefers-reduced-motion: no-preference) {+ :root[data-nt-glass='on'] :is(.confirm-overlay, .sc-overlay, .palette-overlay, .drawer-overlay, .kanban-modal-scrim) {+ animation-name: nt-glass-scrim-in;+ }+ :root[data-nt-glass='on'] :is(.confirm, .shortcuts, .palette, .kanban-modal) {+ animation-name: nt-glass-pop;+ }+ :root[data-nt-glass='on'] :is(.ctx-menu, .tab-menu) {+ animation-name: nt-glass-menu-in;+ }+ :root[data-nt-glass='on'] .drawer {+ animation-name: nt-glass-drawer-in;+ }+ :root[data-nt-glass='on'] body.focus-mode .dock {+ transition: transform 0.16s ease-out;+ }+}+:root[data-nt-glass='on'] .tooltip {+ animation-name: none;+}+/* The onboarding scene replays the REAL .ctx-menu: it appears and disappears by visibility. */+:root[data-nt-glass='on'] .ctx-menu.onb-menu {+ opacity: 1;+ visibility: hidden;+ animation-name: nt-glass-onb-menu;+}+/* The focus-mode exit pill rested at 40% opacity — a glass control that was itself see-through.+ It rests at full opacity in secondary ink instead. */+:root[data-nt-glass='on'] .focus-exit {+ opacity: 1;+ color: var(--muted);+ transition: color 0.16s ease-out;+}+:root[data-nt-glass='on'] .focus-exit:hover {+ color: var(--text-strong);+}+:root[data-nt-glass='on'] body.focus-mode .dock {+ opacity: 1;+ transform: translate(-50%, calc(100% + var(--float-gap) + 12px));+}+:root[data-nt-glass='on'] :is(body.focus-mode.focus-reveal-bottom .dock, body.focus-mode .dock:hover) {+ transform: translateX(-50%);+}+/* Top tooltips belong to the dock (the only `placement="top"` user). They pin 6px above the BUTTON,which on glass put the bubble on the dock's visible rim (visual QA round 3, NH2): they clear therim by 7px instead. */diff --git a/src/renderer/styles.glass-traps.test.ts b/src/renderer/styles.glass-traps.test.tsindex 210f8b298..abefabe09 100644--- a/src/renderer/styles.glass-traps.test.ts+++ b/src/renderer/styles.glass-traps.test.ts@@ -7,18 +7,27 @@ import { describe, expect, it } from 'vitest'* that also gets a working blur. Visual QA rounds 2 and 3 found eleven surfaces that were* see-through with no blur — terminal text read sharp through menus, drawers, pickers and* tooltips — because the shared panel tokens themselves resolved to the fill, which reached every- * floating surface nobody had listed.+ * floating surface nobody had listed. Round 4 found the same failure in TIME: a scrim fading its+ * opacity is a backdrop root for the glass inside it, and a menu fading its own opacity lays the+ * page sharp under its blur, for the 120–160 ms of every open.*- * The rule checked here: every rule that paints a translucent glass fill (as a background or by- * assigning it to a custom property that surfaces paint) must, for each of its selectors, either- * carry a backdrop-filter itself or target an element that a blur rule also targets (the same- * classes, or its paired `::before` glass layer). A token assignment on `:root` targets no- * surface in particular, so it always fails. The live half of the check — backdrop roots, which- * CSS alone cannot see — is `scripts/glass-trap-probe.mjs` (see CLAUDE.md, Liquid Glass chrome).+ * The rules checked here:+ * 1. every rule that paints a translucent glass fill (as a background, a background-image or by+ * assigning it to a custom property that surfaces paint) must, for each of its selectors, either+ * carry a working backdrop-filter itself (the LAST backdrop-filter declaration wins) or target+ * an element that a blur rule covers: the blur rule's selector must match at least everything the+ * fill's selector matches — same ancestors, and its subject compound (pseudo-classes and `:not()`+ * included) a subset of the fill's; a `::before` blur covers its host. A token assignment on+ * `:root` targets no surface in particular, so it always fails.+ * 2. no glass surface (anything painting a fill, or the host of a `::before` fill) and no scrim+ * (`SCRIMS` in the probe) animates or transitions `opacity` — unless a rule under the glass gate+ * overrides that animation/transition for the same element with one that does not.+ * The live half — backdrop roots, which CSS alone cannot see, at rest and mid-animation — is+ * `scripts/glass-trap-probe.mjs` (see CLAUDE.md, Liquid Glass chrome).*/const FILL = /var\(--(glass-chrome-bg|glass-control-bg|term-glass-bg|term-glass-header-bg)\)/-const PAINT = /(?:^|;)\s*(background(?:-color)?|--[\w-]+)\s*:([^;]*)/g-const BLUR = /(?:^|;)\s*(?:-webkit-)?backdrop-filter\s*:\s*(?!none)[^;]*blur/+const PAINT = /(?:^|;)\s*(background(?:-color|-image)?|--[\w-]+)\s*:([^;]*)/g+const GATE = /^:root\[data-nt-glass='on'\](?:\[[^\]]*\])*\s*//** In-flow pieces that only stack on their own blurred surface, never over other content. */const IN_FLOW: Record<string, string> = {@@ -36,10 +45,30 @@ function parse(css: string): Rule[] {const re = /([^{}]+)\{([^{}]*)\}/gconst src = css.replace(/\r\n/g, '\n').replace(/\/\*[\s\S]*?\*\//g, '')let m: RegExpExecArray | null- while ((m = re.exec(src))) out.push({ selectors: splitTop(m[1].replace(/\s+/g, ' ').trim()), body: m[2] })+ while ((m = re.exec(src))) {+ const head = m[1].replace(/\s+/g, ' ').trim()+ // Keyframe steps (`from`, `50%`) are not selectors.+ if (/^(from|to|[\d.]+%)(\s*,\s*(from|to|[\d.]+%))*$/.test(head)) continue+ out.push({ selectors: splitTop(head), body: m[2] })+ }return out}+/** `@keyframes` names whose steps set opacity. */+function opacityKeyframes(css: string): Set<string> {+ const src = css.replace(/\/\*[\s\S]*?\*\//g, '')+ const names = new Set<string>()+ const re = /@keyframes\s+([\w-]+)\s*\{/g+ let m: RegExpExecArray | null+ while ((m = re.exec(src))) {+ let depth = 1+ let i = re.lastIndex+ while (depth && i < src.length) depth += src[i] === '{' ? 1 : src[i] === '}' ? -1 : 0, i+++ if (/(?:^|[;{\s])opacity\s*:/.test(src.slice(re.lastIndex, i))) names.add(m[1])+ }+ return names+}+/** Split on commas outside parentheses. */function splitTop(list: string): string[] {const parts: string[] = []@@ -57,62 +86,125 @@ function splitTop(list: string): string[] {return parts}-/** The subject compound of a selector, one per `:is(…)` alternative, each as its class set plus- * its pseudo-element. `:not(…)`, `:hover` & co. do not change which element is painted. */-function subjects(selector: string): { classes: Set<string>; pseudo: string }[] {- // The last compound: split on descendant/child combinators outside parentheses.+/** One concrete selector: its ancestor part (verbatim, gate stripped), the subject compound's+ * simple selectors (classes, attributes, pseudo-classes WITH their arguments) and its+ * pseudo-element. */+interface Alt {+ anc: string+ tokens: Set<string>+ pseudo: string+}++function alternatives(selector: string): Alt[] {+ const sel = selector.replace(GATE, '').trim()let depth = 0let start = 0- for (let i = 0; i < selector.length; i++) {- const ch = selector[i]+ for (let i = 0; i < sel.length; i++) {+ const ch = sel[i]if (ch === '(') depth++else if (ch === ')') depth--else if (depth === 0 && (ch === ' ' || ch === '>' || ch === '+' || ch === '~')) start = i + 1}- const compound = selector.slice(start)- const pseudo = /::([\w-]+)/.exec(compound)?.[1] ?? ''- // A leading `:is(a, b)` lists alternatives; whatever follows it (`:hover`, `::before`) applies to each.- let alts = [classesOf(compound)]+ const anc = sel.slice(0, start).replace(/\s+/g, ' ').trim()+ return compoundAlts(sel.slice(start)).map((c) => ({ anc, ...c }))+}++/** A leading `:is(a, b)` lists alternatives; whatever follows it (`:hover`, `::before`) applies to each. */+function compoundAlts(compound: string): { tokens: Set<string>; pseudo: string }[] {if (compound.startsWith(':is(')) {let d = 0let end = 3while (end < compound.length && !(compound[end] === ')' && --d === 0)) if (compound[end++] === '(') d++- const rest = classesOf(compound.slice(end + 1))- alts = splitTop(compound.slice(4, end)).map((a) => new Set([...subjects(a)[0].classes, ...rest]))+ const rest = compound.slice(end + 1)+ return splitTop(compound.slice(4, end)).flatMap((a) => compoundAlts(a + rest))}- return alts.map((classes) => ({ classes, pseudo }))+ const tokens = new Set<string>()+ let pseudo = ''+ const re = /::?[\w-]+(?:\((?:[^()]|\((?:[^()]|\([^()]*\))*\))*\))?|\.[\w-]+|\[[^\]]*\]|#[\w-]+|^[a-z][\w-]*/g+ for (const t of compound.match(re) ?? []) {+ if (t.startsWith('::')) pseudo = t.slice(2)+ else tokens.add(t)+ }+ return [{ tokens, pseudo }]}-function classesOf(compound: string): Set<string> {- const bare = compound.replace(/:(not|is|where|has)\((?:[^()]|\([^()]*\))*\)/g, '')- return new Set([...bare.matchAll(/\.([\w-]+)/g)].map((c) => c[1]))+/** Does `b` match at least every element `s` matches? */+const covers = (b: Alt, s: Alt): boolean =>+ (b.anc === '' || b.anc === s.anc) && b.tokens.size > 0 && [...b.tokens].every((t) => s.tokens.has(t))++/** The last (-webkit-)backdrop-filter declaration decides; Chromium treats the two as one property. */+function blurs(body: string): boolean {+ const decls = [...body.matchAll(/(?:^|;)\s*(?:-webkit-)?backdrop-filter\s*:([^;]*)/g)]+ const last = decls.at(-1)?.[1].trim() ?? 'none'+ return last !== 'none' && /blur/.test(last)}-/** Every selector that paints a glass fill without a blur of its own or a paired blur rule. */+const paintsFill = (r: Rule): boolean => [...r.body.matchAll(PAINT)].some((d) => FILL.test(d[2]))++/** Every selector that paints a glass fill without a blur of its own or a covering blur rule. */function glassFillsWithoutBlur(css: string): string[] {const rules = parse(css)- const blurred = rules- .filter((r) => BLUR.test(r.body))- .flatMap((r) => r.selectors.flatMap(subjects))- .filter((s) => s.classes.size > 0)- const covered = (s: { classes: Set<string>; pseudo: string }): boolean =>- blurred.some(- (b) => (b.pseudo === s.pseudo || b.pseudo === 'before') && [...b.classes].every((c) => s.classes.has(c))- )+ const blurred = rules.filter((r) => blurs(r.body)).flatMap((r) => r.selectors.flatMap(alternatives))+ const covered = (s: Alt): boolean =>+ blurred.some((b) => (b.pseudo === s.pseudo || b.pseudo === 'before') && covers(b, s))const bad: string[] = []for (const r of rules) {- const paints = [...r.body.matchAll(PAINT)].some((d) => FILL.test(d[2]))- if (!paints || BLUR.test(r.body)) continue+ if (!paintsFill(r) || blurs(r.body)) continuefor (const sel of r.selectors) {if (Object.keys(IN_FLOW).some((k) => sel.endsWith(k))) continue- if (!subjects(sel).every(covered)) bad.push(sel)+ if (!alternatives(sel).every(covered)) bad.push(sel)}}return bad}+/** Every glass surface or scrim selector that animates or transitions opacity (see rule 2). */+function glassOpacityMotion(css: string, scrims: string[]): string[] {+ const rules = parse(css)+ const fades = opacityKeyframes(css)+ const targets: Alt[] = [+ ...rules.filter(paintsFill).flatMap((r) => r.selectors.flatMap(alternatives)).map((a) => ({ ...a, pseudo: '' })),+ ...scrims.flatMap(alternatives),+ ]+ const kindsOf = (body: string): { animation?: boolean; transition?: boolean } => {+ const out: { animation?: boolean; transition?: boolean } = {}+ for (const d of body.matchAll(/(?:^|;)\s*(animation(?:-name)?|transition(?:-property)?)\s*:([^;]*)/g)) {+ const v = d[2]+ if (d[1].startsWith('animation')) out.animation = v.split(/[\s,]+/).some((w) => fades.has(w))+ else out.transition = /\b(opacity|all)\b/.test(v) || (d[1] === 'transition' && /^\s*[\d.]+m?s\b/.test(v))+ }+ return out+ }+ const bad: string[] = []+ for (const r of rules) {+ const kinds = kindsOf(r.body)+ for (const kind of ['animation', 'transition'] as const) {+ if (!kinds[kind]) continue+ for (const sel of r.selectors) {+ const gated = GATE.test(sel)+ for (const a of alternatives(sel)) {+ if (a.pseudo || !targets.some((t) => covers(t, a))) continue+ // An ungated (default-look) rule is fine when a gated rule re-declares that motion for+ // the same element without opacity.+ const overridden =+ !gated &&+ rules.some(+ (g) =>+ kindsOf(g.body)[kind] === false &&+ g.selectors.some((gs) => GATE.test(gs) && alternatives(gs).some((ga) => !ga.pseudo && covers(ga, a)))+ )+ if (!overridden) bad.push(`${sel} (${kind})`)+ }+ }+ }+ }+ return [...new Set(bad)]+}+describe('Liquid Glass: no translucent fill without a blur', () => {- const CSS = readFileSync(join(__dirname, 'styles.css'), 'utf8')+ const CSS = readFileSync(join(__dirname, 'styles.css'), 'utf8').replace(/\r\n/g, '\n')+ const PROBE = readFileSync(join(__dirname, '../../scripts/glass-trap-probe.mjs'), 'utf8').replace(/\r\n/g, '\n')+ const SCRIMS = [...(/export const SCRIMS = \[([^\]]*)\]/.exec(PROBE)?.[1] ?? '').matchAll(/'([^']+)'/g)].map((m) => m[1])it('every glass fill in styles.css is paired with a working blur', () => {expect(glassFillsWithoutBlur(CSS)).toEqual([])@@ -134,6 +226,21 @@ describe('Liquid Glass: no translucent fill without a blur', () => {expect(glassFillsWithoutBlur(css)).toEqual([":root[data-nt-glass='on'] .picker", ":root[data-nt-glass='on'] .tip"])})+ it('code review 6 #5: the shapes the first version let through', () => {+ const g = ":root[data-nt-glass='on']"+ const css = `+ ${g} .a { background-image: linear-gradient(var(--glass-chrome-bg), var(--glass-chrome-bg)); }+ ${g} .b { background: var(--glass-chrome-bg); -webkit-backdrop-filter: blur(20px); backdrop-filter: none; }+ ${g} .c:hover { backdrop-filter: blur(20px); }+ ${g} .c { background: var(--glass-chrome-bg); }+ ${g} .m:not(.m--scroll)::before { backdrop-filter: blur(20px); }+ ${g} .m.m--scroll { background: var(--glass-chrome-bg); }+ ${g} .modal .menu { backdrop-filter: blur(20px); }+ ${g} .sidebar .menu { background: var(--glass-chrome-bg); }+ ${g} .modal .menu:hover { background: var(--glass-chrome-bg); }`+ expect(glassFillsWithoutBlur(css)).toEqual([`${g} .a`, `${g} .b`, `${g} .c`, `${g} .m.m--scroll`, `${g} .sidebar .menu`])+ })+it('the shared surface tokens are never redefined under the glass gate', () => {const redefined = parse(CSS).filter((r) => r.selectors.some((s) => s.startsWith(":root[data-nt-glass='on']")))@@ -141,3 +248,39 @@ describe('Liquid Glass: no translucent fill without a blur', () => {expect(redefined).toEqual([])})})++describe('Liquid Glass: glass never fades (visual QA round 4, N4-H1)', () => {+ const CSS = readFileSync(join(__dirname, 'styles.css'), 'utf8').replace(/\r\n/g, '\n')+ const PROBE = readFileSync(join(__dirname, '../../scripts/glass-trap-probe.mjs'), 'utf8').replace(/\r\n/g, '\n')+ const SCRIMS = [...(/export const SCRIMS = \[([^\]]*)\]/.exec(PROBE)?.[1] ?? '').matchAll(/'([^']+)'/g)].map((m) => m[1])++ it('reads the scrim list from the live probe', () => {+ expect(SCRIMS).toContain('.palette-overlay')+ expect(SCRIMS).toContain('.kanban-modal-scrim')+ })++ it('no glass surface or scrim animates or transitions opacity under the glass gate', () => {+ expect(glassOpacityMotion(CSS, SCRIMS)).toEqual([])+ })++ it('catches opacity keyframes and transitions on glass and scrims, and accepts a gated override', () => {+ const g = ":root[data-nt-glass='on']"+ const css = `+ @keyframes fade { from { opacity: 0; } to { opacity: 1; } }+ @keyframes slide { from { transform: translateY(4px); } }+ ${g} :is(.menu, .sheet) { background: var(--glass-chrome-bg); backdrop-filter: blur(20px); }+ .menu { animation: fade 0.12s ease-out; }+ ${g} .menu { animation-name: slide; }+ .sheet { animation: fade 0.12s; }+ .scrim { animation: fade 0.12s; }+ .sheet { transition: opacity 0.2s; }+ .menu__row { animation: fade 0.1s; }+ ${g} .menu:hover { transition: all 0.1s; }`+ expect(glassOpacityMotion(css, ['.scrim'])).toEqual([+ '.sheet (animation)',+ '.scrim (animation)',+ '.sheet (transition)',+ `${g} .menu:hover (transition)`,+ ])+ })+})