fix(tui): add iterm payload size for xterm.js image addon (#7612)

- include decoded byte count in iterm2 osc 1337 sequences
- satisfy @xterm/addon-image@0.9.0 image validation
- fixes #7465
This commit is contained in:
Ramiz Wachtler 2026-08-05 09:50:58 +02:00 • committed by GitHub
parent bb6a1cddc7
commit 2c233a5c04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View file

@ -250,7 +250,10 @@ export function encodeITerm2(
inline?: boolean;
} = {},
): string {
const params: string[] = [`inline=${options.inline !== false ? 1 : 0}`];
const params: string[] = [
`inline=${options.inline !== false ? 1 : 0}`,
`size=${Buffer.byteLength(base64Data, "base64")}`,
];
if (options.width !== undefined) params.push(`width=${options.width}`);
if (options.height !== undefined) params.push(`height=${options.height}`);

View file

@ -13,6 +13,7 @@ import {
deleteAllKittyPlacements,
deleteKittyImage,
detectCapabilities,
encodeITerm2,
encodeKitty,
getKittyImageMetadata,
getKittyImagePlacement,
@ -375,6 +376,13 @@ describe("detectCapabilities", () => {
});
});
describe("iTerm2 image encoding", () => {
it("includes the decoded payload size in OSC 1337 metadata", () => {
const sequence = encodeITerm2("AAAA", { width: 2, height: "auto" });
assert.strictEqual(sequence, "\x1b]1337;File=inline=1;size=3;width=2;height=auto:AAAA\x07");
});
});
describe("Kitty image cursor movement", () => {
it("can request no terminal-side cursor movement", () => {
const sequence = encodeKitty("AAAA", { columns: 2, rows: 2, moveCursor: false });