Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

Paste, drop or attach an image in any comment box to upload it #160

Mergedsyntaqx merged paste-images into main
syntaqxopened this pull request

Paste, drop or choose an image in any comment box and it uploads, as on GitHub.

Closes #159

How it works

  • Where it's added: once, in MentionTextarea (components/attach-images.tsx). An <AttachImages to=…> wrapper says where a page's images are kept.
  • Where it applies:
    • pull request comments, reviews and inline line comments;
    • editing a comment or the description;
    • the "Mark ready" summary;
    • commit comments;
    • work item comments;
    • the new pull request and new work item pages.
  • While uploading: ![Uploading name…]() goes in at the caret, and only that placeholder is swapped for the image's Markdown when it's done. Typing around it is kept, and sending waits until every upload has finished.
  • On failure: the placeholder is removed and a sentence under the box says why. What you typed is never touched.
  • Text pastes stay text: a paste uploads only when the clipboard holds image files and no plain text, so spreadsheet and Word pastes come in as text.
  • Upload path: the new POST /-/attachments resource route (same origin, signed in) calls the work service's existing upload_attachment, the path g1t attach / --attach already uses. That service checks who may upload, the type from the bytes, and the 10 MB limit.
  • A new work item with no repository: there's nowhere to keep images until the item exists, so they're sent with the form and attached to the item once it's made, as g1t work new --attach does. In that case only, an upload that fails on the server is quietly left out, because the page has already moved on.

Tests

  • npx tsc -b --force in apps/web: clean.
  • npm test in apps/web: passing, including 11 new tests for the placeholder and clipboard logic (lib/attachments.ts).
  • I looked at the composer in light and dark, at desktop and phone widths, rendered with a mocked upload (screenshot below). Real clipboard and drag behaviour still wants a try in a browser on the deployed site.

desktop4.png

syntaqxmerged this·

All checks have passed

2 passed · on 876aa37

Workflows

CI / pull_request — CI passedDetails
Dependency review — No dependency changesDetails

Merged and closed: the branch can be deleted safely

Everything on it is in its base now.

Sign in to comment.