Skip to content

Join borders only within a layer - #199

Merged
brainkim merged 3 commits into
mainfrom
fix/border-layer-join
Nov 23, 2026
Merged

brainkim merged 3 commits into
mainfrom
fix/border-layer-join

Conversation

@brainkim

@brainkim brainkim commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

A sticky header with a border-bottom grew a tee in its rule wherever a border scrolled under it. Reported from Riposte's pager, where a blockquote's border-left passes under the header:

 Re: The card reader jams on card 7
─┬──────────────────────────────────────────
 │ I don't think it is the cards. ...

Cause

joinTouchingBorders joins any two strokes in neighbouring cells. It reads only the cells, with no record of which layer painted each stroke, so the header's rule joined a bar in the layer beneath it.

Change

  • The painter says which layer it is painting (CellContext.layer): a stacking context, or a sticky or fixed box with no z-index, which stays put while others scroll under it.
  • The framebuffer keeps, for the frame last painted, which layer stroked each border (Framebuffer.layers). joinRow skips a neighbour in another layer, and a border drawn in a cell that holds another layer's border replaces it instead of merging into a cross.
  • isolation is among the properties whose change repaints a box. Giving a box isolation: isolate changed the layer of the borders inside it and repainted nothing.

Layout

The layers are not part of CellGrid. A grid is what the terminal shows: it is swapped with the last frame's and compared with it, and it is also a pty's screen, a canvas's cells and the diff. Which layer stroked a border is the painter's record, read only by the join, like the borders as painted that prevBorders keeps. Nothing compares it with the frame before, so there is one array, written in place: a frame painted over the last writes only in its bands, and a value in a cell with no border is never read. It shifts with prevBorders when the terminal scrolls rows.

A grid drawn into another has its borders settled into glyphs first, so the layers never travel with a grid. An iframe's renderer keeps its own array and settles its own borders.

The number is an id for the layer's element, the same every frame. The join only asks whether two are equal.

Not changed

  • A positioned box with z-index: auto is not a layer here. A position: relative table cell would otherwise lose its corners.
  • A bordered scroller still joins with a border scrolled inside it (┌┬). That content is in the scroller's own layer, only clipped. Refusing every join across a clip would break a bordered overflow: auto panel whose dividers meet its walls, so it needs a rule of its own.

Tests

In tests/sticky-position.test.ts: the rule stays plain as the bar scrolls under it across partial repaints, with and without a z-index; the same inside an iframe; a rule still joins a bar in its own layer; and a box that becomes a layer repaints the borders inside it. Under tests a frame that repaints some rows is checked against one painted whole, now on the layers too. The full suite passes on Node and Bun.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GVbRv5n8btiCtaRBtLrLig

brainkim and others added 3 commits November 23, 2026 14:51
Borders whose strokes touch join into corners and tees by the cells
alone, so a sticky header's rule grew a tee wherever a border scrolled
under it. Each border cell now records the stacking context that
stroked it, and strokes join only within one. A border drawn over
another layer's covers it instead of crossing it. A sticky or fixed
box is a layer of its own with no z-index too.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GVbRv5n8btiCtaRBtLrLig
A grid is what the terminal shows: it is swapped with the last frame's
and compared with it. Which layer stroked a border is the painter's
record, read only where borders join, so the framebuffer keeps one
array of it for the frame last painted and writes it in place, as it
keeps the borders as painted. A frame keeps its own and joins its own
borders.

A frame that repaints some rows is now checked against a whole one on
the layers too, which found that a box given isolation repainted
nothing though its borders changed layer.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GVbRv5n8btiCtaRBtLrLig
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GVbRv5n8btiCtaRBtLrLig
@brainkim
brainkim force-pushed the fix/border-layer-join branch from d3c0bda to fbe4760 Compare November 23, 2026 19:54
@brainkim
brainkim merged commit a029090 into main Nov 23, 2026
10 checks passed
@brainkim
brainkim deleted the fix/border-layer-join branch November 23, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant