Skip to content

feat: Attach images to sessions - #20

Open
fismif wants to merge 13 commits into
eclipse-enclave:mainfrom
fismif:main
Open

fismif wants to merge 13 commits into
eclipse-enclave:mainfrom
fismif:main

Conversation

@fismif

@fismif fismif commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

What and why

Agents in Enclave sessions have no display and no clipboard, so a user can't show one a screenshot.
This lets you attach a PNG or JPEG to a session from HomeShell: paste it into the prompt box, drop
it on the session row, or pick it with the new "Attach image" button. HomeShell imports it into the
project's Enclave image inbox, then hands it to the agent without submitting, so your next
prompt goes with it:

  • Native paste (Ctrl+V) for agents that paste the format: Claude Code and Pi (PNG, JPEG),
    OpenCode (PNG). The catalog's new imagePaste field says which, and is user-editable.
  • The image's path for every other agent and format.

Closes #19.

Depends on eclipse-enclave/enclave#230 (enclave img import, the image inbox), which is not
merged yet. This was built against its fd004c4. On an enclave without the inbox, nothing here
shows: no setting and no attach controls. Re-check against the merged commit before merging this.

Per commit

  • 802f5c3 POST {s}/image (raw bytes, 10 MiB limit, PNG/JPEG checked by magic bytes) and the
    attachImage session capability; the demo provider implements it.
  • c57467f "Attach image" button in the session row; uploads in order, stops at the first failure.
  • e8469f3, 688d139, af98941 Paste into the prompt box and drop on the row. In the Linux desktop
    app, pasting an image doesn't work (WebKitGTK hands the page no file), so it now says to drop the
    image or use the button instead. Recorded in docs/ARCHITECTURE.md.
  • add627b "Image inbox" checkbox in the Enclave Container settings, passed on start and restart,
    read back for adopted CLI sessions, and shown as outdated settings when changed.
  • 1ef6150 Enclave attach: enclave img import --session <container> --json -, path typed into the
    agent's input, Enclave's own error on failure, one attach per project at a time.
  • 261bd26 Native Ctrl+V paste per the agent catalog's imagePaste; catalog schema 2 fills in
    the defaults for an existing agents.json.
  • b06f4d8 Glossary: image inbox and attach (an image) in CONTEXT.md.

Worth a look

  • Attach controls are disabled, not hidden, while a session is waiting or starting. Why: an image or
    path typed into a permission menu can pick an option.
  • The inbox is per project, and a native paste takes its newest image. HomeShell's own attaches in
    a project run one at a time; an enclave img import from a terminal at the same moment can still
    slip in between (documented in docs/PROVIDERS.md).
  • imagePaste accepts only png and jpeg. A hand-edited agents.json with any other value fails
    to load, like other invalid rows.
  • Not checked by hand: image paste in the macOS app (WKWebView), for lack of a Mac.

Changelog

- Attach PNG or JPEG images to a session: paste one into the prompt box, drop it on the session
  row, or use the new Attach image button. In the Linux desktop app, pasting images doesn't work;
  drop or the button do.
- Enclave sessions get an Image inbox setting in their Container settings. With it on, attached
  images reach the agent: Claude Code and Pi paste PNG and JPEG natively, OpenCode PNG, and other
  agents get the image's path in their input. Nothing is submitted, so your next prompt goes
  with the image. Needs an Enclave with the image inbox.
- The agent catalog has a new `imagePaste` field for the image formats an agent pastes natively,
  settable with `homeshell agent set <agent> --image-paste "png jpeg"`.

Checklist

  • Tests added: unit and e2e, or a regression test for a bug fix (see AGENTS.md)
  • Docs updated per the trigger table in AGENTS.md

@fismif

fismif commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

@EclipseSourceAI

@EclipseSourceAI EclipseSourceAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Autonomous AI review. May contain mistakes.

Useful comment? React 👍. Disagree? React 👎 to reject it for follow-up reviews. A reply explaining why helps too.

This agent never approves PRs. A maintainer must sign off.

Only a maintainer can re-request a review from this agent.

Powered by Eclipse Enclave via review-guard-mcp

What it does: lets you attach a PNG or JPEG to a session in three ways: paste it into the prompt box, drop it on the session row, or use a new Attach image button. The daemon gets a POST {s}/image endpoint (raw bytes, 10 MiB limit, magic bytes checked) and an ImageAttacher provider interface, gated by a per-session attachImage capability. The Enclave provider runs enclave img import and then hands the image to the agent in one of two ways:

  • sends Ctrl+V when the agent catalog's new imagePaste field lists the image's format;
  • otherwise types the image's path, without Enter.

Attaches are serialized per project. Enclave sessions also get an Image inbox setting in Container settings, which drift detection covers and adopted CLI sessions read back.

