Skip to content

ui-react: rebuild image previews when explicitly sending restored held messages #3987

Open

Description

@schlessera

Out of scope

No automatic send on reload, replay of uncertain/dispatched work, new queue capacity, new image formats or stored derived frames. No changes to the once-only acceptance protocol, draft revision ownership or original retention. SVG/BMP support is a separate follow-up and is not required to repair restoration of already-supported image formats.

Context

Part of #3150. The maintainer selected #3155 I2 B (2026-11-11): when the user explicitly sends a restored held message, rebuild eligible previews from its stored image originals. Reload alone never sends it.

At inspected main 3c44ac6fc56d27675dadaf38a16254db53c39f69, mergeSnapshots (packages/ui-react/src/stores/draft-state.ts:139) restores fileIds without optional local file metadata. advanceSnapshots (packages/ui-react/src/lib/draft-client.ts:354) prepares frames only from s.files entries carrying that metadata. Thus a restored snapshot can dispatch originals without their otherwise eligible image frames. ensureFrame (packages/ui-react/src/lib/image-frames.ts:92) can already retrieve original bytes, and createAttachmentRoutes (packages/ui-server/src/attachments/routes.ts:78, original GET at :196) enforces authorized original retrieval.

Scope

On an explicit send of a restored held snapshot, resolve trustworthy metadata and bytes for its exact fileIds, rebuild eligible frames through the shared frame registry, and send that immutable snapshot with its original references. Reuse existing authorized APIs where they supply the needed evidence; any missing bounded lookup must enforce the same owner/reference and integrity checks. Do not infer kinds from filenames/MIME or copy current composer metadata into an older snapshot.

Preserve original ordering and the existing count/byte budgets. Frame derivation remains disposable page state, not draft truth. All asynchronous results are scoped to the original account, draft, snapshot, fileId and generation/revision, and discarded after Cancel/removal/lock/disposal or replacement.

Acceptance criteria

  • A real host/runtime case creates a held image snapshot, discards page-local metadata, reloads, and observes zero send effects until an explicit user send. That send retrieves the exact authorized originals and includes the same eligible frames/references as before reload, once.
  • Same-name files with different IDs, mixed image/non-image batches and later composer edits do not substitute/reorder bytes or consume another revision. Legacy inline images and restored supported originals share the existing aggregate image budgets.
  • Cancel/removal, account lock/switch, connection loss, generation change and stale lookup results cannot send, attach another account's file or recreate a cancelled snapshot. An uncertain acceptance stays uncertain; no fetch retry replays its message.
  • Transient metadata/original retrieval failure is visible with appropriate existing recovery controls; it cannot silently masquerade as an intentional original-only preview result. Deterministic content/format limitations preserve the original and the approved truthful sendable-content behavior. No fabricated saved/read claim.
  • Missing/foreign/deleted references are refused through actual authenticated server handlers. No unauthorized original bytes or frames enter provider context.
  • A named failing-first case demonstrates frame loss after reload; restored mutations that skip metadata hydration and dispatch without an explicit send each fail on the intended frame/no-send assertion. Bound work to the snapshot's files, clean up object URLs and preserve provider prefixes.

Verification

Use packages/ui-react/tests/draft-client.test.ts, draft-snapshots.test.ts, draft-runtime.test.ts and the actual browser outgoing-snapshot/image-original cases. Include a real persisted-host/reload/send path with offline provider doubles, plus mounted-route authorization/integrity proof. Run focused affected checks and provider-history guards, without real provider calls or device access.

Contract impact

Preserve current draft/snapshot and chat-message wire shapes when existing APIs suffice. Any additive authenticated metadata surface or changed documented semantics must update the relevant integration-contract component in the same CONTRACT commit. No persisted inline image payload or public field is selected by this decision.

Activity

  1. added
    type: fix
    area: ui-react
    priority: p2
    agent-ready
    on Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: ui-reactpriority: p2type: fix

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions