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.

fix(glass): draw the Glass slider like a macOS slider with a tick mark

iceclatterWTaa8655be2fbe
diff --git a/src/renderer/components/settings/GlassSlider.tsx b/src/renderer/components/settings/GlassSlider.tsx
new file mode 100644
index 000000000..746c47a0f
--- /dev/null
+++ b/src/renderer/components/settings/GlassSlider.tsx
@@ -0,0 +1,100 @@
+import { useLayoutEffect, useRef, useState } from 'react'
+import {
+ GLASS_READABLE_TICK,
+ snapGlassSlider,
+ stepGlassSlider
+} from '@renderer/lib/glassContrast'
+
+/** Keep the Readable caption at least this far from the Clear / Tinted captions. */
+const CAPTION_GAP = 8
+
+function valueText(v: number): string {
+ if (v === GLASS_READABLE_TICK) return 'Readable'
+ const pct = `${Math.round(v * 100)}%`
+ return v < GLASS_READABLE_TICK ? `Clearer than readable, ${pct}` : `More tinted than readable, ${pct}`
+}
+
+/**
+ * The Liquid Glass slider, drawn like a macOS slider with a tick mark: a thin rounded track filled
+ * with the accent up to the thumb, a notch at the Readable point with its caption under it, and
+ * a magnetic detent there for both drag and arrow keys (lib/glassContrast `snapGlassSlider` /
+ * `stepGlassSlider`). Styles: `.glass-slider` in styles.css.
+ */
+export function GlassSlider({
+ value,
+ disabled,
+ onChange
+}: {
+ value: number
+ disabled: boolean
+ onChange: (v: number | null) => void
+}) {
+ const wrap = useRef<HTMLDivElement>(null)
+ const clear = useRef<HTMLSpanElement>(null)
+ const tinted = useRef<HTMLSpanElement>(null)
+ const readable = useRef<HTMLButtonElement>(null)
+ const [captionLeft, setCaptionLeft] = useState<number | null>(null)
+
+ // Centre the Readable caption under the notch, clamped clear of the two end captions.
+ useLayoutEffect(() => {
+ const measure = (): void => {
+ const w = wrap.current?.clientWidth ?? 0
+ const half = (readable.current?.offsetWidth ?? 0) / 2
+ const min = (clear.current?.offsetWidth ?? 0) + CAPTION_GAP + half
+ const max = w - (tinted.current?.offsetWidth ?? 0) - CAPTION_GAP - half
+ const notch = 10 + (w - 20) * GLASS_READABLE_TICK
+ setCaptionLeft(Math.min(Math.max(notch, min), Math.max(min, max)))
+ }
+ measure()
+ const ro = new ResizeObserver(measure)
+ if (wrap.current) ro.observe(wrap.current)
+ return () => ro.disconnect()
+ }, [])
+
+ return (
+ <div
+ ref={wrap}
+ className="glass-slider"
+ aria-disabled={disabled || undefined}
+ style={{ ['--glass-fill' as string]: value, ['--glass-tick' as string]: GLASS_READABLE_TICK }}
+ >
+ <div className="glass-slider__rail">
+ <span className="glass-slider__notch" aria-hidden />
+ <input
+ type="range"
+ min={0}
+ max={1}
+ step={0.01}
+ value={value}
+ disabled={disabled}
+ aria-label="Glass, from Clear to Tinted"
+ aria-valuetext={valueText(value)}
+ onChange={(e) => onChange(snapGlassSlider(Number(e.target.value)))}
+ onKeyDown={(e) => {
+ const dir = e.key === 'ArrowRight' || e.key === 'ArrowUp' ? 1 : e.key === 'ArrowLeft' || e.key === 'ArrowDown' ? -1 : 0
+ if (!dir) return
+ e.preventDefault()
+ onChange(stepGlassSlider(value, dir))
+ }}
+ />
+ </div>
+ <div className="glass-slider__captions">
+ <span ref={clear}>Clear</span>
+ <button
+ ref={readable}
+ type="button"
+ className="glass-slider__readable"
+ disabled={disabled}
+ style={{ left: captionLeft ?? undefined, visibility: captionLeft === null ? 'hidden' : undefined }}
+ onClick={() => onChange(null)}
+ title="Back to the readable point"
+ >
+ Readable
+ </button>
+ <span ref={tinted} className="glass-slider__tinted">
+ Tinted
+ </span>
+ </div>
+ </div>
+ )
+}
diff --git a/src/renderer/components/settings/sections/AppearanceSection.tsx b/src/renderer/components/settings/sections/AppearanceSection.tsx
index 4f090cf9f..53c09b3e1 100644
--- a/src/renderer/components/settings/sections/AppearanceSection.tsx
+++ b/src/renderer/components/settings/sections/AppearanceSection.tsx
@@ -17,6 +17,7 @@ import { SYSTEM_NODE_COLOR_SWATCHES } from '@shared/node-colors'
import { SettingsSection } from '../SettingsSection'
import { SearchableRow } from '../SearchableRow'
import { FieldRow } from '../FieldRow'
+import { GlassSlider } from '../GlassSlider'
import { Switch } from '@renderer/ui/Switch'
import { SegmentedPill } from '@renderer/ui/SegmentedPill'
import {
@@ -401,45 +402,15 @@ export function AppearanceSection({ isActive }: { isActive: boolean }): React.JS
: glassA11y.moreContrast
? 'Increase Contrast is on in your system settings, so glass stays at Tinted with stronger edges.'
: glassSlider < GLASS_READABLE_TICK
- ? 'Clearer than Readable: the wallpaper shows through more, and text contrast is no longer guaranteed.'
- : 'From Readable to Tinted, regular text keeps 4.5:1 contrast over any wallpaper.'
+ ? 'Clearer than Readable: text can fade over bright parts of the wallpaper.'
+ : 'Regular text keeps 4.5:1 contrast over any wallpaper.'
}
control={
- <div className={cn('flex w-56 flex-col gap-1', glassLocked && 'pointer-events-none opacity-40')}>
- <input
- type="range"
- min={0}
- max={1}
- step={0.01}
- list="nt-glass-ticks"
- disabled={glassLocked}
- value={glassSlider}
- aria-label="Glass, from Clear to Tinted"
- aria-valuetext={
- Math.abs(glassSlider - GLASS_READABLE_TICK) < 0.005
- ? 'Readable'
- : `${Math.round(glassSlider * 100)}% tinted`
- }
- onChange={(e) => update({ glassTint: Number(e.target.value) })}
- className="w-full accent-[var(--accent)]"
- />
- <datalist id="nt-glass-ticks">
- <option value={GLASS_READABLE_TICK} label="Readable" />
- </datalist>
- <div className="relative h-4 text-[11px] text-muted">
- <span className="absolute left-0">Clear</span>
- <button
- type="button"
- className="absolute -translate-x-1/2 hover:text-text"
- style={{ left: `${GLASS_READABLE_TICK * 100}%` }}
- onClick={() => update({ glassTint: null })}
- title="Back to the readable point"
- >
- Readable
- </button>
- <span className="absolute right-0">Tinted</span>
- </div>
- </div>
+ <GlassSlider
+ value={glassSlider}
+ disabled={glassLocked}
+ onChange={(v) => update({ glassTint: v })}
+ />
}
/>
</SearchableRow>
diff --git a/src/renderer/lib/glassContrast.test.ts b/src/renderer/lib/glassContrast.test.ts
index 9ab38601a..919cf01e2 100644
--- a/src/renderer/lib/glassContrast.test.ts
+++ b/src/renderer/lib/glassContrast.test.ts
@@ -21,7 +21,9 @@ import {
glassSliderAlpha,
glassTint,
resolveGlassSlider,
- glassSurfaceAlpha
+ glassSurfaceAlpha,
+ snapGlassSlider,
+ stepGlassSlider
} from './glassContrast'
const WHITE = [255, 255, 255] as const
@@ -207,3 +209,20 @@ describe('accessibility outranks the Glass slider', () => {
expect(glassSurfaceAlpha(0.3, 0.7)).toBe(glassSliderAlpha(0.3, 0.7))
})
})
+
+describe('Glass slider detent (macOS tick-mark feel)', () => {
+ it('a drag within ±0.03 of the tick lands on it', () => {
+ expect(snapGlassSlider(GLASS_READABLE_TICK + 0.03)).toBe(GLASS_READABLE_TICK)
+ expect(snapGlassSlider(GLASS_READABLE_TICK - 0.02)).toBe(GLASS_READABLE_TICK)
+ expect(snapGlassSlider(0.5)).toBe(0.5)
+ })
+
+ it('arrow keys step 0.05 and stop on the tick when they cross it', () => {
+ expect(stepGlassSlider(0.5, 1)).toBeCloseTo(0.55, 10)
+ expect(stepGlassSlider(0.68, 1)).toBe(GLASS_READABLE_TICK)
+ expect(stepGlassSlider(0.72, -1)).toBe(GLASS_READABLE_TICK)
+ expect(stepGlassSlider(GLASS_READABLE_TICK, 1)).toBeCloseTo(0.75, 10)
+ expect(stepGlassSlider(1, 1)).toBe(1)
+ expect(stepGlassSlider(0, -1)).toBe(0)
+ })
+})
diff --git a/src/renderer/lib/glassContrast.ts b/src/renderer/lib/glassContrast.ts
index 8354b6df1..134b6f198 100644
--- a/src/renderer/lib/glassContrast.ts
+++ b/src/renderer/lib/glassContrast.ts
@@ -257,3 +257,19 @@ export function glassSurfaceAlpha(t: number, readable: number, a11y: GlassA11y =
if (a11y.reduceTransparency) return 1
return glassSliderAlpha(a11y.moreContrast ? 1 : t, readable)
}
+
+/** Magnetic detent, like a macOS slider's tick marks: a drag within this of the tick lands on it. */
+export const GLASS_TICK_DETENT = 0.03
+/** Keyboard arrow step. */
+export const GLASS_SLIDER_STEP = 0.05
+
+export function snapGlassSlider(v: number): number {
+ return Math.abs(v - GLASS_READABLE_TICK) <= GLASS_TICK_DETENT + 1e-9 ? GLASS_READABLE_TICK : v
+}
+
+/** One arrow press from `v` (dir -1 / +1): a step of 0.05 that stops on the tick if it crosses it. */
+export function stepGlassSlider(v: number, dir: -1 | 1): number {
+ const next = Math.min(1, Math.max(0, Math.round((v + dir * GLASS_SLIDER_STEP) * 1000) / 1000))
+ const crosses = dir > 0 ? v < GLASS_READABLE_TICK && next > GLASS_READABLE_TICK : v > GLASS_READABLE_TICK && next < GLASS_READABLE_TICK
+ return crosses ? GLASS_READABLE_TICK : snapGlassSlider(next)
+}
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 3c1a353ee..de3db1fd6 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -13839,3 +13839,103 @@ body.focus-mode .dock:hover {
will-change: auto;
}
}
+
+/* ---- Glass slider (Settings → Appearance, components/settings/GlassSlider.tsx) ---------------
+ Drawn like a macOS slider with a tick mark. The thumb's centre runs from 10px to (width − 10px),
+ so the fill and the notch use the same `10px + (100% − 20px) × t` the browser uses for the thumb. */
+.glass-slider {
+ width: 240px;
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+}
+.glass-slider[aria-disabled] {
+ opacity: 0.4;
+ pointer-events: none;
+}
+.glass-slider__rail {
+ position: relative;
+ height: 20px;
+}
+.glass-slider__notch {
+ position: absolute;
+ top: 1px;
+ left: calc(10px + (100% - 20px) * var(--glass-tick));
+ width: 2px;
+ height: 8px;
+ margin-left: -1px;
+ border-radius: 1px;
+ background: var(--muted);
+}
+.glass-slider input[type='range'] {
+ -webkit-appearance: none;
+ appearance: none;
+ position: relative;
+ display: block;
+ width: 100%;
+ height: 20px;
+ margin: 0;
+ background: transparent;
+ cursor: pointer;
+}
+.glass-slider input[type='range']:focus {
+ outline: none;
+}
+.glass-slider input[type='range']::-webkit-slider-runnable-track {
+ height: 4px;
+ border-radius: 999px;
+ background: linear-gradient(
+ to right,
+ var(--accent) 0 calc(10px + (100% - 20px) * var(--glass-fill)),
+ color-mix(in srgb, var(--text) 18%, transparent) 0
+ );
+}
+.glass-slider input[type='range']::-webkit-slider-thumb {
+ -webkit-appearance: none;
+ appearance: none;
+ width: 20px;
+ height: 20px;
+ margin-top: -8px;
+ border-radius: 50%;
+ /* theme-exempt: the thumb is white in both themes, like a macOS slider */
+ background: #fff;
+ box-shadow:
+ 0 1px 3px rgba(0, 0, 0, 0.3),
+ 0 0 0 0.5px rgba(0, 0, 0, 0.12);
+}
+.glass-slider input[type='range']:focus-visible::-webkit-slider-thumb {
+ box-shadow:
+ 0 1px 3px rgba(0, 0, 0, 0.3),
+ 0 0 0 0.5px rgba(0, 0, 0, 0.12),
+ 0 0 0 3px color-mix(in srgb, var(--accent) 50%, transparent);
+}
+.glass-slider__captions {
+ position: relative;
+ display: flex;
+ justify-content: space-between;
+ height: 14px;
+ font-size: 11px;
+ line-height: 14px;
+ color: var(--muted);
+}
+.glass-slider__readable {
+ position: absolute;
+ top: 0;
+ transform: translateX(-50%);
+ padding: 0;
+ border: none;
+ background: none;
+ font: inherit;
+ color: inherit;
+ cursor: pointer;
+}
+.glass-slider__readable:hover {
+ color: var(--text);
+}
+.glass-slider__readable:focus {
+ outline: none;
+}
+.glass-slider__readable:focus-visible {
+ border-radius: 3px;
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 60%, transparent);
+}
diff --git a/src/renderer/styles.theme.test.ts b/src/renderer/styles.theme.test.ts
index 486781092..457ef87bc 100644
--- a/src/renderer/styles.theme.test.ts
+++ b/src/renderer/styles.theme.test.ts
@@ -110,6 +110,8 @@ describe('every CSS variable resolves', () => {
'--term-glass-header-bg',
'--term-glass-fg',
'--glass-chrome-bg', // App.tsx, Liquid Glass chrome fill (lib/glassContrast.ts glassChromeAlpha)
+ '--glass-fill', // GlassSlider, the slider value (fills the track)
+ '--glass-tick', // GlassSlider, the Readable tick position (the notch)
'--peer-color', // presence chips, per peer
'--group-label-boost', // GroupNode, zoom-compensated label size
'--mascot-w',