Public: anyone can read this; the crew can change it.

A link or an image shared to the forge from a phone becomes a tell that names it #16675

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A phone share can now carry a link, text and one picture. The picture is only half-reachable: a tell has nowhere to hold an image, so it waits for your next /talk message, and /talk does not show it yet. The gate, tsc and the share, home-feed, cookie-flags and both-doors tests pass.

Notes

opened this

A phone share can now carry a link, text and one picture. The picture is only half-reachable: a tell has nowhere to hold an image, so it waits for your next /talk message, and /talk does not show it yet.

The gate, tsc and the share, home-feed, cookie-flags and both-doors tests pass. The gate was red on the first push, so the pull briefly existed red; it is clean on the second push. I did not run the full suite. I did not start the app or try a share against a preview.

What changed

  • Manifest: the share target is now multipart/form-data and declares an image file field (PNG, JPEG, GIF or WebP). The existing link and text posts still work.
  • Validation: the picture is checked by its bytes, not by the name or type the phone sent. It must be a real image, not empty, and at most 5 MB.
  • Where it goes: a valid picture is kept as your own unsent attachment (owner-only, swept after an hour), reusing conversation_files.ts. The held form shows it.
  • Origin line: /tell/share now says where the share came from, for example "Shared from your phone: a link to example.com and an image (photo.png)." It is escaped and never sent.
  • Draft only: nothing files until you tap Send, and a picture alone counts as a share.
  • Refusals: a bad or oversized picture returns 422 with "The image was not kept: …" and the limit, and your text stays in the box. Signed out, the words are held through sign-in and the picture is not (it has no owner yet); the form says so. A signed-out post over 64 KiB gets a plain sentence instead of "payload too large".
  • Tests: test/share-target-image.test.ts covers the three shapes, a refused picture, the size limit, the signed-out case and the origin line. I changed the manifest expectation in home-feed.test.ts and share-target.test.ts, because the manifest really did change.
  • Docs: docs/features/share-receive.md is updated.
  • Reused: checkFile, imageType, cleanName, FILE_WORDS and storeFile from core/conversation_files.ts, plus the existing held-share stash, readForm and the same-origin check.
  • sw.ts: I did not touch it. It never intercepts POSTs, so the multipart share goes straight to the network.

Left out

  • A tell carries words only, and the issue and thought stores have no attachment slot. So the picture is kept for your next /talk message instead of riding with the tell, and /talk does not list pending files on load yet. That is the missing piece; the held form tells the person the picture is kept for Talk.
  • The terminal screen is unchanged: no tell is filed for a picture, so there is nothing new for it to list.

Try it

  • On the preview, POST multipart to /tell/share with a PNG and some text while signed in, then open /tell/share.
  • Or run bun test test/share-target-image.test.ts.
[
  {"go": "POST /tell/share (multipart: text=\"this one\", image=a real PNG), signed in", "look": "303 to /tell/share; the form shows the text, the thumbnail and \"Shared from your phone: some text and an image (name).\"", "expect": "no new tell until Send is tapped", "ask": "Is keeping the picture for Talk acceptable, or should a tell be able to carry it?"},
  {"go": "POST /tell/share with text and a non-image file named x.png", "look": "422 page: \"The image was not kept: only a PNG, JPEG, GIF or WebP picture up to 5 MB is taken. Your words were kept.\"", "expect": "the text is still in the box"}
]

Closes #16311

4 earlier comments
commented

A phone share can now carry a link, text and one picture. The picture is only half-reachable: a tell has nowhere to hold an image, so it waits for your next /talk message, and /talk does not show it yet.

The gate, tsc and the share, home-feed, cookie-flags and both-doors tests pass. The gate was red on the first push, so the pull briefly existed red; it is clean on the second push. I did not run the full suite. I did not start the app or try a share against a preview.

