I'd love to be able to add images inline in a post

merged…
osebo28d ago

I'd love to be able to add images inline in a post

3 repliesoldestnewest
Osebotfable-5-128d ago

Where things stand: images already upload (chip or ⌘V) but land in posts.meta.attachments and render as a gallery under the post. Markdown ![alt](url) in a body already renders an <img> (the agent is even told it can do that), but then the same image shows twice: inline and in the gallery.

Plan

  1. Composers (components/composer.tsx, components/thread-composer.tsx): an upload (chip, paste, and drag-drop onto the textarea) inserts ![caption](url) at the cursor on its own line, so you place the picture where you're writing. Removing the thumbnail chip also removes that markdown. Shared logic goes into one hook in components/attach-images.tsx so both composers stay identical.
  2. Rendering (components/post.tsx, components/markdown.tsx): the gallery under the post only shows attachments the body doesn't already reference; inline images get loading="lazy" and open full-size on tap, like the gallery does.
  3. Agent context (lib/context.ts): relative /uploads/… image URLs in bodies become absolute so Osebot can download them from the sandbox; the instruction also tells it that inlining a screenshot stops it repeating under the post.
  4. Keep meta.attachments as is: old posts, the API shape, the attached_images line in the prompt, and the 8-image cap are untouched.

Will verify with tsc + a static mockup screenshot of a post with an inline image.

Osebotfable-5-128d agothreadide@6dc4cd2

Done, pushed to thread/0042ff59 (6dc4cd2).

What changed

  • Composers (reply + start-a-thread): adding an image via the Image chip, pasting a screenshot, or dropping a file onto the text box now writes ![caption](url) into the body at the cursor, on its own line, and moves the caret below it so you keep typing. Removing the thumbnail chip removes that markdown too. Shared hook useInlineImages in components/attach-images.tsx, so both composers behave the same.
  • Rendering: inline images render lazily and open full-size on tap. The gallery under a post now only shows attachments the text doesn't already embed, so Osebot's screenshots placed inline stop showing twice (it was already told it could embed them, and they duplicated).
  • Osebot context: /uploads/… image links in bodies are made absolute so it can fetch them from the sandbox; the prompt says inline placement isn't repeated under the post.
  • Untouched on purpose: meta.attachments, the upload API, the 8-image cap, old posts.

Verified: tsc clean; helper edge cases (empty body, mid-line cursor, replacing a selection, two images at once, chip removal, captions with []) run with tsx; the screenshot attached is the real Markdown component + globals.css in post markup at 390px, before vs after.

Not verified in a browser (no DB/OAuth in the sandbox): caret placement after an upload and drag-drop. Worst case the caret stays put; the body is still right.

One known limitation worth saying: the textarea shows the raw ![…](…) markdown, not a picture. The chip row is the visual confirmation. If you'd rather see a rendered preview while writing, that's a separate (bigger) step.

Post with an image: before (gallery under the text) vs after (inline where the sentence placed it), 390px, real globals.css + Markdown component
Post with an image: before (gallery under the text) vs after (inline where the sentence placed it), 390px, real globals.css + Markdown component
Osebot28d ago

Merged threadide #167 by @osebo (merge, 980a701).