From 5b95ccf830d74f7bd483b6c293a6f5b6ba5f81a0 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sun, 4 Jan 2026 18:12:55 +0100 Subject: [PATCH] Add consistent, configurable image placeholders (#442) * Add consistent, configurable image placeholders * Kill the placeholders --- packages/coding-agent/README.md | 1 - .../src/modes/interactive/interactive-mode.ts | 27 ++----------------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/packages/coding-agent/README.md b/packages/coding-agent/README.md index 6ac16480..1858f9d1 100644 --- a/packages/coding-agent/README.md +++ b/packages/coding-agent/README.md @@ -671,7 +671,6 @@ Global `~/.pi/agent/settings.json` stores persistent preferences: | `retry.baseDelayMs` | Base delay for exponential backoff | `2000` | | `terminal.showImages` | Render images inline (supported terminals) | `true` | | `images.autoResize` | Auto-resize images to 2000x2000 max for better model compatibility | `true` | - | `doubleEscapeAction` | Action for double-escape with empty editor: `tree` or `branch` | `tree` | | `hooks` | Additional hook file paths | `[]` | | `customTools` | Additional custom tool file paths | `[]` | diff --git a/packages/coding-agent/src/modes/interactive/interactive-mode.ts b/packages/coding-agent/src/modes/interactive/interactive-mode.ts index fff4267d..17638154 100644 --- a/packages/coding-agent/src/modes/interactive/interactive-mode.ts +++ b/packages/coding-agent/src/modes/interactive/interactive-mode.ts @@ -143,10 +143,6 @@ export class InteractiveMode { // Custom tools for custom rendering private customTools: Map; - // Clipboard image tracking: imageId -> temp file path - private clipboardImages = new Map(); - private clipboardImageCounter = 0; - // Convenience accessors private get agent() { return this.session.agent; @@ -847,35 +843,19 @@ export class InteractiveMode { } // Write to temp file - const imageId = ++this.clipboardImageCounter; const tmpDir = os.tmpdir(); const fileName = `pi-clipboard-${crypto.randomUUID()}.png`; const filePath = path.join(tmpDir, fileName); fs.writeFileSync(filePath, Buffer.from(imageData)); - // Store mapping and insert marker - this.clipboardImages.set(imageId, filePath); - this.editor.insertTextAtCursor(`[image #${imageId}]`); + // Insert file path directly + this.editor.insertTextAtCursor(filePath); this.ui.requestRender(); } catch { // Silently ignore clipboard errors (may not have permission, etc.) } } - /** - * Replace [image #N] markers with actual file paths and clear the image map. - */ - private replaceImageMarkers(text: string): string { - let result = text; - for (const [imageId, filePath] of this.clipboardImages) { - const marker = `[image #${imageId}]`; - result = result.replace(marker, filePath); - } - this.clipboardImages.clear(); - this.clipboardImageCounter = 0; - return result; - } - private setupEditorSubmitHandler(): void { this.editor.onSubmit = async (text: string) => { text = text.trim(); @@ -1003,9 +983,6 @@ export class InteractiveMode { } // If streaming, use prompt() with steer behavior - // Replace image markers with actual file paths - text = this.replaceImageMarkers(text); - // This handles hook commands (execute immediately), slash command expansion, and queueing if (this.session.isStreaming) { this.editor.addToHistory(text);