Repository navigation
Description
Scrollback pictures tear: history is erased, and fast output mixes viewport geometries
This is the umbrella issue for the picture tearing seen in a remote ThinkTerm pane while a coding agent (oh-my-pi / omp) streams. Two independent defects produce the same visible symptom, so the fixes are split into two PRs.
Symptoms
1. A picture that scrolled into history tears or disappears
A kitty image renders correctly while it is on screen. After enough output pushes it into the scrollback, scrolling back shows it torn into horizontal bands, or gone entirely.
omp keeps at most tui.maxInlineImages (default 8) inline pictures live. Past that it sends the kitty delete command for the oldest one:
ESC _ G a=d,d=I,i=<image-id>,q=2 ESC \
The server log from a real session shows the store capped at 8 pictures after 600 and 1500 transmits: kitty-store.log.
On 0.4.9 (9963017f) that delete detaches the picture from every physical line, including rows already in the scrollback. The remote GUI keeps a per-row line cache and does not refetch all rows at once, so rows still cached keep pixels while rows refetched after the delete come back blank: the picture tears into bands, then disappears.
Fix: #31 — scrollback rows keep the ImageCell with its pixels, stripped of its kitty identity (ImageCell::as_history()). Visible rows are detached exactly as before. A mux client can still fetch the surviving history by cell through GetImageCell, and a later reuse of the image id cannot rewrite it.
2. Even with no picture, fast output + scrolling up tears the viewport
While the agent is streaming fast, scrolling up even a little can leave the top half frozen while the bottom half keeps following the live tail, line by line. The right overlay scrollbar is ThinkTerm's (outside the terminal grid) and it moves during the tear. It happens with no images and no d=I at all, and it happens with both Stepped and Smooth trackpad scrolling, so it is not the kitty image path and not the pixel-scroll path.
The same boundary cuts a picture in half when one spans it, which is why this looks like "the image tears".
Cause (candidate, needs validation): read_pane_changes in the mux server reads the pane's geometry/cursor/seqno, then takes the terminal lock again for the viewport rows. The pane's parser runs on its own thread and can scroll the screen between those reads. The rows then come from the old viewport while the push reports the old physical_top as the live screen. A client that is scrolled back renders an old row at a stable index that now holds a different line, producing the top/bottom split.
Fix: #34 (draft) — re-read the geometry/cursor/seqno after the rows and report that later state. Rows from the old viewport are then labelled as history; the new live rows are left for the client's next paint. This is server-side only.
Evidence
0.4.9 server, after d=I and scrolling back to the picture (the 20 rows between BEFORE-IMAGE and AFTER-IMAGE are blank):
Control: the same test without d=I, after 3000 lines and scrolling back. Refetching works; the picture is intact:
The patched server, same d=I test as the first screenshot:
More detail and scripts: evidence NOTES.
For the viewport tear, the reporter confirms the moving scrollbar is ThinkTerm's and that it persists in Stepped mode. No screenshot of that split is attached yet; the server-side geometry race is the current hypothesis, and #34 is marked draft until it is validated on the reporter's macOS trackpad + omp setup.
Reproduction
Picture history (deterministic)
On a mux-hosted pane (the GUI may be on another machine):
- Print a 20-row kitty image with a unique image id and explicit placement id (
a=tthena=p,i=<id>,p=<pid>,c=..,r=..). - Print ~30 lines so the picture is in the scrollback, then send
ESC _ G a=d,d=I,i=<id>,q=2 ESC \. - Print ~1000 lines, scroll back to the picture.
scroll_test.py does exactly this (delete vs keep); stripes.png is the labelled 20-row pattern.
Viewport tear (reported)
With an agent streaming fast in a remote pane, scroll up a little with a trackpad while output continues. The top stays, the bottom follows the live tail, and the right overlay scrollbar moves. It reproduces in both Stepped and Smooth scroll modes.
Fixes
- fix(term): keep kitty images in the scrollback as history #31 — keep kitty pictures that have scrolled into the scrollback as history; do not let
d=Ierase them. Tested:wezterm-cell18,wezterm-term203, plus new regression tests. - fix(mux): report the geometry that follows the rows a push copied #34 (draft) — report the mux server geometry that follows the rows a push copied, instead of the geometry that preceded them, so a scrolled client is not handed old viewport rows labelled as live. Needs validation on the reporter's fast-output case.
Not part of this issue: terminal file links that run the opener on the wrong host are tracked separately in #30 / #32.
Expected behavior
- Once a row has scrolled into the scrollback, later output must not rewrite or erase that history, including pictures the program no longer keeps live.
- A viewport that the user scrolled back should not mix two different geometries. If the server cannot produce a consistent snapshot in one read, it should report the later geometry and let the client fetch the new live rows on the next paint.



Activity
[-]Kitty images are erased from the scrollback when a program deletes them (tearing after scroll)[/-][+]Scrollback pictures tear: history is erased, and fast output mixes viewport geometries[/+]