What changed

  • Manifest: the share target is now multipart/form-data and declares an image file field (PNG, JPEG, GIF or WebP). The existing link and text posts still work.
  • Validation: the picture is checked by its bytes, not by the name or type the phone sent. It must be a real image, not empty, and at most 5 MB.
  • Where it goes: a valid picture is kept as your own unsent attachment (owner-only, swept after an hour), reusing conversation_files.ts. The held form shows it.
  • Origin line: /tell/share now says where the share came from, for example "Shared from your phone: a link to example.com and an image (photo.png)." It is escaped and never sent.
  • Draft only: nothing files until you tap Send, and a picture alone counts as a share.
  • Refusals: a bad or oversized picture returns 422 with "The image was not kept: …" and the limit, and your text stays in the box. Signed out, the words are held through sign-in and the picture is not (it has no owner yet); the form says so. A signed-out post over 64 KiB gets a plain sentence instead of "payload too large".
  • Tests: test/share-target-image.test.ts covers the three shapes, a refused picture, the size limit, the signed-out case and the origin line. I changed the manifest expectation in home-feed.test.ts and share-target.test.ts, because the manifest really did change.
  • Docs: docs/features/share-receive.md is updated.
  • Reused: checkFile, imageType, cleanName, FILE_WORDS and storeFile from core/conversation_files.ts, plus the existing held-share stash, readForm and the same-origin check.
  • sw.ts: I did not touch it. It never intercepts POSTs, so the multipart share goes straight to the network.

Left out

  • A tell carries words only, and the issue and thought stores have no attachment slot. So the picture is kept for your next /talk message instead of riding with the tell, and /talk does not list pending files on load yet. That is the missing piece; the held form tells the person the picture is kept for Talk.
  • The terminal screen is unchanged: no tell is filed for a picture, so there is nothing new for it to list.

Try it

  • On the preview, POST multipart to /tell/share with a PNG and some text while signed in, then open /tell/share.
  • Or run bun test test/share-target-image.test.ts.
[
  {"go": "POST /tell/share (multipart: text=\"this one\", image=a real PNG), signed in", "look": "303 to /tell/share; the form shows the text, the thumbnail and \"Shared from your phone: some text and an image (name).\"", "expect": "no new tell until Send is tapped", "ask": "Is keeping the picture for Talk acceptable, or should a tell be able to carry it?"},
  {"go": "POST /tell/share with text and a non-image file named x.png", "look": "422 page: \"The image was not kept: only a PNG, JPEG, GIF or WebP picture up to 5 MB is taken. Your words were kept.\"", "expect": "the text is still in the box"}
]
commented

This push fixes two of the three failures; the third I did not touch. The two suites that failed here (test/unused-exports.test.ts and test/img-size.test.ts) pass now. The tests with "share" in their names, 180 tests in all, and tsc and design-lint are clean too.

  • Dead export: takeShare in src/web/studio/share_receive.ts had no callers once the page moved to takeHeld, so I removed it.
  • Image size: the held-share <img> declared only width="160", which the size check rejects. It now declares height="160" as well, so the page doesn't shift when the picture loads.
  • Not changed: "two processes on one data directory … the crew is queued on each issue once" touches nothing in this pull. I didn't run or change it, so I don't know whether it is flaky or something this pull causes. If it fails again on this push, it needs a look.
  • Possible distortion: the 160×160 box is square, and no CSS rule covers share-image. A non-square picture may look stretched until a rule for share-image is added.
commented

A link, some text or one picture shared from a phone now opens a held, prefilled "Tell the crew" form, and the picture can actually be sent from Talk. Nothing is sent until the person taps Send. The 1,050 tests across the 106 files whose names mention talk, conversation, share, unused exports or image size pass, and tsc, the gate and design-lint are clean. I did not run the full suite; the forge's check does that on push.

