fix(plugins): return bare Kitty delete sequences from legacy pi-tui shim

Upstream Pi's deleteKittyImage/deleteAllKittyImages return unwrapped control
sequences; legacy callers such as pi-sprite wrap tmux passthrough themselves.
Aliasing OMP's auto-wrapping encodeKittyDeleteImage (and hand-wrapping
deleteAllKittyImages) double-wrapped under tmux, so the outer terminal dropped
the delete command. Match the upstream bare-sequence contract and pin it in
the regression test.
This commit is contained in:
omp-eval
2026-07-26 15:31:38 +02:00
committed by can1357
parent 5905ec0430
commit c8b37c8d2e
2 changed files with 20 additions and 11 deletions
@@ -6,13 +6,10 @@
* exposes the equivalent, broader `decodePrintableKey` helper. Keep the legacy
* name available without reintroducing it into the canonical package surface.
*/
import { ImageProtocol, isInsideTmux, TERMINAL, wrapTmuxPassthrough } from "@oh-my-pi/pi-tui";
import { ImageProtocol, TERMINAL } from "@oh-my-pi/pi-tui";
export * from "@oh-my-pi/pi-tui";
export {
decodePrintableKey as decodeKittyPrintable,
encodeKittyDeleteImage as deleteKittyImage,
} from "@oh-my-pi/pi-tui";
export { decodePrintableKey as decodeKittyPrintable } from "@oh-my-pi/pi-tui";
/** Report canonical terminal capabilities through the legacy Pi TUI shape. */
export function getCapabilities(): {
@@ -29,8 +26,18 @@ export function getCapabilities(): {
return { images, trueColor: TERMINAL.trueColor, hyperlinks: TERMINAL.hyperlinks };
}
/** Delete every Kitty graphics image using the legacy Pi TUI control sequence. */
export function deleteAllKittyImages(): string {
const sequence = "\x1b_Ga=d,d=A,q=2\x1b\\";
return isInsideTmux() ? wrapTmuxPassthrough(sequence) : sequence;
/**
* Delete one Kitty graphics image by id, matching the legacy Pi TUI helper.
*
* Returns the bare control sequence exactly like upstream Pi: legacy callers
* (e.g. pi-sprite) apply their own tmux passthrough wrapping, so wrapping here
* would double-wrap under tmux and the outer terminal would drop the command.
*/
export function deleteKittyImage(imageId: number): string {
return `\x1b_Ga=d,d=I,i=${imageId},q=2\x1b\\`;
}
/** Delete every Kitty graphics image using the legacy Pi TUI bare sequence. */
export function deleteAllKittyImages(): string {
return "\x1b_Ga=d,d=A,q=2\x1b\\";
}
@@ -280,8 +280,10 @@ describe("legacy pi package root remaps (issue #1474)", () => {
deleteAll: string;
capabilities: { images: "kitty" | "iterm2" | null; trueColor: boolean; hyperlinks: boolean };
};
expect(loaded.deleteOne).toContain("a=d,d=I,i=42,q=2");
expect(loaded.deleteAll).toContain("a=d,d=A,q=2");
// Bare sequences, exactly like upstream Pi: legacy callers (pi-sprite)
// apply their own tmux passthrough wrapping.
expect(loaded.deleteOne).toBe("\x1b_Ga=d,d=I,i=42,q=2\x1b\\");
expect(loaded.deleteAll).toBe("\x1b_Ga=d,d=A,q=2\x1b\\");
expect(["kitty", "iterm2", null]).toContain(loaded.capabilities.images);
expect(typeof loaded.capabilities.trueColor).toBe("boolean");
expect(typeof loaded.capabilities.hyperlinks).toBe("boolean");