From c54867d9f0470c5d8e792942476c81d21a7c35d7 Mon Sep 17 00:00:00 2001 From: Codeman maintainer Date: Wed, 7 Oct 2026 03:49:21 +0200 Subject: [PATCH] refactor(tiles): _tileGridLimit measures the terminal area itself _tileGridCapacityNow had one caller, _tileGridLimit, and only measured the area (the grid section, or the single view the grid would replace) for it. The measurement now sits in _tileGridLimit, whose doc comment says what is measured. Co-Authored-By: Claude Opus 5.5 (1M context) --- src/web/public/tile-grid.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/web/public/tile-grid.js b/src/web/public/tile-grid.js index 13857ec1..d2ef4461 100644 --- a/src/web/public/tile-grid.js +++ b/src/web/public/tile-grid.js @@ -336,24 +336,21 @@ Object.assign(CodemanApp.prototype, { btn.setAttribute('aria-label', title); }, - /** How many tiles the terminal area can hold right now (the grid section, or the single view it would replace). */ - _tileGridCapacityNow() { + /** + * How many tiles the grid takes here and now: what the terminal area fits + * (the grid section, or the single view it would replace), at most the cap + * (TILE_GRID_MAX), never less than one. The texts say which of the two + * binds, so a large monitor never reads "this window fits 6". + */ + _tileGridLimit() { + const T = window.CodemanTileGrid; + const max = T.TILE_GRID_MAX; const el = this._tilesOwnTerminal() ? this._tileGridSection() : document.querySelector('.terminal-wrap'); const rect = el?.getBoundingClientRect?.() || { width: 0, height: 0 }; - return window.CodemanTileGrid.tileGridCapacity({ + const fits = T.tileGridCapacity({ width: rect.width || window.innerWidth, height: rect.height || window.innerHeight, }); - }, - - /** - * How many tiles the grid takes here and now: what the window fits, at most - * the cap (TILE_GRID_MAX), never less than one. The texts say which of the - * two binds, so a large monitor never reads "this window fits 6". - */ - _tileGridLimit() { - const max = window.CodemanTileGrid.TILE_GRID_MAX; - const fits = this._tileGridCapacityNow(); const capacity = Math.max(1, Math.min(fits, max)); const byCap = fits >= max; return {