mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 03:04:28 +00:00
Add consistent, configurable image placeholders (#442)
* Add consistent, configurable image placeholders * Kill the placeholders
This commit is contained in:
parent
36e774282d
commit
5b95ccf830
2 changed files with 2 additions and 26 deletions
|
|
@ -671,7 +671,6 @@ Global `~/.pi/agent/settings.json` stores persistent preferences:
|
||||||
| `retry.baseDelayMs` | Base delay for exponential backoff | `2000` |
|
| `retry.baseDelayMs` | Base delay for exponential backoff | `2000` |
|
||||||
| `terminal.showImages` | Render images inline (supported terminals) | `true` |
|
| `terminal.showImages` | Render images inline (supported terminals) | `true` |
|
||||||
| `images.autoResize` | Auto-resize images to 2000x2000 max for better model compatibility | `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` |
|
| `doubleEscapeAction` | Action for double-escape with empty editor: `tree` or `branch` | `tree` |
|
||||||
| `hooks` | Additional hook file paths | `[]` |
|
| `hooks` | Additional hook file paths | `[]` |
|
||||||
| `customTools` | Additional custom tool file paths | `[]` |
|
| `customTools` | Additional custom tool file paths | `[]` |
|
||||||
|
|
|
||||||
|
|
@ -143,10 +143,6 @@ export class InteractiveMode {
|
||||||
// Custom tools for custom rendering
|
// Custom tools for custom rendering
|
||||||
private customTools: Map<string, LoadedCustomTool>;
|
private customTools: Map<string, LoadedCustomTool>;
|
||||||
|
|
||||||
// Clipboard image tracking: imageId -> temp file path
|
|
||||||
private clipboardImages = new Map<number, string>();
|
|
||||||
private clipboardImageCounter = 0;
|
|
||||||
|
|
||||||
// Convenience accessors
|
// Convenience accessors
|
||||||
private get agent() {
|
private get agent() {
|
||||||
return this.session.agent;
|
return this.session.agent;
|
||||||
|
|
@ -847,35 +843,19 @@ export class InteractiveMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write to temp file
|
// Write to temp file
|
||||||
const imageId = ++this.clipboardImageCounter;
|
|
||||||
const tmpDir = os.tmpdir();
|
const tmpDir = os.tmpdir();
|
||||||
const fileName = `pi-clipboard-${crypto.randomUUID()}.png`;
|
const fileName = `pi-clipboard-${crypto.randomUUID()}.png`;
|
||||||
const filePath = path.join(tmpDir, fileName);
|
const filePath = path.join(tmpDir, fileName);
|
||||||
fs.writeFileSync(filePath, Buffer.from(imageData));
|
fs.writeFileSync(filePath, Buffer.from(imageData));
|
||||||
|
|
||||||
// Store mapping and insert marker
|
// Insert file path directly
|
||||||
this.clipboardImages.set(imageId, filePath);
|
this.editor.insertTextAtCursor(filePath);
|
||||||
this.editor.insertTextAtCursor(`[image #${imageId}]`);
|
|
||||||
this.ui.requestRender();
|
this.ui.requestRender();
|
||||||
} catch {
|
} catch {
|
||||||
// Silently ignore clipboard errors (may not have permission, etc.)
|
// 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 {
|
private setupEditorSubmitHandler(): void {
|
||||||
this.editor.onSubmit = async (text: string) => {
|
this.editor.onSubmit = async (text: string) => {
|
||||||
text = text.trim();
|
text = text.trim();
|
||||||
|
|
@ -1003,9 +983,6 @@ export class InteractiveMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If streaming, use prompt() with steer behavior
|
// 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
|
// This handles hook commands (execute immediately), slash command expansion, and queueing
|
||||||
if (this.session.isStreaming) {
|
if (this.session.isStreaming) {
|
||||||
this.editor.addToHistory(text);
|
this.editor.addToHistory(text);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue