Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/renderer/components/cowork/CoworkPromptInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@
useEffect(() => {
setValue(draftPrompt);
setCaretIndex(draftPrompt.length);
}, [draftKey]); // intentionally omit draftPrompt to only trigger on session switch

Check warning on line 332 in src/renderer/components/cowork/CoworkPromptInput.tsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'draftPrompt'. Either include it or remove the dependency array

const slashCommands = useMemo(() => getSlashCommandsForEngine(agentEngine), [agentEngine]);
const slashTrigger = useMemo(() => getSlashTrigger(value, caretIndex), [value, caretIndex]);
Expand Down Expand Up @@ -572,12 +572,13 @@

const addImageAttachmentFromDataUrl = useCallback((name: string, dataUrl: string) => {
// Use the dataUrl as the unique key (no file path for inline images)
const pseudoPath = `inline:${name}:${Date.now()}`;
const displayName = name.trim() || 'pasted-image.png';
const pseudoPath = `inline:${displayName}:${Date.now()}`;
dispatch(addDraftAttachment({
draftKey,
attachment: {
path: pseudoPath,
name,
name: displayName,
isImage: true,
dataUrl,
},
Expand Down Expand Up @@ -677,10 +678,15 @@
// Fallback: add as regular file attachment
addAttachment(nativePath);
} else {
// No native path (clipboard/drag from browser) - read via FileReader
// No native path (clipboard/drag from browser): stage a real file so agent tools can read it.
try {
const dataUrl = await fileToDataUrl(file);
addImageAttachmentFromDataUrl(file.name, dataUrl);
const stagedPath = await saveInlineFile(file);
if (stagedPath) {
addAttachment(stagedPath, { isImage: true, dataUrl });
} else {
addImageAttachmentFromDataUrl(file.name, dataUrl);
}
} catch (error) {
console.error('Failed to read image from clipboard:', error);
const stagedPath = await saveInlineFile(file);
Expand Down
Loading