@xynogen/pix-ask 0.2.15 → 0.2.16

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/chip-editor.ts +15 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-ask",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "description": "Pi tool — structured questionnaire UI (ask_user)",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -184,10 +184,20 @@ function chip(color: string, glyph: string, label: string, meta: string): string
184
184
  export class ChipEditor extends Editor {
185
185
  private readonly imageIds = new Set<number>();
186
186
  private readonly keybindings?: KeybindingsManager;
187
+ // Injectable so tests can force a deterministic clipboard state (an empty
188
+ // clipboard, a known image) instead of depending on the real system
189
+ // clipboard, which leaks across concurrent tests. Defaults to the real reader.
190
+ private readonly readClipboardImage: () => string | null;
187
191
 
188
- constructor(tui: TUI, theme: EditorTheme, keybindings?: KeybindingsManager) {
192
+ constructor(
193
+ tui: TUI,
194
+ theme: EditorTheme,
195
+ keybindings?: KeybindingsManager,
196
+ readClipboardImage: () => string | null = readClipboardImageToFile,
197
+ ) {
189
198
  super(tui, theme);
190
199
  this.keybindings = keybindings;
200
+ this.readClipboardImage = readClipboardImage;
191
201
  this.patchHandlePaste();
192
202
  this.patchExpandPasteMarkers();
193
203
  this.patchSubmitValue();
@@ -248,8 +258,11 @@ export class ChipEditor extends Editor {
248
258
  * base Editor handles the key as ordinary input / text paste.
249
259
  */
250
260
  override handleInput(data: string): void {
261
+ // "app.clipboard.pasteImage" is type-checked via pi-coding-agent's
262
+ // declaration merge onto pi-tui's Keybindings interface. If pix-ask ever
263
+ // drops the pi-coding-agent dep, this key silently becomes a type error.
251
264
  if (this.keybindings?.matches(data, "app.clipboard.pasteImage")) {
252
- const filePath = readClipboardImageToFile();
265
+ const filePath = this.readClipboardImage();
253
266
  if (filePath) {
254
267
  this.insertTextAtCursor(filePath);
255
268
  return;