Skip to content

Render Kitty images at Unicode placeholder cells - #26031

Merged
nwparker merged 5 commits into
mainfrom
codex/inline-image-placeholders
Oct 16, 2026
Merged

nwparker merged 5 commits into
mainfrom
codex/inline-image-placeholders

Conversation

@nwparker

@nwparker nwparker commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1504 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1499
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1928 $\color{#cf222e}{\Huge{\mathbf{−}}}$​87 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1841

ELI5

Applications can display images through Kitty's text-cell placeholders. Replacing an image keeps the old picture visible until the new one is ready, without flashing blank or showing reserved characters.

Merged as 26278b32ce84 on October 16. #28200 is also merged as 90849ed0c6ff for Claude file images. #25109 is closed.

What Changed

The existing image addon parses virtual placements and draws fragments at U+10EEEE cells. Replacement retains decoded placements while a new source is prepared, rejects stale decode results and releases failed/superseded bitmaps. Virtual placements reuse existing storage limits.

The upgraded addon uses upstream cell payloads and buffer accessors. Its duplicated image-attribute class and our changes to that class are gone. Placeholder lookup uses getExtended, which checks the current cell flag before exposing underline metadata. A regression verifies glyph masking preserves a real physical tile payload, links, colors and text.

The three small core attribute corrections remain: retain underline color without visible underlining, refresh the extended flag after SGR 58 and normalize the default-color sentinel. The retention check also preserves upstream's new payload condition. Existing invisible-text flags and a cancellable microtask timer handle glyph masking and scroll batching.

Why

This builds on the upgraded storage rather than maintaining the removed attribute implementation. It reuses parsing, allocation, cleanup and cell metadata while keeping placeholder support separate from the dependency upgrade.

The original implementation comes from emmahyde's #23616. Replacement and glyph corrections follow edenaion's report and proposed fix, integrated without its larger dependency stack.

Linked Issue

Addresses the placeholder protocol portion of #23615 and #25109. Claude’s reported file-backed paste also requires stacked #28200; this PR alone does not close that use case. Cold-remount restoration remains separate.

Visual Proof

Existing before/after replacement proof, with both decodes held at the same boundary:

DOM replacement during decoding

WebGL replacement during decoding

Reserved glyph before and after

Those comparisons were recorded before the beta upgrade. Ten fresh real-PTY pixel cases pass on this upgraded stack, including active WebGL, named placements, letterboxing, transparency and delete/recreate repaint.

Testing

  • Full application typechecking and changed-code quality pass on refreshed head 0dc7b4a59dd4, based on main 9b99928cb50f.
  • 166 image/source/payload/underline/scroll contracts and 222 terminal-input/IME contracts pass. These groups overlap and are not a unique-test total.
  • Both fresh frozen dependency installation and all five canonical package/source patch reproduction checks pass. The merged core patch preserves the newer main input changes.
  • The fresh hidden macOS image matrix passes 29 image cases. One additional execution times out waiting for its PTY before any image command; three unchanged targeted diagnostic executions subsequently pass. The original failure and trace remain retained.
  • Both reporters independently confirmed 30/30 on the earlier head 8a5afc6f, on macOS 27.0.1.
  • Historical Windows/WSL image validation passed all 14 cases without skips or retries. The refreshed child has a fresh Windows/WSL run passing all 12 image and 9 WSL launch/paste executions without skips or retries.
  • Full hosted CI is not certified green. The Windows ARM persistence job later timed out in its afterEach cleanup at orcad-serve-parity.integration.test.ts:34, after the restart assertions. No baseline reproduction yet; the failed job is retained. Other hosted checks continue.

Review

Refreshed onto current main without adding unrelated application changes. The earlier native-chat typecheck blocker is resolved by the current main source. Three core attribute corrections remain; the upstream placeholder issue and PR are still open. The parent changes 17 expected files.

The original terminal-startup timeout is retained and has no established image-related cause. A separate original-plugin failure in the child was traced to the plugin asking for a converted PNG that does not exist; the bounded file reader correctly rejects it. It does not require another core patch.

The invisible flag persists until overwrite, including after addon disposal, and serializers can observe it. Buffer internals remain pinned. Physical placement ownership, negative-z layering and cold-remount restoration remain separate work. Claude file sources require stacked #28200. No remote wire format changes.

Agent skill upstream boundary

  • Not applicable; no agent skill source changes.

Checklist

  • Focused on placeholder parsing, rendering and resource ownership.
  • Explained behavior, mechanism and smaller approach.
  • Visual proof attached; fresh upgraded-stack pixel checks pass.
  • Self-reviewed ownership, cell metadata, cleanup and bounds.
  • Cross-platform, remote and mixed-version impact considered.
  • Final required CI and platform checks pass.

@edenaion

Copy link
Copy Markdown

Found a flicker when a placeholder image is animated by retransmitting it under the same id (a=T,f=100,i=77,U=1,c=..,r=.., the path Claude Code's plugin Image element uses for video).

KittyImageStorage.storeImage() deletes the image's virtual placements as soon as the new bytes arrive, and the replacement placement is added only after _renderPlacement finishes its asynchronous decode. Under load (two or three 80x22 placeholder grids at 12 fps) every cell of the image shows its raw placeholder glyph for whole frames: 12 of 90 screenshots in my test on native Windows.

Fix on my fork: edenaion@d10ca74

☼ A retransmit with U=1 keeps the visible placements until the decoded replacement is added, then swaps once. A decode that fails drops the stale picture; a decode superseded by a newer command keeps it for that command to replace.

☼ Placeholder cells whose image or placement is unknown, deleted or still decoding draw nothing instead of the glyph.

Same run after the fix: 0 of 90. It adds lifecycle and glyph-contract cases (7 of 18 fail before the change) and regenerates the addon patch with regenerate-xterm-patches.mjs. It sits on this stack's tip (codex/inline-image-orphan-checkpoints) merged with current main, so picking it up may need a small rebase.

@nwparker

Copy link
Copy Markdown
Contributor Author

Found a flicker when a placeholder image is animated by retransmitting it under the same id (a=T,f=100,i=77,U=1,c=..,r=.., the path Claude Code's plugin Image element uses for video).

KittyImageStorage.storeImage() deletes the image's virtual placements as soon as the new bytes arrive, and the replacement placement is added only after _renderPlacement finishes its asynchronous decode. Under load (two or three 80x22 placeholder grids at 12 fps) every cell of the image shows its raw placeholder glyph for whole frames: 12 of 90 screenshots in my test on native Windows.

Fix on my fork: edenaion@d10ca74

☼ A retransmit with U=1 keeps the visible placements until the decoded replacement is added, then swaps once. A decode that fails drops the stale picture; a decode superseded by a newer command keeps it for that command to replace.

☼ Placeholder cells whose image or placement is unknown, deleted or still decoding draw nothing instead of the glyph.

Same run after the fix: 0 of 90. It adds lifecycle and glyph-contract cases (7 of 18 fail before the change) and regenerates the addon patch with regenerate-xterm-patches.mjs. It sits on this stack's tip (codex/inline-image-orphan-checkpoints) merged with current main, so picking it up may need a small rebase.

Thanks, will pick up your change 🫡

@nwparker
nwparker marked this pull request as ready for review October 12, 2026 06:05
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 30e46904-d742-4cf0-9519-c3833b9c1ffd
📥 Commits

Reviewing files that changed from the base of the PR and between b5c8635 and 2e16b1e.

📒 Files selected for processing (1)
  • tests/e2e/terminal-kitty-placeholders.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

📝 Walkthrough

The image addon now supports Kitty Unicode placeholder placements. It parses placeholder metadata, stores virtual images, and renders image tiles in matching terminal cells. Image decoding and storage enforce limits and discard stale results. Rendering handles source and display cell dimensions, aspect ratios, and placeholder visibility. The changes also update underline-color handling and add unit and end-to-end tests for placement, rendering, deletion, and lifecycle behavior.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 2e16b

The available change context identifies added placeholder-image end-to-end coverage and no concrete merge-blocking risk; the reported validation runs pass.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Out of Scope Changes check Warning The PR includes changes with no demonstrated connection to #23615. The xterm core patch changes src/common/SortedList.ts. The image-addon patch also changes general IIP and SIXEL decoder allocation … Remove the unrelated SortedList and IIP/SIXEL decoder changes from this PR, or link them to separate active coding objectives and provide evidence that they are required for #23615.
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 12 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Linked Issues check Passed The PR implements the coding requirements in #23615. The Kitty handler parses U=1 as a virtual placement. Placeholder cells use U+10EEEE, image IDs, and combining diacritics to select tiles. `ImageR…
Title check Passed The title clearly and concisely describes the primary change: rendering Kitty images at Unicode placeholder cells.
Description check Passed The description is complete and aligned with the template. It explains the user-visible behavior, implementation, rationale, issue references, visual proof, testing, review notes, scope boundaries, an…
Full details: Out of Scope Changes check

Explanation

The PR includes changes with no demonstrated connection to #23615. The xterm core patch changes src/common/SortedList.ts. The image-addon patch also changes general IIP and SIXEL decoder allocation and pooling behavior. These changes do not implement Kitty virtual-placement parsing, placeholder-cell rendering, or glyph suppression.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
config/scripts/xterm-image-kitty-retransmit.test.mjs (1)

219-232: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Put the disposal test cleanup in try/finally.

All other tests in this file call h.terminal.dispose() inside finally. This test does not. A failed assertion on Lines 227-230 skips h.terminal.dispose(), so the terminal stays alive. If vi.waitFor times out, writing also stays pending. Wrap these lines in try/finally so cleanup runs after a failure.

Proposed fix
-    await vi.waitFor(() => expect(pending).toHaveLength(1))
-    h.addon.dispose()
-    pending[0].resolve(stale)
-    await writing
-    expect(h.storage._images.size).toBe(0)
-    expect(h.kitty._virtualPlacements.size).toBe(0)
-    expect(first.close).toHaveBeenCalledOnce()
-    expect(stale.close).toHaveBeenCalledOnce()
-    h.terminal.dispose()
+    try {
+      await vi.waitFor(() => expect(pending).toHaveLength(1))
+      h.addon.dispose()
+      pending[0].resolve(stale)
+      await writing
+      expect(h.storage._images.size).toBe(0)
+      expect(h.kitty._virtualPlacements.size).toBe(0)
+      expect(first.close).toHaveBeenCalledOnce()
+      expect(stale.close).toHaveBeenCalledOnce()
+    } finally {
+      h.terminal.dispose()
+    }

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 882449f4-1999-4114-819e-faa2ad5f213f
📥 Commits

Reviewing files that changed from the base of the PR and between 8259b1a and b5c8635.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (16)
  • config/patches/@[email protected]
  • config/patches/@[email protected]
  • config/patches/xterm-src/@[email protected]
  • config/patches/xterm-src/@[email protected]
  • config/scripts/xterm-image-kitty-admission.test.mjs
  • config/scripts/xterm-image-kitty-coordinate-boundaries.test.mjs
  • config/scripts/xterm-image-kitty-glyph-visibility.test.mjs
  • config/scripts/xterm-image-kitty-placeholder-contract.test.mjs
  • config/scripts/xterm-image-kitty-placeholder-lifecycle.test.mjs
  • config/scripts/xterm-image-kitty-retransmit.test.mjs
  • config/scripts/xterm-kitty-placeholder-test-terminal.mjs
  • config/scripts/xterm-underline-color-contract.test.mjs
  • tests/e2e/helpers/terminal-inline-image-proof.ts
  • tests/e2e/terminal-inline-images-paired-runtime.spec.ts
  • tests/e2e/terminal-inline-images-windows.spec.ts
  • tests/e2e/terminal-kitty-placeholders.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@nwparker
nwparker marked this pull request as draft October 12, 2026 09:23
@nwparker
nwparker changed the base branch from main to codex/xterm-beta-payload-base October 12, 2026 09:23
@nwparker
nwparker marked this pull request as ready for review October 12, 2026 09:25
@nwparker
nwparker force-pushed the codex/inline-image-placeholders branch from 2a86024 to d19d15c Compare October 12, 2026 23:27
@nwparker
nwparker changed the base branch from codex/xterm-beta-payload-base to main October 12, 2026 23:27
@nwparker
nwparker marked this pull request as draft October 14, 2026 04:50
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.

2 participants