jcode icon indicating copy to clipboard operation
jcode copied to clipboard

Pasted images are never rendered in the transcript, only the [image N] placeholder

Open aphelion31 opened this issue 2 months ago • 2 comments

Summary

Paste an image and press Enter: the transcript only ever shows the literal [image N] placeholder. The bytes do reach the model, but nothing renders, so there is no way to confirm which image was actually attached.

Images coming back the other way (tool results, generated images) already render inline, so the two directions behave inconsistently.

This is a UX gap rather than a defect. Filing it because the rendering machinery is already fully in place and unused, which makes it look intentional when reading the code.

Environment

  • macOS 15, aarch64
  • jcode v0.84.0 and current master

What already exists

Everything needed is present:

  • RenderedImageSource::UserInput — the variant for exactly this case
  • RenderedImageAnchor::UserPrompt { ordinal } — the anchor for exactly this case
  • resolve_anchored_items_inner buckets by prompt ordinal (by_prompt)
  • render_message_into emits those buckets under the user's message
  • the server-side history renderer (session/render.rs) does anchor user images via image_anchor_for_message

The gap

Nothing pushes a RenderedImage for the images the client just submitted.

submit_input takes pending_images, sends them to the provider, and stores them on the session, but never adds a rendered image for the live transcript. A remote client only rebuilds remote_side_pane_images from a full History payload, so the attachment stays invisible for the whole turn even though the model received it.

Net effect: the persisted session knows the image belongs to that prompt, but the live view never shows it.

Suggested fix

Echo the submitted images as RenderedImage { source: UserInput, anchor: UserPrompt { ordinal } } right after the user's DisplayMessage is pushed, in both paths that consume pending_images:

  • submit_input (local turns)
  • submit_prepared_remote_input (remote turns)

Two details that cost me a debugging cycle, in case they help:

  1. The ordinal must be counted the way the renderer counts it: rendered user display messages, excluding synthetic attached-image label messages, matching prepare_body_incremental and session/render.rs.
  2. compacted_hidden_user_prompts() must not be added. It offsets the human-visible prompt number, not the anchor, which is relative to the rendered window. Adding it pushes every image past its real bucket. I got this wrong first.

The local side_pane_images merge dedupes on (media_type, data), so echoing before the turn is persisted does not double-render.

Branch, if useful as a reference: https://github.com/aphelion31/jcode/tree/fix/macos-clipboard-image-applescript

Tests cover presence, payload identity, per-prompt ordinal advance (a fixed ordinal stacks turn 2 under turn 1), and that a text-only turn fabricates nothing. All three fail against the unpatched submit paths.

Not covered

stage_turn_for_remote_tick_loop (queued / interleave sends) still echoes nothing. Those hand the images to process_remote_followups, which owns its own user-message echo, so wiring that up wants its own change rather than a second echo site.

Note

Filing as an issue rather than a PR because pull_request_creation_policy is collaborators_only, so CreatePullRequest is rejected for non-collaborators. Happy to open one if that changes.

aphelion31 avatar Sep 10 '26 01:09 aphelion31

Will resolve the issue in some time

pradfer123 avatar Sep 10 '26 03:09 pradfer123

Thanks for the detailed report. The current paths differ: local submissions can recover persisted images but need cache invalidation, while remote submissions lack the live image echo. Recommend treating live, queued, retry, and history-reload anchoring together and verifying the pin_images setting and deduplication. I could not complete fixed-binary visual verification here, so I am leaving this for a focused UI review rather than shipping a partial echo fix.


— Jcode agent (automated triage), on behalf of @1jehuang

1jehuang avatar Sep 10 '26 17:09 1jehuang