Skip to content

fix(paste): preview absolute image paths instead of treating them as slash commands - #29

Open
Andrez421 wants to merge 1 commit into
getpipher:mainfrom
Andrez421:fix/compose-preview-absolute-paths
Open

Andrez421 wants to merge 1 commit into
getpipher:mainfrom
Andrez421:fix/compose-preview-absolute-paths

Conversation

@Andrez421

Copy link
Copy Markdown

Problem

The compose-time preview never appears for an image path that starts with /, which is exactly what pi inserts when you paste a screenshot on Linux/macOS (Ctrl+V → /tmp/pi-clipboard-<uuid>.png).

updateComposePreview() skips any editor text starting with / to leave slash commands to their own UI. Every POSIX absolute path also starts with /, so the real paste case never reaches the preview. The submit-time attachment is unaffected because the input hook has no such guard, which is why images still reach the model and only the preview is missing.

Failure is silent: the terminal-input listener calls updateComposePreview(ctx).catch(() => {}).

Fix

Only treat the text as a slash command when it contains no image path token:

-  if (editorText.trim().startsWith("/")) {
+  if (editorText.trim().startsWith("/") && findImagePathTokens(editorText).length === 0) {

Tests

  • T71 (new): editor text that is exactly an absolute image path renders the preview. Verified RED on the unfixed code (AssertionError: absolute path must render the compose preview) and GREEN after the change.
  • T72 (new): a real slash command (/vision) without an image path is still skipped, so the guard keeps its original purpose.
  • Full suite: 356 passed, 0 failed (tsx --test, all tests/*.test.ts + test/delegator.test.mts).
  • tsc --noEmit: clean.

Reproduced in pi 1.3.0 on Linux/Wayland with Ghostty (Kitty graphics). The same patch applied to the installed 0.5.3 makes the absolute path render pi-clipboard-….png | 679x616 | image/png | 163.9KB | kitty above the editor.

Fixes #28

…slash commands

pi's clipboard paste inserts an absolute temp path on Linux and macOS, and the
compose-preview slash-command guard skipped every editor text starting with "/".
That made the preview unreachable for the real paste flow on POSIX systems.

Only treat the text as a slash command when it contains no image path token.

Adds T71 (absolute path still previews) and T72 (a real slash command stays
skipped). Fixes getpipher#28.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compose preview never appears for absolute image paths (Linux/macOS)

1 participant