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(glyphgrid): stop mip-blurring text at a zoom that is barely under 1
enes95edf1a72b23
diff --git a/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.md b/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.mdindex bb785cd31..fc10d63ff 100644--- a/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.md+++ b/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.md@@ -375,6 +375,17 @@ Auto after you switched builds, that is why: re-select Shared and carry on.pointer leaves. Move the pointer between two links on one line and confirm the old one clears.A link that wraps across rows is underlined on every row it covers.+- [ ] **2.20 Crispness at a zoom that is NOT exactly 1.** The 2026-08-09 report ("text isn't so+ crisp, might be related to retina") was taken at zoom **0.976** — and a canvas is very rarely+ at exactly 1, since any pinch, fitView or window resize lands on a number like that. The+ sampler used to jump to trilinear mip filtering the instant zoom fell below 1, blending a+ half-resolution mip into every glyph to pay for a 2.4% minification.+ Pinch to a hair under 1 (0.95–0.99) and compare against **GPU per terminal** at the same+ zoom: the text must read as sharp, not softened. Then zoom OUT properly (0.5, 0.3) and check+ the opposite failure — the mip chain is still what stops a zoomed-out canvas shimmering, so+ speckle or crawling stems there means the band went too far. `atlasFilterChoice` is the rule;+ 0.9 is the boundary between the two.+## 3. Interactions- [ ] **3.1 Wheel scrolls tmux history.** Wheel over a terminal scrolls tmux's own scrollback, thediff --git a/src/renderer/glyphgrid/atlas-filter.test.ts b/src/renderer/glyphgrid/atlas-filter.test.tsnew file mode 100644index 000000000..9cfa0d7fd--- /dev/null+++ b/src/renderer/glyphgrid/atlas-filter.test.ts@@ -0,0 +1,41 @@+import { describe, expect, it } from 'vitest'+import { atlasFilterChoice } from './gl-webgl2'++/**+ * The 2026-08-09 report — "the terminal text isn't so crisp, which might be related to retina+ * displays" — measured. The reporting canvas was at **0.976**, and the rule jumped to trilinear+ * mip filtering the instant zoom fell below 1: a half-resolution mip blended into every glyph to+ * pay for a 2.4% minification. GPU per terminal looked sharper because xterm draws 1:1 and the+ * browser's compositor does the 0.976 in one pass.+ *+ * A canvas is very rarely at exactly 1 — any pinch, fitView or window resize lands on a number+ * like that — so the near-1 band is where most users actually sit, not an edge case.+ */+describe('atlasFilterChoice', () => {+ it('samples level 0 alone just below 1 — the case the report was taken at', () => {+ expect(atlasFilterChoice(0.976135).min).toBe('linear')+ expect(atlasFilterChoice(0.95).min).toBe('linear')+ expect(atlasFilterChoice(0.9).min).toBe('linear')+ })++ it('keeps bit-exact NEAREST at and above 1', () => {+ expect(atlasFilterChoice(1).min).toBe('nearest')+ expect(atlasFilterChoice(1.5).min).toBe('nearest')+ })++ it('still reaches for the mip chain on a GENUINE zoom-out', () => {+ // This is what the chain is for: at 0.5 or 0.3 several texels really do land in one pixel, and+ // level 0 alone undersamples into shimmer.+ expect(atlasFilterChoice(0.85).min).toBe('trilinear')+ expect(atlasFilterChoice(0.5).min).toBe('trilinear')+ expect(atlasFilterChoice(0.1).min).toBe('trilinear')+ })++ it('leaves the magnification rule alone', () => {+ // Unchanged from the 2026-08-04 parity call: 1 is on the crisp side, above it LINEAR matches+ // the bilinear upscale GPU mode gets from its CSS transform.+ expect(atlasFilterChoice(1).mag).toBe('nearest')+ expect(atlasFilterChoice(0.976).mag).toBe('nearest')+ expect(atlasFilterChoice(1.0001).mag).toBe('linear')+ })+})diff --git a/src/renderer/glyphgrid/gl-webgl2.ts b/src/renderer/glyphgrid/gl-webgl2.tsindex a2aff0cf9..65f022e54 100644--- a/src/renderer/glyphgrid/gl-webgl2.ts+++ b/src/renderer/glyphgrid/gl-webgl2.ts@@ -37,6 +37,46 @@ import { plateRadiusDevice, plateRectDevice, plateShapeDevice } from './plate'*/const MAX_SAFE_LOD = Math.floor(Math.log2(2 * GUTTER_PX))+/**+ * How close to 1 a zoom may be and still be sampled from LEVEL 0 alone.+ *+ * The mip chain exists for GENUINE zoom-out — a canvas at 0.3 or 0.5, where many texels really do+ * fall into one pixel and plain LINEAR undersamples into shimmer. It was being applied the instant+ * zoom dropped below 1, which is where the 2026-08-09 "text isn't so crisp, might be retina"+ * report came from: the reporting canvas sat at **0.976**. For a 2.4% minification the sampler was+ * blending a half-resolution mip into every glyph — a lot of blur to pay for almost no scaling,+ * and exactly the difference against GPU mode, where xterm draws 1:1 and the COMPOSITOR does the+ * 0.976 in one high-quality pass.+ *+ * A canvas is very rarely at exactly 1. Any pinch, any fitView, any window resize lands on a+ * number like this one, so the near-1 band is not an edge case — it is where most users sit.+ *+ * 0.9 is the floor because that is where dropped texels stop being negligible: at 0.976 roughly+ * one column in forty is skipped, at 0.9 one in ten, and past that a stem starts losing a pixel+ * often enough to read as raggedness rather than as sharpness.+ */+const NEAR_ONE_ZOOM = 0.9++/** The atlas sampler's two filters for a zoom, as names rather than GL enums so the rule can be+ * tested without a GL context. */+export function atlasFilterChoice(zoom: number): {+ min: 'nearest' | 'linear' | 'trilinear'+ mag: 'nearest' | 'linear'+} {+ // MAG is unchanged: 1 belongs on the crisp side, and above it LINEAR matches the bilinear+ // upscale GPU mode gets from its CSS transform (the 2026-08-04 parity call).+ const mag = zoom > 1 ? 'linear' : 'nearest'+ // At or above 1 nothing is minified and NEAREST is bit-exact.+ if (zoom >= 1) return { min: 'nearest', mag }+ // Just below 1: minified, but barely. LEVEL 0 with LINEAR keeps the glyph's own texels and+ // weights them almost entirely towards the nearest one — sharp, and without the mip blur.+ if (zoom >= NEAR_ONE_ZOOM) return { min: 'linear', mag }+ // Genuine zoom-out: several texels per pixel. Trilinear over the mip chain, which is what stops+ // a zoomed-out canvas shimmering — safe only because the slots carry gutters and the sampler is+ // clamped to MAX_SAFE_LOD, so a minified glyph never averages in its neighbour's ink.+ return { min: 'trilinear', mag }+}+const VERT = `#version 300 es// One instance per CELL. Two triangles from gl_VertexID (0..5), no vertex buffer.uniform vec2 uPan; // camera pan (screen px)@@ -354,8 +394,14 @@ export function createWebgl2GL(canvas: HTMLCanvasElement): GlyphGL | null {* darkening towards the background.*/const applyAtlasMinFilter = (zoom: number): void => {- const wantMin = zoom >= 1 ? gl.NEAREST : gl.LINEAR_MIPMAP_LINEAR- const wantMag = zoom > 1 ? gl.LINEAR : gl.NEAREST+ const choice = atlasFilterChoice(zoom)+ const wantMin =+ choice.min === 'nearest'+ ? gl.NEAREST+ : choice.min === 'linear'+ ? gl.LINEAR+ : gl.LINEAR_MIPMAP_LINEAR+ const wantMag = choice.mag === 'linear' ? gl.LINEAR : gl.NEARESTif (wantMin === atlasMinFilter && wantMag === atlasMagFilter) returngl.bindTexture(gl.TEXTURE_2D, atlasTex)if (wantMin !== atlasMinFilter) {