pi-better-openai 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +2 -2
- package/package.json +1 -1
- package/src/pets.ts +10 -1
package/index.ts
CHANGED
|
@@ -66,7 +66,7 @@ import {
|
|
|
66
66
|
listCodexPets,
|
|
67
67
|
nextAnimationFrameDelayMs,
|
|
68
68
|
PET_ANIMATION_ROWS,
|
|
69
|
-
|
|
69
|
+
deleteCodexPetKittyImage,
|
|
70
70
|
registerOpenAIPets,
|
|
71
71
|
renderCodexPetFrame,
|
|
72
72
|
resetCodexPetKittyCache,
|
|
@@ -467,7 +467,7 @@ export default function betterOpenAI(pi: ExtensionAPI): void {
|
|
|
467
467
|
function takePetKittyCleanupSequence(): string {
|
|
468
468
|
if (pendingPetKittyCleanupImageIds.size === 0) return "";
|
|
469
469
|
const sequence = Array.from(pendingPetKittyCleanupImageIds)
|
|
470
|
-
.map((imageId) =>
|
|
470
|
+
.map((imageId) => deleteCodexPetKittyImage(imageId))
|
|
471
471
|
.join("");
|
|
472
472
|
pendingPetKittyCleanupImageIds.clear();
|
|
473
473
|
return sequence;
|
package/package.json
CHANGED
package/src/pets.ts
CHANGED
|
@@ -415,6 +415,10 @@ export function deleteCodexPetKittyPlacement(imageId: number): string {
|
|
|
415
415
|
return `\x1b_Ga=d,d=i,i=${imageId},p=1,q=2\x1b\\`;
|
|
416
416
|
}
|
|
417
417
|
|
|
418
|
+
export function deleteCodexPetKittyImage(imageId: number): string {
|
|
419
|
+
return `\x1b_Ga=d,d=I,i=${imageId},q=2\x1b\\`;
|
|
420
|
+
}
|
|
421
|
+
|
|
418
422
|
function placeKittyImage(imageId: number, columns: number, rows: number): string {
|
|
419
423
|
return `\x1b_Ga=p,i=${imageId},p=1,c=${columns},r=${rows},q=2,C=1\x1b\\`;
|
|
420
424
|
}
|
|
@@ -467,7 +471,12 @@ function renderKittyPetFrame(
|
|
|
467
471
|
const upload = frame.kittyUploaded ? "" : encodeKittyRawRgba(frame, frameImageId);
|
|
468
472
|
frame.kittyUploaded = true;
|
|
469
473
|
previousKittyFrameByPlacement.set(options.imageId, frameImageId);
|
|
470
|
-
|
|
474
|
+
// Recent pi-tui versions automatically free Kitty image IDs they own on changed lines.
|
|
475
|
+
// Pet frames are managed here and intentionally reused across animation loops, so keep
|
|
476
|
+
// the first Kitty command pointed at a harmless footer-placement ID, not a frame ID.
|
|
477
|
+
const hostCleanupSentinel =
|
|
478
|
+
frameImageId !== options.imageId ? deleteCodexPetKittyPlacement(options.imageId) : "";
|
|
479
|
+
const sequence = `${hostCleanupSentinel}${deletePrevious}${deleteCurrent}${upload}${placeKittyImage(frameImageId, columns, rows)}`;
|
|
471
480
|
const lines: string[] = [];
|
|
472
481
|
for (let i = 0; i < rows - 1; i++) lines.push("");
|
|
473
482
|
const moveUp = rows > 1 ? `\x1b[${rows - 1}A` : "";
|