fix(components): prefer plain text over synthetic clipboard images (#262) - #422
Open
hasak21 wants to merge 1 commit into
Open
fix(components): prefer plain text over synthetic clipboard images (#262)#422hasak21 wants to merge 1 commit into
hasak21 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue
Closes #262
Problem / pressure
When copying text from Microsoft Word (and certain other rich-text editors on macOS/Windows), Word places multiple MIME representations on the clipboard simultaneously:
text/plain,text/html,text/rtf, and a rasterized snapshot image (image/png).In Lody's composer inputs (
SessionChatInputArea,WorkspaceChatLanding,useChatLandingImageDraft,TaskBodyEditorFallback, andTaskThread), paste handlers inspectedevent.clipboardData.itemsfor file entries. Because the rasterized PNG file was present initems, Lody immediately intercepted the paste viaevent.preventDefault()and treated the clipboard content as an image file upload. This prevented the copied plain text from being inserted as editable text in the textarea.Summary
SessionChatInputArea,WorkspaceChatLanding,useChatLandingImageDraft,TaskBodyEditorFallback, andTaskThread, check whether non-emptytext/plainis present on the clipboard.text.length > 0, avoid intercepting the paste as a file attachment, allowing normal text insertion into the textarea (or draft capture for texts > 1024 characters).packages/components/tests/session-chat-input-paste.test.tsx.Before / after
Test plan
pnpm --filter @lody/components test tests/session-chat-input-paste.test.tsx(all 4 tests passed).pnpm --filter @lody/components test paste(all 23 tests across paste suites passed).pnpm check:quick(oxlint,lint:i18n,check:code-collab-imports,check:platform-boundaries,check:public-boundaryall passed with 0 errors).packages/components/src/...andpackages/components/tests/...).Context handoff
Instructions for reviewing agents
session-chat-input-area.tsx,chat-landing.tsx,use-chat-landing-image-draft.ts,task-body-editor-fallback.tsx, andtask-thread.tsx.text.length > 0before checkingevent.clipboardData.itemsfor file entries correctly prioritizes user-intended text without regressing pure image/screenshot pastes.text/plain+image/png) to verify precedence.Authoring context