Where to focus:

  • provider/enclave/image.go: how attachImage is worked out from three sources: the contract check, the launch flags remembered at start, and the inventory listing. Missing options counts as "may have the inbox".
  • The native paste relies on Enclave's paste window opening right after the import. That behaviour is in eclipse-enclave/enclave#230, which isn't merged yet, so re-check against the merged commit as the description says.
  • The per-project lock is keyed by HomeShell's project ID. Enclave's inbox is per Enclave-resolved project, so two HomeShell projects that resolve to the same Enclave project would not serialize with each other.

Verification: I built the daemon and ran the demo UI. Attaching worked through the picker (single and multiple files), drag and drop, paste, a collapsed row and a waiting-state row. Text-only pastes and non-image files were handled correctly. The only visual issue was the collapsed-row status alignment (inline comment). I couldn't run the Go test suites here, and paste in the WebKitGTK and macOS desktop apps was not checked.

@fismif

fismif commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review.

  • Per-project lock: agreed, that's a gap. I'm tracking it as a follow-up instead of fixing it here. Keying on Enclave's resolved project needs a fallback for sessions the inventory hasn't listed yet, and that's a design question of its own.
  • enclave#230: I'll re-check native paste against the merged commit before this lands.
  • Failing Webapp job (8f063ba): the attach-status test failed on every run, not now and then. The upload finishes outside act, so the effect that starts the clear timer hadn't run yet when the test advanced the fake clock. The test now uses advanceTimersByTimeAsync inside an async act. The component was correct.

@EclipseSourceAI EclipseSourceAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Autonomous AI review. May contain mistakes.

Useful comment? React 👍. Disagree? React 👎 to reject it for follow-up reviews. A reply explaining why helps too.

This agent never approves PRs. A maintainer must sign off.

Only a maintainer can re-request a review from this agent.

Powered by Eclipse Enclave via review-guard-mcp

Follow-up review. Checked the three threads I raised earlier against the code now on the branch, all three are genuinely fixed:

  • acceptsImageNow(state) now lives in @homeshell/model (types.ts) next to hasSessionRuntime/isSessionTerminal, matches the daemon's CheckAttachable (idle/running only), and has a table test in session-display.spec.ts. session-row.tsx uses it.
  • The rememberLaunchedImageInbox comment now correctly distinguishes the cached vs. uncached case, and I confirmed sandboxFlagsFor does return before sandboxBase when the config carries no sandbox group, so the "configured" cases in TestAttachImageCapabilityOfALaunch do exercise the uncached path as claimed. Keeping the lookup (treating unknown as "may have it") is the right call given the UX trade-off described.
  • The collapsed-row attach status now gets the same 0.75rem 0.5rem 2.1rem inset as .rowNote, matching the preview underneath. I ran the new Playwright pixel-alignment test logic by hand against the CSS and it lines up; the component unit test names the attached image in a brief status that clears itself and the full components/model unit suites (895 tests) pass.

Also reviewed 8f063ba (flaky timer test fix): the reasoning holds, the effect that starts the clear timer is pending when waitFor resolves on the upload text, so a synchronous advanceTimersByTime had no pending timer to fire. Switching to advanceTimersByTimeAsync inside an async act fixes it; verified by running the test, it passes reliably now.

No new issues found in the commits since my last review; they're narrowly scoped to the three fixes above. I couldn't run the Go test suite or the Playwright e2e suite in this environment (no Go toolchain), so I verified the Go-side logic by reading sessionconfig.go/enclave.go directly instead.

The per-project lock gap mentioned in my original review is explicitly deferred as a follow-up by the author (not a formal thread), that's a reasonable call given the design question attached to it.

These previous comments can be resolved as they are now handled:

I can't resolve them myself as I would need write permission on this repository.

@fismif
fismif marked this pull request as ready for review November 27, 2026 16:00
fismif added 13 commits December 2, 2026 14:51
POST {s}/image takes raw PNG or JPEG bytes (Content-Type image/png or
image/jpeg, at most 10 MiB) and answers with the image's path as the
session's agent sees it. Sessions whose provider implements the new
ImageAttacher interface declare the derived session capability
attachImage. Only idle and running sessions take an image: in waiting an
image could pick a menu option, and a starting agent may drop it.

The demo (fake) provider implements it, making up a /mnt/host-images/
path and echoing [image: <path>] into the session's preview.
A session declaring attachImage shows a paperclip button, "Attach image",
beside its send box's Send. It opens a file picker for PNG and JPEG,
several at once. The row drops any other file with "Only PNG or JPEG
images can be attached", then uploads the rest one after another, in
order, stopping at the first refusal. A success names the image in a
brief status under the send box; failures go to the page's error line,
like other session actions.

