Skip to content

fix(chat): keep remote image cards after turn-end remount - #610

Merged
RongleCat merged 1 commit into
RongleCat:mainfrom
Yy-702:fix/chat-image-thumb-remount-abort
Aug 14, 2026
Merged

fix(chat): keep remote image cards after turn-end remount#610
RongleCat merged 1 commit into
RongleCat:mainfrom
Yy-702:fix/chat-image-thumb-remount-abort

Conversation

@Yy-702

@Yy-702 Yy-702 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Why

Remote https images in assistant leftovers (e.g. a web-fetch stock chart) render while the answer is still streaming, then flip to 预览失败 — 文件可能已损坏或无法读取 (broken_blob) as soon as the turn ends.

The file is fine. Host already wrote a valid JPEG thumb under cache/image-thumbs/. What breaks is the remount:

  1. session://journal_reconciled / ready rehydrates the journal and remounts ImageUi.
  2. First paint uses the live https://… src.
  3. resolveChatImageThumb hits the in-memory cache and swaps src to the loopback thumb in a microtask.
  4. WKWebView aborts the in-flight https load → <img onError>loadFailed is locked forever.

What

  • First-paint chat cards from peekChatImageThumb when the session cache already has a display URL (no https → loopback swap on remount).
  • Ignore abort / stale-src onError (shouldApplyChatImageLoadError); remount <img> with key={resolvedSrc}.
  • Do not wipe a working https original when thumb resolve returns empty (nextChatCardDisplaySrc).

Verify

  • pnpm exec vitest run src/lib/imageThumbClient.test.ts src/lib/mediaLoadPro.test.ts (42 passed)
  • Local pnpm dev: reopen the morning-brief chat that showed the eastmoney chart; after the turn (and after switching away/back) the leftover card stays visible instead of “preview failed”.

Journal rehydrate remounted ImageUi with the live https src, then
swapped to the cached loopback thumb in a microtask. WKWebView aborted
the in-flight load and locked broken_blob ("preview failed") even though
the file was fine.

First-paint from the thumb cache, ignore abort/stale-src errors, and
do not wipe a working https original when thumb resolve returns empty.
@RongleCat
RongleCat merged commit 46429f3 into RongleCat:main Aug 14, 2026
3 of 4 checks passed
@RongleCat

Copy link
Copy Markdown
Owner

Merged, thanks @Yy-702 — this is the right remount fix.

Journal rehydrate was first-painting the live https URL, then swapping to the cached loopback thumb and locking broken_blob on the WKWebView abort. First-paint from peekChatImageThumb, ignoring abort/stale-src, and keeping a working https original when thumb resolve is empty should keep leftover cards (charts, web-fetch images) visible after the turn ends.

Landed on main as 46429f3.

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.

2 participants