Skip to content

fix(term): keep kitty images in the scrollback as history - #31

Open
Mirr0ch1 wants to merge 1 commit into
RoversX:mainfrom
Mirr0ch1:fix/scrollback-image-history
Open

Mirr0ch1 wants to merge 1 commit into
RoversX:mainfrom
Mirr0ch1:fix/scrollback-image-history

Conversation

@Mirr0ch1

@Mirr0ch1 Mirr0ch1 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A kitty picture that has scrolled into the scrollback is history. Deleting its placement or its image data used to reach back through every physical line and detach it from the scrollback too. A mux client that had already painted some of those rows kept them, while rows it refetched came back without the picture, so scrolling back showed the image torn into bands or gone.

This keeps the pixels on scrollback rows and strips their kitty identity instead (ImageCell::as_history()): history still paints, a client can fetch it by cell through the existing GetImageCell path, and a later reuse of the image id cannot rewrite it. Deletion on the visible screen is unchanged.

Part of #29. This fixes the history-loss half; the fast-output viewport half is #34.

Validation

  • cargo test -p wezterm-cell -p wezterm-term --lib — 18 + 203 passed.
  • New regression tests:
    • deleting_an_image_leaves_its_scrollback_history_painted
    • deleting_a_visible_image_still_takes_it_off_the_screen
  • Updated kitty_delete_all_preserves_scrollback_inactive_screen_and_unplaced_data for the new history cells.
  • Manual end-to-end with a mux client: print a 20-row picture, push it into the scrollback, delete it with a=d,d=I, print 1000 lines, scroll back. 0.4.9 shows a blank block; with this branch the picture is intact.

Evidence (screenshots, logs, repro scripts):

I did not run the full cargo test --workspace; the focused suites above and cargo check for the affected crates pass.

Third-party material

None. All code is my own; the test pattern is generated by ImageMagick.

Contributor agreement

I agree to the ThinkTerm Contributor Agreement version 1.2 for this contribution, including the permission for a future MIT release and the patent license, and confirm I am authorized to make these grants.

A picture that has scrolled out of the screen is history, but deleting
its placement or its image data reached back through every physical line
and detached it from the scrollback too. A mux client that had already
painted some of those rows kept them, while rows it refetched came back
without the picture, so scrolling back showed the image torn into bands
(or gone).

Rows above the visible area now keep the ImageCell with its pixels and
texture coordinates, stripped of its kitty identity: the history still
paints, a client can fetch it by cell, and a later reuse of the image id
cannot rewrite it. Deletion on the visible screen is unchanged.
@Mirr0ch1

Copy link
Copy Markdown
Contributor Author

Scope note after further testing: this PR fixes the reproducible image history loss — a program deleting an image (kitty d=I) erases the part already in ThinkTerm's scrollback. It does not by itself explain the separate fast-output tear reported in the follow-up comment on #29 (top frozen, bottom following the live tail, with no image involved). That one is still being isolated and may live in the agent TUI or a viewport/fetch race rather than the kitty image path. Keeping this PR focused on the terminal-side history bug.

This branch has not been deployed

No deployments
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