Skip to content

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.

perf(glass): size the status-chip wash once per theme

iceclatterWT2635dc3f0c4e
diff --git a/src/renderer/lib/glassContrast.test.ts b/src/renderer/lib/glassContrast.test.ts
index ad27f2382..184637e60 100644
--- a/src/renderer/lib/glassContrast.test.ts
+++ b/src/renderer/lib/glassContrast.test.ts
@@ -262,6 +262,15 @@ describe('glass status chip keeps its label readable', () => {
}
})
+ // glassTint sizes the wash at the tick for every slider position; that is only safe because the
+ // wash can only grow with the alpha (the scan is contiguous, so the tick's wash passes above it).
+ it.each(rows)('%s: the wash never shrinks right of the Readable tick', (_id, t, readable, wash) => {
+ for (const a of [readable, (readable + 1) / 2, 0.95, 1].filter((x) => x >= readable)) {
+ expect(glassChipWash(t.theme.foreground!, t.theme.background!, a)).toBeGreaterThanOrEqual(wash)
+ }
+ expect(glassTint(t.theme, 1)!.chipWash).toBe(glassTint(t.theme)!.chipWash)
+ })
+
it('the stylesheet uses the computed wash, never a fixed one', () => {
const css = readFileSync(join(__dirname, '..', 'styles.css'), 'utf8')
const rule = css.slice(css.indexOf(":root[data-nt-glass='on'] .term-node__status {"))
diff --git a/src/renderer/lib/glassContrast.ts b/src/renderer/lib/glassContrast.ts
index 949286eb3..d08e4880e 100644
--- a/src/renderer/lib/glassContrast.ts
+++ b/src/renderer/lib/glassContrast.ts
@@ -176,8 +176,10 @@ export function glassTint(
const readable = glassTintAlpha(foreground, theme.background!)
const alpha = glassSurfaceAlpha(slider, readable, a11y)
const rgb = bg.join(', ')
- // Left of the Readable tick the contrast promise is off anyway; size the chip for the tick.
- const chipWash = glassChipWash(foreground, theme.background!, Math.max(alpha, readable))
+ // Sized at the Readable tick, whatever the slider: left of it the promise is off anyway, and
+ // right of it a denser tint only leaves MORE room for the wash, so the tick's wash still passes —
+ // one computation per theme instead of a ~21k-check cache miss per slider step.
+ const chipWash = glassChipWash(foreground, theme.background!, readable)
return {
background: `rgba(${rgb}, ${alpha.toFixed(3)})`,
header: `rgba(${rgb}, ${HEADER_LAYER_ALPHA})`,