Review points

  1. Picture reaches Talk. Talk's page now shows the person's unsent files (at most four) as chips. The client adopts them as attachments, so the next message carries the picture. This is pendingOf in src/core/conversation_files.ts, wired through src/web/pages/talk.ts and talk_client.ts. A test checks that the shared picture shows up as a chip. The held form now says "It waits in Talk, attached to your next message there." Its old second explanation is gone.
  2. Refusal paths tested. A 5 MB+ picture posted to /tell/share gets a 422 naming the limit, keeps the words and stores nothing. A signed-out post over 64 KiB gets a 413 with "too big to take before you sign in".
  3. No more stretched photos. .share-image now has a CSS rule with object-fit: contain, using tokens. It is documented in docs/design/areas/feed.md.
  4. heldShares — not reverted, I disagree. I put back the one-line form on purpose. The gate (scripts/gate.ts) reports the original get-or-create block as a twin of keptFor in growth_panel.ts and fails. A comment now says why.
  5. Terminal. docs/features/share-receive.md now says sharing is phone-only by nature, since a share sheet doesn't exist over ssh. I did not add a screen.

Left out

  • Talk shows every unsent file the person has, not only the shared one. This includes files from a turn that went unanswered.
  • Unsent files are still swept after an hour.

To try it: sign in, POST a multipart form with an image to /tell/share, follow the redirect to the held form, then open /talk. The picture is there as a chip.

commented

Fix for the failed check: /talk now looks up the held share picture only when the request carries ?shared=1. That brings it back to 60 SQL statements, inside the page budget.

The earlier version ran a query on every /talk load, and test/pages-budget.test.ts counted 61 against a budget of 60. The share receive page's "waits in Talk" link now points at /talk?shared=1, so the picture still shows as an unsent attachment when someone arrives from a share. A plain /talk no longer shows it.

Checks run here: tsc is clean and gate.ts and design-lint pass. pages-budget, share-target-image and share-target all pass (34 tests). I did not run the full suite.

What changed: one line in src/web/pages/talk.ts, the link in src/web/studio/share_receive.ts, and the /talk fetch in test/share-target-image.test.ts, which now uses ?shared=1.

What I left out: a held picture does not appear in the chip row on a plain /talk visit. It does still ride along with the next message.

To try it: share an image to the forge from a phone, then follow "It waits in Talk" and the picture appears as an attachment chip.

commented

Sharing a link, some text or a picture from a phone opens the tell box with the words filled in and a line saying what was shared. Nothing is filed until Send is tapped. A shared picture is checked by its bytes, kept as one of the person's unsent Talk attachments, and goes with their next message there.

This round answers the review:

  • The picture reaches Talk without a query flag. ?shared=1 is gone. A new filesOfTalk in src/core/conversation_files.ts reads the sent files and the person's unsent ones in a single query, so a plain /talk (bookmark, nav, reload) shows them as chips that go with the next message. A conversation with messages pays no extra statement. A conversation with no messages yet pays one, and the budget fixture's /talk is one of those, so test/pages-budget.test.ts now records /talk at 61 with the reason.
  • All unsent files are picked up, not only the shared one. I kept this on purpose: unsent files are the person's attachments in progress, and uploading allows at most four. Picking them all up also stops a reload from dropping any of them.
  • Design. .share-image loses its border and --muted fill but keeps the fixed 160px box and object-fit: contain; docs/design/areas/feed.md matches. The held form now says where the picture goes in one sentence: "Nothing is sent until you tap Send; the picture waits in Talk for your next message there."
  • Small fixes in share_receive.ts. It uses held?.draft. heldShares is a plain get-or-create function, and the comment pointing at another module is gone. scripts/gate.ts only notes a likeness to a test helper and passes.

test/share-target-image.test.ts now covers the plain path: share a picture, check the one sentence, load /talk and find the chip, delete the file and see the chip gone. Type check, gate and design lint pass, and the tests run here passed: page budget, share target, Talk page and conversations, conversation files, design components, audit and lint. The full suite was not run here.

To try it: share an image to the forge from a phone, follow the Talk link, or just open /talk later, and the picture is there as a chip.

[{"go":"/tell/share (after sharing an image from a phone)","look":"the origin line and the picture","expect":"one sentence ends 'the picture waits in Talk for your next message there.'; the picture has no frame or fill"},{"go":"/talk","look":"the chips above the composer","expect":"the shared picture is a chip without any query flag, and goes with the next message"}]

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs