fix: wire up file picker change handler for attach button#558
Merged
Conversation
Owner
Author
PR #558 Multi-Model Code Review (Re-Review v3 — Final)CI status: Previous Findings
Current Review (3/3 reviewers completed)All reviewers confirmed the core flow is correct:
Informational (single-reviewer, not actionable)
Test Coverage
Recommendation✅ Approve — all findings addressed. Verified end-to-end on both platforms. Ready to merge. |
The attach button clicked a hidden <input type="file"> via JS but
nobody was listening for the change event, so selected images were
silently dropped. This was especially visible on mobile where
paste/drag-drop (which have their own handlers) aren't available.
Add a global delegated change listener for file inputs matching the
'file-{sessionName}' pattern that reads selected images and calls
JsImagePasted — the same path used by paste and drag-drop.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The change handler was accidentally inserted inside the opening line of the dragover listener, creating an unclosed function that broke all JS on the page. Move the change handler to its own top-level addEventListener call between the paste and dragover handlers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Images selected on mobile (Remote mode) were silently dropped because the bridge protocol had no image support. The mobile client encodes images, sends them, but SendPromptAsync's remote path never forwarded them to the server. Changes: - Add ImageAttachment model and ImageAttachments field to SendMessagePayload - WsBridgeClient.SendMessageAsync accepts and forwards image attachments - CopilotService.SendPromptAsync (remote path) encodes images as base64 - WsBridgeServer decodes base64 images to temp files and passes them through DispatchBridgePromptAsync to SendPromptAsync with imagePaths Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
WsBridgeServer rejected messages with empty/whitespace text, silently dropping image-only sends from mobile. Allow messages through when ImageAttachments are present even if the text is empty. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
664a9c5 to
a7ed6ef
Compare
The WsBridge server had a 256KB message size limit, causing it to close the WebSocket connection when receiving base64-encoded images (a 5MB photo becomes ~7MB as base64). Increase to 16MB. Also remove debug tracing from the image encoding path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
FilePicker on iOS opens the Files app (document picker showing 'Recents'), which is confusing for image attachment. MediaPicker opens the native photo library picker instead — the expected UX on both iOS and Android. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Delete decoded image temp files in a finally block after DispatchBridgePromptAsync completes, preventing accumulation in the PolyPilot-images temp directory. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Problem
The attach image button (📎) does nothing on mobile. Tapping it opens the native file picker, but selecting an image has no effect — the image is silently dropped.
Root Cause
The button clicks a hidden
<input type="file">viaclickElement()JS interop, which correctly opens the native picker. But there is nochangeevent listener on the file input, so when the user selects a file, nothing reads it.On desktop, image attachment works via paste and drag-drop, which have their own global JS listeners. The file picker button has never actually worked on any platform — it's just more noticeable on mobile where paste/drag-drop aren't available.
Fix
Add a global delegated
changeevent listener for<input type="file">elements matching thefile-{sessionName}pattern. When files are selected:FileReaderJsImagePasted(the same Blazor interop used by paste and drag-drop)This follows the exact same pattern as the existing paste and drop handlers.
Testing