Skip to content

Web mode: attach images over the saveImage bridge instead of hiding the button - #227

Merged
currentbits merged 5 commits into
mainfrom
coder/web-mode-silently-drops-image-attachment-084f8b
Aug 17, 2026
Merged

currentbits merged 5 commits into
mainfrom
coder/web-mode-silently-drops-image-attachment-084f8b

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Fixes #142.

Why

In web mode (the app served over the web bridge to a phone or browser, isWebMode() true because window.coder is absent), image attachments were impossible: src/App.tsx passed undefined for onPickAttachments/onDropAttachmentFiles, which makes Composer hide the attach button and ignore drops. Nothing told the user this was environment-related rather than a bug, and the README advertises web mode for phone check-ins.

A disabled button with a tooltip was the other option, but the plumbing for real uploads already existed and already worked in web mode: attachments:saveImage is a plain JSON wire call, which is why pasting an image already worked there. Wiring pick and drop to that same call is a smaller change than explaining a limitation that does not need to exist.

What changed

  • src/useCoder.ts
    • pickAttachments: in web mode, open a transient <input type="file" multiple accept="image/*"> and upload each pick via attachments.saveImage. It deliberately does not call api.attachments.pick() there, which would pop a native dialog on the host machine. Native mode is unchanged.
    • dropAttachmentFiles: the early return [] when webUtils.droppedFilePath is unavailable (web and dev bridges) becomes the fallback to the same upload path. The native absolute-path route via attachments.fromPaths is untouched.
    • Both share one FileReader -> data URL -> saveImage helper.
  • src/App.tsx: both props are now always passed.
  • src/components/Composer.tsx: doc comments only, the old ones said absence meant web mode.

No renderer-side size or mime guard was added: electron/attachments.js saveImage() already validates the data URL and caps at 20MB, returning null, and the helper filters nulls. One guard, at the place every caller routes through.

Limitation: web can attach images only, not folders, because <input type=file> cannot pick a directory. The desktop picker still does both. Marked with a ponytail: comment.

Verification

  • New test in test/webDegrade.test.tsx: with window.coder deleted and a thread selected, dropping an image File on the composer must call attachments.saveImage with a data: URL for the right thread and surface the returned attachment as a chip. test/support/fakeCoder.ts gained a one-line saveImage override so the fake can echo an attachment back.
  • npm run typecheck clean.
  • Full renderer suite: 724 passed, 0 failed.

Note: origin/main is behind local main, so this PR's diff also carries three earlier merges that were never pushed (electron process/shutdown consolidation, changelog site work). Only the src/ and test/ changes above belong to this thread.

  • PR created by the Claude Code agent

Willem added 5 commits August 17, 2026 11:08
… The changelog on the website is fucked everythign is squeeze
… Use grok workers you are orchestrating for this thread https
… Use grok workers to do this gh issue you are orchestrating h
Web pick/drop now read Files as data URLs and call attachments.saveImage
instead of hiding the attach button. Native pick/fromPaths are unchanged.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@currentbits
currentbits merged commit 7140d2e into main Aug 17, 2026
1 check failed
@currentbits
currentbits deleted the coder/web-mode-silently-drops-image-attachment-084f8b branch October 3, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web mode silently drops image attachments; the button just disappears

1 participant