feat: Add clipboard image paste support and fix image previews in CC sessions
- Add save_clipboard_image and cleanup_temp_images commands in Rust backend - Implement paste event handler in FloatingPromptInput to capture pasted images - Save pasted images to .claude_temp/session_id/ directory - Add automatic cleanup of temp images when session ends - Fix image preview display for file paths containing spaces - Update regex patterns to handle both quoted (@"path with spaces") and unquoted (@path) mentions - Automatically wrap paths with spaces in quotes when inserting - Update remove handler to properly handle both quoted and unquoted paths Users can now paste images directly from clipboard (e.g., screenshots) and see proper previews for all image files regardless of filename format.
This commit is contained in:
@@ -20,6 +20,7 @@ import { api, type Session } from "@/lib/api";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { open } from "@tauri-apps/plugin-dialog";
|
||||
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { StreamMessage } from "./StreamMessage";
|
||||
import { FloatingPromptInput, type FloatingPromptInputRef } from "./FloatingPromptInput";
|
||||
import { ErrorBoundary } from "./ErrorBoundary";
|
||||
@@ -827,9 +828,19 @@ export const ClaudeCodeSession: React.FC<ClaudeCodeSessionProps> = ({
|
||||
api.clearCheckpointManager(effectiveSession.id).catch(err => {
|
||||
console.error("Failed to clear checkpoint manager:", err);
|
||||
});
|
||||
|
||||
// Clean up temporary images
|
||||
if (projectPath) {
|
||||
invoke('cleanup_temp_images', {
|
||||
projectPath,
|
||||
sessionId: effectiveSession.id
|
||||
}).catch((err: any) => {
|
||||
console.error("Failed to cleanup temp images:", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}, [effectiveSession]);
|
||||
}, [effectiveSession, projectPath]);
|
||||
|
||||
const messagesList = (
|
||||
<div
|
||||
|
Reference in New Issue
Block a user