Cache Discord media locally - #6
Merged
Merged
Conversation
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: unavailable · PR result: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
Peyton-Spencer
force-pushed
the
feat/discord-media-cache
branch
from
August 29, 2026 04:38
2dd89e5 to
5ee6fe7
Compare
3 tasks
Peyton-Spencer
force-pushed
the
feat/discord-media-cache
branch
from
August 29, 2026 04:46
5ee6fe7 to
2e710d1
Compare
This was referenced Aug 29, 2026
Peyton-Spencer
marked this pull request as ready for review
August 30, 2026 18:50
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.
Summary
Cache Discord images locally while their signed CDN URLs are still valid, then render them through T3's existing signed local asset route. This is stacked directly on #5.
Changes
discord-*cache files after 30 days or above a 1 GiB LRU budgetRecovery finding
Opening an exact Discord message produced a fresh signed URL transiently, but Discrawl v0.13.3's full wiretap later overwrote it with an older duplicate and a targeted fetch still returned HTTP 404. This PR therefore does not automate accessibility or hidden Discord navigation; expired media uses an explicit exact-message fallback until Discrawl can deterministically preserve the newest attachment URL.
Test plan
pnpm --filter t3 typecheckpnpm --filter @t3tools/web typecheckpnpm --filter t3 exec vp test run src/channels/DiscordMediaCache.test.ts src/channels/DiscrawlAdapter.test.tspnpm --filter @t3tools/web buildpnpm exec vp check(0 errors; 19 pre-existing warnings)Note
Add local Discord media cache to Discrawl channel adapter
DiscordMediaCachein DiscordMediaCache.ts to download and store Discord image attachments on the local filesystem with host, expiry, type, signature, and size (<= 25 MiB) validation, atomic writes, deduplicated in-flight fetches, and a periodic sweeper that removes files older than 30 days and trims total cache to <= 1 GiB.makeDiscrawlAdaptervia ChannelRegistry.ts and DiscrawlAdapter.ts; listed messages now includecachedAttachmentIdandcacheStateon attachments when caching is enabled.DiscordAttachment,CachedDiscordAttachment,DiscordImage, andDiscordAttachmentButtoncomponents that render locally cached assets viauseAssetUrl, show an open-in-Discord button for expired links, and fall back to remote URLs otherwise.ChannelAttachmentin channels.ts with optionalcachedAttachmentIdandcacheStatefields.DiscordMediaCachewrites toconfig.attachmentsDir; incorrect config or a full disk will cause cache failures to surface asunavailableattachments rather than errors. Sweeper deletes anydiscord--prefixed files in the attachments directory older than 30 days, so existing files matching that pattern will be removed.Macroscope summarized 2e710d1.