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(terminal): keep the hysteresis band when a ratio change keeps the thresholds (#986)

Erik Zwep85fb6758e987
diff --git a/src/renderer/terminal/webgl-budget.test.ts b/src/renderer/terminal/webgl-budget.test.ts
index 8550d5881..296980536 100644
--- a/src/renderer/terminal/webgl-budget.test.ts
+++ b/src/renderer/terminal/webgl-budget.test.ts
@@ -512,6 +512,20 @@ describe('webgl-budget coordinator', () => {
expect(a.rec.held).toBe(true)
})
+ it('a ratio change that keeps the same thresholds keeps the hysteresis band', () => {
+ // 2 → 3 (a move between two retina-class displays, or browser zoom) does not change the
+ // thresholds, so a terminal crisp at 170% (inside the 160–175% band) must stay crisp.
+ setWebglDevicePixelRatio(2)
+ const a = fakeClient('a')
+ grant(a)
+ zoomTo(1.8)
+ zoomTo(1.7)
+ expect(a.rec.held).toBe(false)
+ setWebglDevicePixelRatio(3)
+ vi.advanceTimersByTime(WEBGL_DRAIN_MS * 10)
+ expect(a.rec.held).toBe(false)
+ })
+
it('ignores a non-finite or non-positive ratio', () => {
const a = fakeClient('a')
grant(a)
diff --git a/src/renderer/terminal/webgl-budget.ts b/src/renderer/terminal/webgl-budget.ts
index 7e7f230f7..10ab6116e 100644
--- a/src/renderer/terminal/webgl-budget.ts
+++ b/src/renderer/terminal/webgl-budget.ts
@@ -169,15 +169,19 @@ let devicePixelRatio = Number.POSITIVE_INFINITY
/**
* Report the window's devicePixelRatio (it changes when the window moves between displays, and
- * with browser zoom in the Server Edition). Re-evaluates the current zoom against the ENTRY
- * threshold of the new display only: hysteresis guards a pinch hovering at one boundary, and a
- * display change is not that — at 170% on a 1x display the terminals are crisp, and 170% on a
- * retina display never crossed its 175% line, so they belong back on the GPU.
+ * with browser zoom in the Server Edition). When the change crosses the low-DPI line, the current
+ * zoom is re-evaluated against the ENTRY threshold of the new display only: hysteresis guards a
+ * pinch hovering at one boundary, and a display change is not that — at 170% on a 1x display the
+ * terminals are crisp, and 170% on a retina display never crossed its 175% line, so they belong
+ * back on the GPU.
*/
export function setWebglDevicePixelRatio(dpr: number): void {
if (!Number.isFinite(dpr) || dpr <= 0 || dpr === devicePixelRatio) return
+ // Only a change of threshold pair skips the band: 2 → 3 keeps 175/160, and a terminal held
+ // crisp inside that band must stay crisp.
+ const thresholdsChanged = dpr < LOW_DPI_BELOW !== devicePixelRatio < LOW_DPI_BELOW
devicePixelRatio = dpr
- applyZoomCrisp(lastZoom, true)
+ applyZoomCrisp(lastZoom, thresholdsChanged)
}
/**