The button is disabled, with a tooltip saying why, while the session is
not idle or running (the daemon refuses an image then), while the daemon
is unreachable, and while a batch is still uploading.
On a session declaring attachImage, pasting into its send box attaches
the clipboard's image when the clipboard holds an image and no plain
text; with any plain text it stays an ordinary text paste, so copying
from a web page never uploads an image unexpectedly. Dropping image
files on the session row attaches them, collapsed or expanded, and the
row is outlined while files are dragged over it.

Both go through the Attach image button's path: the same PNG/JPEG
filter, ordered upload stopping at the first failure, status line and
page error line. While the session takes no image (not idle or running,
daemon unreachable, a batch still uploading) the row refuses the drag,
outlined muted with the reason in its status line, and a paste reports
the reason in the error line. The "Image attached" status now also
shows on a collapsed row, so a drop there is confirmed.
Hand-checked on Ubuntu 24.04 (GNOME, Wayland; app run under XWayland for
input) with WebKitGTK 2.52.6: an image paste gives the page types [Files]
with empty files and items, and navigator.clipboard.read is undefined.
Dropping and the Attach image button work.
WebKitGTK, the Linux desktop app's webview, reports a pasted image as
type Files but hands the page no file, so the paste did nothing at all.
A paste with no text that lists files but holds none now shows "Pasting
images doesn't work here: drop the image on the row or use Attach image"
in the page error line.
When the installed enclave has the image inbox, the Enclave Container
settings get an "Image inbox" checkbox. It defaults to Enclave's
image_inbox and its help says that every session of the project that has
it on shares the inbox, and that it needs the Docker or Podman backend.
Like the other booleans, it is passed only when it differs from the
config (--image-inbox, or --image-inbox=false), replayed on restart, and
read back from ps --json for adopted CLI sessions. Drift already compares
every recorded option, so a change shows as outdated settings with no
special case.

Support is read from the contract check's own config --json answer
(.options.image_inbox), kept per binary with its verdict, so no extra
process runs. qemu is not modelled: Enclave's error shows on the session.
An Enclave session takes attached images when the installed enclave has
the image inbox, HomeShell runs a bridge to it (not a foreground CLI
session), and its recorded image inbox is on or unknown: image_inbox true
in ps --json, or no options recorded at all. Until an inventory check
lists a session HomeShell started or restarted, it goes by what its run
resolved: the --image-inbox flag passed, else Enclave's config.

An attach runs `enclave img import --session <container> --json -` in
the session's working directory with the image on stdin, reads the path
from the versioned image-import envelope, and types the path and a space
into the agent's input through the bridge's new raw input, without
Enter. A failed import's `error:` line is the 500 message. Attaches in
one project run one at a time, import and delivery together.

The e2e fixture learns img import --json and records the agent's input.
The agent catalog gains imagePaste: the image formats (png, jpeg) an
agent takes as a native attachment when sent Ctrl+V. Claude Code and Pi
paste PNG and JPEG, OpenCode PNG; every other agent, and any the user
adds, pastes none. Catalog schema 2 fills these in for an existing
agents.json, keeping a list already there. The field is editable through
/api/agents and `homeshell agent add|set --image-paste`; a format other
than png or jpeg is refused.

An attach to an Enclave session now sends Ctrl+V right after the import
when the session's agent lists the image's format, and the path and a
space otherwise, as before. Neither submits, and the per-project lock
still covers import and delivery.

The e2e fixture can list extra Enclave tools, so the API e2e covers
Claude Code (Ctrl+V), OpenCode with a JPEG (path) and a PNG (Ctrl+V),
and Codex (path).
"names the attached image in a brief status that clears itself" failed on
every run. The upload resolves outside act, so React renders the status
text but leaves the effect that starts the clear timer pending. waitFor
returned on the text, and the synchronous advance ran over a clock with
no timer on it; the effect then scheduled a real one after the test.

Advance with advanceTimersByTimeAsync inside an async act, which lets the
pending effect run and its timer fire. The component was correct.
The session row checked for idle or running inline, a copy of the state
rule in the daemon's CheckAttachable. It now calls acceptsImageNow from
@homeshell/model, beside the UI's other copies of daemon state rules
(hasSessionRuntime, isSessionTerminal), so the copy is named, documented
against its daemon source and tested in one place.
rememberLaunchedImageInbox claimed the run had always asked for Enclave's
config already. That holds only for a create or restart with a sandbox
choice; without one the config was just forgotten and is asked for after
`enclave run`. The comment now says so, and why the ask stays: skipping
it would offer attaching to a session whose inbox is off until the next
inventory check.
On a collapsed row, "Image attached: x.png" sat flush against the row's
left edge while the output preview under it starts 2.1rem in. The
row-level status now takes the inset the row's notes use; the one under
the send box keeps its own alignment. A UI e2e pins the two left edges
together.
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.

Consider image/screenshot sharing via HomeShell

2 participants