feat: add file upload and preview support (images and documents)
- Support image (JPEG/PNG/GIF/WebP, max 5MB) and document uploads - Images sent as multimodal content blocks to Claude SDK - Documents saved to temp dir for Claude's Read tool - Emerald capsule badges in input for attached files - Drag-and-drop, paste, and file picker support via PromptInput - Chat display: image thumbnails with lightbox, file cards - Lightbox uses Radix Dialog with prev/next navigation - File metadata embedded in message content as HTML comments - Compatible with existing slash command badge system Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
4ac1f8cea3
commit
164f730da1
11 files changed
+562
-22
No files matched your search
@@ -392,6 +392,30 @@ export const SETTING_KEYS = {
|
||||
MAX_THINKING_TOKENS: 'max_thinking_tokens',
|
||||
} as const;
|
||||
|
||||
// ==========================================
|
||||
// File Attachment Types
|
||||
// ==========================================
|
||||
|
||||
export interface FileAttachment {
|
||||
id: string;
|
||||
name: string;
|
||||
type: string; // MIME type
|
||||
size: number;
|
||||
data: string; // base64 encoded content
|
||||
}
|
||||
|
||||
// Check if a MIME type is an image
|
||||
export function isImageFile(type: string): boolean {
|
||||
return type.startsWith('image/');
|
||||
}
|
||||
|
||||
// Format bytes into human-readable size
|
||||
export function formatFileSize(bytes: number): string {
|
||||
if (bytes < 1024) return bytes + ' B';
|
||||
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB';
|
||||
return (bytes / (1024 * 1024)).toFixed(1) + ' MB';
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// Claude Client Types
|
||||
// ==========================================
|
||||
@@ -406,4 +430,5 @@ export interface ClaudeStreamOptions {
|
||||
mcpServers?: Record<string, MCPServerConfig>;
|
||||
abortController?: AbortController;
|
||||
permissionMode?: string;
|
||||
files?: FileAttachment[];
|
||||
}
|
||||
Reference in new issue
Block a user