From 6548f4bbdf6f5f0d3f6ab0aea769947c3b42adb5 Mon Sep 17 00:00:00 2001 From: RECTOR Date: Sat, 11 Jul 2026 12:44:51 +0700 Subject: [PATCH] fix(v0.3.5): compose preview skips slash commands + marker-path guard Two fixes for the compose-time preview: 1. Skip compose-time preview when editor text starts with / (slash command). Prevents the preview widget from showing while typing commands like /vision preview, which could interfere with the command's own panel. 2. /vision preview now clears the compose widget before opening + gives a helpful error if the user passes a marker ([Image-#N]) instead of a file path: 'pass a file path, not a marker. Example: /vision preview /tmp/screenshot.png' --- extensions/paste.ts | 8 ++++++++ extensions/vision.ts | 9 +++++++++ package.json | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/extensions/paste.ts b/extensions/paste.ts index a3e775d..f06704a 100644 --- a/extensions/paste.ts +++ b/extensions/paste.ts @@ -224,6 +224,14 @@ async function updateComposePreview(ctx: ExtensionContext): Promise { if (ctx.mode !== "tui") return; // widget is TUI-only const editorText = ctx.ui.getEditorText(); + // Don't show compose preview for slash commands — they have their own UI + if (editorText.trim().startsWith("/")) { + if (lastPreviewTokens) { + ctx.ui.setWidget("vision-compose-preview", undefined); + lastPreviewTokens = ""; + } + return; + } const tokens = findImagePathTokens(editorText); const tokensKey = tokens.join("\0"); diff --git a/extensions/vision.ts b/extensions/vision.ts index d08a3d6..798665a 100644 --- a/extensions/vision.ts +++ b/extensions/vision.ts @@ -738,6 +738,15 @@ export default function visionExtension(pi: ExtensionAPI): void { ctx.ui.notify("Usage: /vision preview ", "warning"); return; } + // Clear compose preview widget if active (prevent interference) + if (typeof ctx.ui.setWidget === "function") { + ctx.ui.setWidget("vision-compose-preview", undefined); + } + // Helpful error if the user passed a marker instead of a path + if (path.includes("[Image-#") || path.startsWith("`")) { + ctx.ui.notify("Vision preview: pass a file path, not a marker. Example: /vision preview /tmp/screenshot.png", "warning"); + return; + } if (ctx.mode !== "tui") { // Non-TUI: notify metadata as text const loaded = await loadImage(path, { compress: false, maxDimension: 1568, jpegQuality: 85, cwd: ctx.cwd }); diff --git a/package.json b/package.json index 3020bf3..0a03ca7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getpipher/vision", - "version": "0.3.4", + "version": "0.3.5", "description": "Capability-aware vision + paste extension for the pi coding agent. Delegates image analysis to a vision model only when the active primary model is text-only; passes images through natively for multimodal models (zero delegation).", "keywords": [ "pi-package",