pi-orca-images 0.2.2 → 0.2.3
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/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/src/labels.ts +11 -6
- package/src/shim.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.3
|
|
4
|
+
|
|
5
|
+
- Fix: Pi crashed with "This extension ctx is stale after session replacement or reload" when an `[Image N]` label was in the prompt after `/resume`, `/new`, `/fork` or `/reload`. Pi hands extensions a Proxy over the TUI that ignores `delete`, so the old session's render hook was never removed and kept styling labels with its stale ctx.
|
|
6
|
+
|
|
3
7
|
## 0.2.2
|
|
4
8
|
|
|
5
9
|
- Gallery: preview image (`pi.image`) and shorter description for the pi.dev package page.
|
package/package.json
CHANGED
package/src/labels.ts
CHANGED
|
@@ -189,18 +189,24 @@ export interface EditorWatcher {
|
|
|
189
189
|
/**
|
|
190
190
|
* Label every editor in the TUI tree, checked before each render. Pi and extensions can swap the
|
|
191
191
|
* editor at any time (custom editors, settings changes), so a one-time lookup is not enough.
|
|
192
|
+
*
|
|
193
|
+
* Pi hands extensions a Proxy over the TUI whose own-property checks and deletes never reach the
|
|
194
|
+
* TUI, so uninstall restores by assignment and the wrapper turns inert even if something else
|
|
195
|
+
* still holds it: a leftover wrapper would relabel editors with a stale session's style.
|
|
192
196
|
*/
|
|
193
197
|
export function watchEditors(
|
|
194
198
|
tui: { doRender?: (...args: unknown[]) => unknown },
|
|
195
199
|
options: LabelOptions,
|
|
196
200
|
): EditorWatcher {
|
|
197
201
|
const installed = new Map<LabelTarget, ImageLabels>();
|
|
198
|
-
const hadOwn = Object.hasOwn(tui, "doRender");
|
|
199
202
|
const originalRender = tui.doRender;
|
|
203
|
+
let active = true;
|
|
200
204
|
if (originalRender) {
|
|
201
205
|
tui.doRender = function (this: unknown, ...args: unknown[]) {
|
|
202
|
-
|
|
203
|
-
|
|
206
|
+
if (active) {
|
|
207
|
+
for (const editor of findEditors(tui)) {
|
|
208
|
+
if (!installed.has(editor)) installed.set(editor, installImageLabels(editor, options));
|
|
209
|
+
}
|
|
204
210
|
}
|
|
205
211
|
return originalRender.apply(this, args);
|
|
206
212
|
};
|
|
@@ -210,11 +216,10 @@ export function watchEditors(
|
|
|
210
216
|
return installed.size;
|
|
211
217
|
},
|
|
212
218
|
uninstall() {
|
|
219
|
+
active = false;
|
|
213
220
|
for (const labels of installed.values()) labels.uninstall();
|
|
214
221
|
installed.clear();
|
|
215
|
-
if (
|
|
216
|
-
if (hadOwn) tui.doRender = originalRender;
|
|
217
|
-
else delete tui.doRender;
|
|
222
|
+
if (originalRender) tui.doRender = originalRender;
|
|
218
223
|
},
|
|
219
224
|
};
|
|
220
225
|
}
|
package/src/shim.ts
CHANGED
|
@@ -85,7 +85,8 @@ export function installShim(tui: ShimTarget, options: ShimOptions = {}): Shim {
|
|
|
85
85
|
cancel();
|
|
86
86
|
if (shim.renderPatched) tui.doRender = originalRender;
|
|
87
87
|
if (shim.focusPatched) tui.handleViewportInput = originalInput;
|
|
88
|
-
delete
|
|
88
|
+
// Assign, not delete: a delete through Pi's TUI Proxy never reaches the TUI.
|
|
89
|
+
host[SHIM] = undefined;
|
|
89
90
|
},
|
|
90
91
|
};
|
|
91
92
|
|