Attach images pasted into the composer, comments and chat #171
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "blindxfish/devplacepy:PasteImage"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pressing Ctrl+V with a screenshot on the clipboard now attaches it immediately, instead of requiring a trip through the file picker.
How
The clipboard reader lives in
dp-uploadbehind a new opt-inpasteboolean attribute. With it set, the component binds one paste listener on itsclosest("form")and routes the clipboard's image files through the samehandleFilespath as the picker and the drop target - so validation, size/count limits, the terms gate and the hiddenattachment_uidsfield are all shared, and no page controller grows a clipboard reader of its own. A paste carrying plain text is never swallowed.It is opt-in rather than a form-wide default because a form may hold several upload buttons -
projects.htmlhas cover + logo beside the attachment one - and a default would attach one pasted screenshot to all three at once. Marking exactly the button that owns the form's content attachments keeps that unambiguous.Where it lands
Set on
_attachment_form.html, so every form that includes it inherits the behaviour:Plus
_comment_form.html(comments on posts, projects, gists and news, and the inline boxes on feed cards and/gists) andmessages.html+ themode="embed"skeletonAppChatbuilds (direct messages).Deliberately not enabled on the project cover/logo pickers (the several-buttons-per-form case above) or the project file browser (
mode="direct", not inside a form).Server contract
Unchanged. A pasted image goes to
/uploads/uploadexactly as a picked file does and binds throughattachment_uids, so no route, schema, agent tool or docs endpoint changed.Tests
paste_image()helper intests/conftest.py(dispatches a realClipboardEventcarrying a PNGFile), plus one e2e test per surface: post composer, comment form, chat.Full suite run in the project's own Docker image: 3353 passed, 10 failed in 26m32s. All ten failures reproduce on a pristine
HEADcheckout in the same container and are environmental - nine intests/api/projects/workspace.pyfail withFileNotFoundError: 'docker'(the image only installs the docker CLI when built withINSTALL_DOCKER_CLI=true), andtests/e2e/game/farm.py::test_steal_takes_build_and_pays_thiefasserts against suite-wide accumulated farm coins. The e2e game tier passes clean on its own (36 passed).🤖 Generated with Claude Code