Skip to content

Navigation Menu

Sign in
Sign up

fix: cache inline image payloads - #1707

Open
kawacukennedy wants to merge 1 commit into
floatpane:master from
kawacukennedy:fix/inline-image-cache
Open

fix: cache inline image payloads #1707
kawacukennedy wants to merge 1 commit into
floatpane:master from
kawacukennedy:fix/inline-image-cache

Conversation

@kawacukennedy

@kawacukennedy kawacukennedy commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

What?

Inline cid: images never render. CachedAttachment stored only attachment metadata, so the decoded payload of inline attachments was dropped on cache write and never restored on cache read. inlineImagesFromAttachments skips attachments with empty Data, so the CID lookup always resolved against an empty map.

This PR adds a Data []byte field to CachedAttachment and:

  • persists the decoded payload for inline attachments in both cache-write paths (PreviewBodyFetchedMsg, EmailBodyFetchedMsg),
  • restores it in both cache-read paths,
  • counts it in calculateEmailBodySize so LRU accounting stays accurate.

Why?

Fixes #1702. With the payload cached, the CID lookup in ProcessBodyWithInline resolves and inline images render via the Kitty graphics protocol like remote ones.

CachedAttachment previously stored only metadata, dropping the decoded
payload of inline (cid:) attachments. On a cache hit, attachments were
rebuilt with empty Data, so inlineImagesFromAttachments always skipped
them and CID lookup resolved against an empty map. Persist the decoded
payload for inline attachments on cache write and restore it on read so
cid: images render from cache.
kawacukennedy requested a review from a team as a code owner August 13, 2026 18:46
@floatpanebot floatpanebot added bug Something isn't working area/config Configuration / settings size/M Diff: 51–200 lines labels Aug 13, 2026

Copy link
Copy Markdown
Member

Benchmark report — no significant change

Metrics worse: 0 · better: 0 (threshold: ±3%).

benchstat output
goos: linux
goarch: amd64
pkg: github.com/floatpane/matcha/backend
cpu: AMD EPYC 9V74 80-Core Processor 
 │ old.txt │ new.txt │
 │ sec/op │ sec/op vs base │
ParseSearchQuery_Simple-4 2.559μ ± 28% 2.435μ ± 82% ~ (p=0.818 n=6)
ParseSearchQuery_Complex-4 8.173μ ± 44% 5.982μ ± 39% ~ (p=0.065 n=6)
TokenizeSearchQuery-4 4.170μ ± 19% 3.886μ ± 18% ~ (p=0.900 n=6)
geomean 4.434μ 3.840μ -13.41%
 │ old.txt │ new.txt │
 │ B/op │ B/op vs base │
ParseSearchQuery_Simple-4 26.00 ± 0% 26.00 ± 0% ~ (p=1.000 n=6) 1
ParseSearchQuery_Complex-4 762.0 ± 0% 762.0 ± 0% ~ (p=1.000 n=6) 1
TokenizeSearchQuery-4 176.0 ± 0% 176.0 ± 0% ~ (p=1.000 n=6) 1
geomean 151.6 151.6 +0.00%
1 all samples are equal
 │ old.txt │ new.txt │
 │ allocs/op │ allocs/op vs base │
ParseSearchQuery_Simple-4 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=6) 1
ParseSearchQuery_Complex-4 23.00 ± 0% 23.00 ± 0% ~ (p=1.000 n=6) 1
TokenizeSearchQuery-4 9.000 ± 0% 9.000 ± 0% ~ (p=1.000 n=6) 1
geomean 7.453 7.453 +0.00%
1 all samples are equal
pkg: github.com/floatpane/matcha/tui
 │ old.txt │ new.txt │
 │ sec/op │ sec/op vs base │
LogPanelView-4 161.0μ ± 16% 158.6μ ± 14% ~ (p=0.394 n=6)
SearchOverlayView-4 187.3μ ± 8% 168.5μ ± 8% -10.05% (p=0.009 n=6)
InboxConstruction-4 895.7μ ± 16% 925.0μ ± 20% ~ (p=0.589 n=6)
geomean 300.0μ 291.3μ -2.91%
 │ old.txt │ new.txt │
 │ B/op │ B/op vs base │
LogPanelView-4 44.67Ki ± 51% 33.23Ki ± 34% ~ (p=0.675 n=6)
SearchOverlayView-4 33.17Ki ± 69% 56.14Ki ± 41% +69.25% (p=0.028 n=6)
InboxConstruction-4 874.3Ki ± 0% 874.2Ki ± 0% -0.02% (p=0.013 n=6)
geomean 109.0Ki 117.7Ki +7.97%
 │ old.txt │ new.txt │
 │ allocs/op │ allocs/op vs base │
LogPanelView-4 714.0 ± 0% 713.0 ± 0% ~ (p=1.000 n=6)
SearchOverlayView-4 923.5 ± 0% 926.0 ± 0% +0.27% (p=0.041 n=6)
InboxConstruction-4 3.479k ± 0% 3.477k ± 0% -0.06% (p=0.041 n=6)
geomean 1.319k 1.319k +0.02%

auto-generated by benchmarks.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

area/config Configuration / settings bug Something isn't working size/M Diff: 51–200 lines

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

BUG: inline cid: images never render — attachment parts cached without payload

AltStyle によって変換されたページ (->オリジナル) /