mirror of
https://github.com/donlucasx/xscapes.git
synced 2026-10-20 08:43:32 +02:00
His OK, "Yes, in its own window". The probe ran in a window the script opened
and closed, resolved by the tty of the `do script` tab; his three windows were
never named.
Painted 120 wide, narrowed to 74, deleted rows 10-20 inside a scroll region and
repainted them at 74, widened back to 120, read the cells back:
rows 10-20 74 cells the retained tail is GONE
rows 1-4, 8-9, 21-24 120 cells controls, tails intact
row 7, narrow repaint 120 cells R07 + 70 g + < + 45 G + <
Row 7 reproduces item 3 exactly -- a repaint at the narrow width leaves the old
tail behind the new cells -- and the controls coming back at 120 are what makes
the DL rows' 74 mean something. So erase cannot reach those cells and a repaint
cannot, but replacing the row can: DL allocates a genuinely new row at the
visible width. It is the one mechanism that works and it touches only rows we
own, which is the objection that ruled out ESC[2J.
Item 4 of the audit was WRONG and is struck. The window IS snapped to the cell
grid: Terminal.app holds a fixed 20 px inset on each side and the text grid is
an exact multiple of the 14.000 px cell. Content width minus columns x 14 is
exactly 40 px on all five frames now measured -- 143x62, 120x30, 116x37, 76x41.
The "123.6 columns" reading divided the whole content view by the column count
and absorbed both insets; it is the same arithmetic that produced the bogus
14.28 px pitch this session started with. What survives is the half that
mattered: the inset is drawable, Terminal.app paints retained cells into it, and
they sit at columns W+1 and W+2 -- outside the grid, so no column-addressed
sequence can name them.
Also recorded: his line-spacing test failed ("no, it didnt"), so the hairline
cannot be removed inside half blocks, only not drawn; and the three frames he
sent at 120x30, 116x37 and 76x41 give the defect its own control -- the frame he
did not narrow into is clean at 5.4% of the inset, the two he did are 48.6% and
50.4%.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UJvgity4qhHtTGojUkFivG
79 lines
4.8 KiB
Markdown
79 lines
4.8 KiB
Markdown
# Width audit — Terminal.app's alternate screen on a WIDTH change
|
||
|
||
*2026-09-05, session 16. Measured with `notes/widthprobe` in windows a script opened
|
||
(resolved by the tty of the `do script` tab, no keystrokes), read back with
|
||
`history of tab`. His OK: "go ahead".*
|
||
|
||
## Why
|
||
|
||
His Terminal.app at 123x55, after a drag that changed the WIDTH as well as the
|
||
height (the trace: 34 resizes, 120 → 130 → 123 columns), showed the band's last
|
||
column painted with cells from several rows lower, and a six-column patch of scape
|
||
cells in the three rows above the band at the left edge. The host's bytes replay
|
||
CLEAN in the screen model (`TestReplayTrace`, `TRACE_RETAIN=0`). The model's width
|
||
rule for the alternate screen -- cut to the new width, pad with blanks -- had never
|
||
been measured; session 13 measured height only.
|
||
|
||
## Measured
|
||
|
||
1. **Retain and clip.** A row keeps every cell it ever had, at the widest the window
|
||
has been. Narrowing 120 → 74 clips the display; the read-back still holds all 120
|
||
cells of every row, `<` marker in column 120 included. Widening 74 → 80 → 86 shows
|
||
the retained cells again in the new columns. No reflow, no wrap, no blanking.
|
||
(Driver 1: before / 74 / 80 / 86 -- four identical read-backs.)
|
||
2. **Erase-line reaches the visible width only.** At 74 columns, `ESC[2K` on a
|
||
120-cell row left cells 75–120 in place (`EEE…E<`, 46 cells); `ESC[K` from column 3
|
||
kept `R0` and the same tail. Widening to 100 showed the tail in columns 75–100.
|
||
3. **A repaint at the narrow width leaves the tail.** Row 7 rewritten at 74 columns
|
||
read back as the new 74 cells followed by the old 46 (`R07ggg…gGGG…G<`).
|
||
4. ~~**The window is not snapped to the cell grid.**~~ **WRONG, corrected 2026-09-07.**
|
||
The window IS snapped: Terminal.app holds a fixed **20 px inset on each side** and the
|
||
text grid is an exact multiple of the 14.000 px cell. Measured on five frames --
|
||
143x62, 120x30, 116x37, 76x41 -- content width minus columns x 14 is **exactly 40 px
|
||
in every one**. The 123.6-column reading came from dividing the whole content view by
|
||
the column count, which absorbs the two insets; it is the same arithmetic that later
|
||
produced a bogus 14.28 px pitch. What is true, and is the load-bearing half: the inset
|
||
is DRAWABLE, Terminal.app paints RETAINED cells into it, and those cells sit at columns
|
||
W+1 and W+2 of a W-column terminal -- outside the grid, so no column-addressed sequence
|
||
can name them.
|
||
|
||
5. **DL DROPS THE RETAINED CELLS.** (2026-09-07, `notes/widthprobe` + `drive-dl.sh`, his
|
||
OK: *"Yes, in its own window"*.) Painted 120 wide, narrowed to 74, then deleted rows
|
||
10-20 inside a scroll region and repainted them at 74; widened back to 120 and read the
|
||
cells back.
|
||
- **Rows 10-20 came back 74 cells long.** The retained tail is gone.
|
||
- **Control rows 1-4, 8-9, 21-24 came back 120 cells long**, tails intact -- so the
|
||
read-back can see tails, and the narrow/widen really happened.
|
||
- **Row 7, the narrow-repaint arm, came back 120**: `R07` + 70 `g` + `<` + 45 `G` + `<`
|
||
-- the new cells followed by the old tail, reproducing item 3 exactly.
|
||
So erase cannot reach those cells and a repaint cannot, but **replacing the row can**: DL
|
||
allocates a genuinely new row at the visible width. It is the one mechanism that works,
|
||
and it is contained to rows we own.
|
||
|
||
## Consequences for the host
|
||
|
||
- A narrowing followed by a widening exposes old cells in the new columns of EVERY
|
||
row until something repaints them. The band repaints in full on the tick after a
|
||
resize (`dmg.reset`), so its exposure lasts one tick. The agent's rows are Claude's:
|
||
Ink erases with `ESC[2K`, which reaches the visible width only, so a widened window
|
||
shows stale tails in transcript rows Claude does not rewrite. Not ours.
|
||
- The partial column cannot be painted (it is beyond the reported width) and cannot
|
||
be cleared (no erase reaches hidden cells). Cosmetic, Terminal.app only, and only
|
||
after a narrow-from-wider to a non-grid width. Documented, not fixed.
|
||
- The six-column patch above the band is NOT reproduced under either width rule.
|
||
Still open. It is not retained-cell exposure (it sits at columns 1–7).
|
||
|
||
## The model
|
||
|
||
`screen.retainWidth` (off by default; Ghostty's source cuts and pads, and every
|
||
height test was written against that) keeps rows at their widest and clips erases to
|
||
the visible width. `TestReplayTrace` and the trace probes take `TRACE_RETAIN=1`.
|
||
|
||
## Also measured the same day
|
||
|
||
Terminal.app's U+2580 ink starts 5px below the cell top and stops 13px above the
|
||
bottom (Menlo, 30px rows); U+2584's ink runs from 17px to the bottom edge exactly.
|
||
So a split cell drawn with U+2584 and the colours the other way up has no hairline.
|
||
`term.LowerHalf`, picked by `DetectSplit` from `TERM_PROGRAM`; `XSCAPES_SPLIT`
|
||
overrides. Measured from his saved screenshot of a printf test, stripe by stripe.
|