Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix: chat images keep the version from when the message was written #14009

Closedflamboh(GitHub profile, opens in a new tab)wants to merge 6 commits intot3code/codex-turn-mapping fromrefs/pull/14009/headopened View on GitHub

Note

🤖 Opus 5.5 on behalf of Oliver

Important

Durable fix for the stale-image problem. The prompt-only mitigation is #13942 (targets main); the two are independent and can merge in either order.

Explain Like I'm Lost

Agents show screenshots by linking absolute file paths in Markdown. That path is a live pointer, so when an agent overwrites /tmp/shot.png the chat shows a stale cached image, and once the cache clears, every older message shows the newest file. This change copies each referenced image into the attachment store when the message completes, so every message keeps the bytes it was written with.

Problem

Clients cache the signed asset URL per path and the browser caches the response for an hour, so a re-linked, overwritten file renders the old image. Busting the cache would make it worse: earlier messages would switch to the latest file and the before/after history in a thread would be lost. Files in /tmp can also disappear, breaking old threads.

Fix

  • ProviderEventIngestor queues a message-media.snapshot outbox effect in the same write when an assistant_message turn item completes with local image paths. It sits on the ingest path every adapter uses, so all providers get it.
  • MessageMediaSnapshots resolves each path's real target, opens it with the same identity-checked openMediaFile the media-file asset route uses, reads through that handle with a hard byte cap (20 files, 10 MB each, 40 MB per message), and copies it into the existing attachment store with a content-hash id. It records mediaSnapshots: [{ path, attachmentId }] on the turn item via turn-item.updated. Failures are logged and skipped and never fail the turn.
  • The event sink carries recorded snapshots onto a provider's re-send of a completed message inside the write transaction, and the snapshot commit reads the message inside its own write, so neither can erase the other.
  • If a snapshot run doesn't commit (thread deleted, message gone), it removes the copies it created.
  • Image extraction handles balanced parentheses in paths and reference-style images.
  • Snapshots get their own per-thread outbox lane, so large copies don't delay the next turn.
  • Web and mobile render the snapshot attachment when one exists. Open file and copy path still use the original path. Messages without a snapshot (older threads, failed copies, relative paths, videos) keep today's live behaviour.
  • Thread deletion removes snapshot attachments along with the others.

Tests cover: a completed message queues one effect and a streaming one queues none; missing, oversized, non-image and symlinked-to-non-image paths are skipped; overwriting the source leaves the stored bytes unchanged; a provider re-send keeps the snapshots; deletion cleanup includes snapshot ids.

Opus 5.5 via Claude Code in T3 Code

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      orchestration-v2/MessageMediaSnapshots.ts:118

      This service has a no-op Context.Reference default, so a missing layer silently discards snapshot effects. Please define it as a required Context.Service with its interface inline, extract construction into an exported make, and expose a layer built from make; missing wiring should remain a typed layer requirement. This also lets the executor declare the snapshot service among its layer requirements.

      No longer relevant as of 8604e6980ad61b2df96cfd8e5bef047acb140818

      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      orchestration-v2/MessageMediaSnapshots.ts:26

      At these service boundaries, please import the local modules as namespaces (* as EventSink, * as IdAllocator, * as ProjectionStore) and acquire yield* EventSink.EventSinkV2, etc., rather than importing bare service tags.

      No longer relevant as of 8604e6980ad61b2df96cfd8e5bef047acb140818

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This change introduces an automatic media-snapshot workflow spanning provider ingestion, durable outbox execution, filesystem and attachment persistence, orchestration schema/state, cleanup, and web/mobile rendering. Its size and cross-cutting production side effects exceed a self-contained bug fix, so the implementation warrants human review.

      Notes:

      • All code in this push has already been reviewed. Approvability was decided on eligibility alone.
      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Note

      This comment is posted by Julius' dot

      Closing under the prior-approval rule. This changes local-image links from live file references into automatically retained message snapshots, adding a durable capture and deletion lifecycle for every provider. That is an intentional persistence and product-behavior choice beyond correcting a stale cache. Neither this PR nor #13942 records explicit maintainer approval of that direction and scope. The stale-image problem and focused tests are useful; please agree on snapshot semantics and retention with maintainers, link the approval, and request reconsideration.

    5. juliusmarminge closed this

Sign in to join this conversation.