Repository navigation
fix(composer): keep an inline image where the user placed it - #1442
Merged
Merged
Conversation
An image chip serialized to nothing at submission, so an image travelled as a trailing attachment: the transcript and the provider prompt put every image after the text even when the draft had named it between words. The user's own order survived editing and was then thrown away on send. Serialize the chip's `@path` at its place in the prompt instead and have Electron main record that text on the prepared attachment (`inlinePath`). The durable message, a restored session, and the runtime's content blocks all read the position back, so an image block sits where it was typed. An attachment the prompt does not name inline keeps the previous trailing behavior, and records written before this change render exactly as they did. Host-core persists the new field beside the existing attachment fields; the content block splice itself lives in one shared placement helper, so the renderer and the runtime cannot disagree about where an image belongs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
An image chip keeps its place in the Composer draft, but on send the chip
serialized to nothing, so the image travelled as a trailing attachment. The
transcript and the provider prompt therefore put every image after the text
even when the draft had named it between words: text, image, text came back as
text, text, image.
Change
@pathat the position itheld; renderer-only sentinels never reach the prompt.
inlinePathon the prepared attachment(durable message attachment and sidecar attachment alike), and stops
appending a fallback path the prompt already names.
packages/shared/src/inline-attachments.ts)splits the prompt into ordered text runs and attachments. The transcript
renders the image chip there, a restored session rebuilds the same content
blocks, and the runtime hands pi the built user message instead of
prompt(text, images), which always appended images last.behavior, and records written before this change render exactly as before.
inlinePathbeside the existing attachment fields; datarelocation never rewrites it (it is the user's own text).
Verification
pnpm test(build:js + every package test +cargo test -p host-core):desktop 3584, shared 1190, agent-runtime 1297, host-core 781 — all green.
pnpm --filter @pi-desktop/desktop typecheck,pnpm lint,node scripts/check-architecture.mjs,pnpm docs:check(85 locale pairs,559 pages),
cargo fmt --check— all pass. Clippy reports only the twopre-existing
transcripts.rswarnings.prompt-inline-attachments.test.mjs(recording, dedupe, replayed copy),
session-message-presentation.test.mjs(row order), and
runtime.test.tsplacement cases (live prompt, trailingimage, restored history).
test:e2e:composer-pastepasses its Composer probewith
imageOnly: true, including the updated submission assertion.ordering step.