You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(client-runtime): show the new project icon when it is too large to cache - #49436
When a project has a cached icon and the icon is replaced with one too large to cache (an SVG whose data URL is over 32 KiB, or any image over 4 MiB), the old icon keeps showing, even after a reload. The loader threw on the size limits, and the cache treats every loader error as a network failure and answers with the cached icon. I found this reading packages/client-runtime/src/projectFaviconCache.ts and reproduced it in T3 Code web by replacing a cached small favicon.svg with a >32 KiB SVG.
Change
In packages/client-runtime/src/projectFaviconCache.ts, the loader returns null for an SVG over the 32 KiB cache limit or a download over 4 MiB instead of throwing. On null, resolve evicts the stale cached entry (only if it still matches the entry captured before the load, after the existing abort and clear checks) and returns the remote URL; network, HTTP, abort, and downscale errors still throw, so the cached icon stays.
Scope
Bug fix for stale rendered project favicons in packages/client-runtime (15 non-test lines in 1 file). Small fix for an obvious bug, so no issue.
Verification
Setup: Ubuntu 26.04.1 LTS x86_64, T3 Code web in the Browser panel, Light theme, 1280x800, fresh isolated state per commit. Steps: Open demo-project with 171 B red favicon.svg → cached → replace favicon.svg with 38,932 B green SVG → reload. Observed: Before (6be1ac51ef4d), the header <img> kept the v1 data:image/svg+xml;base64,... URL and the images store in IndexedDB t3code:project-favicons kept the v1 record. After (6764f5c8170f), the header <img> loaded the v2 /api/assets/... URL and the images store was empty ([]).
Stale red v1 icon left of demo-project after replacing favicon.svg with a >32 KiB green v2 SVG
Green v2 icon left of demo-project after replacing favicon.svg with a >32 KiB green v2 SVG
Links: Base 6be1ac51ef4d · Head 6764f5c8170f · Regression test packages/client-runtime/src/projectFaviconCache.test.ts
Not shown: Desktop and apps/mobile not captured live (both use the shared cache covered by unit tests); apps/mobile-nitro does not use projectFaviconCache.
Automated tests and check:changed output (base 6be1ac5 vs head 6764f5c)
Base 6be1ac51ef4d source with 6764f5c8170f tests (vp test run packages/client-runtime/src/projectFaviconCache.test.ts):
❯ |@t3tools/client-runtime| src/projectFaviconCache.test.ts (3 tests | 1 failed) 21ms
❯ persistent project favicon cache (3)
✓ isolates environments, workspaces, and icon selections 2ms
✓ bounds individual images, total bytes, and entry count in storage 2ms
× evicts a stale cached icon when the replacement exceeds cache limits while keeping it on transient failures 16ms
FAIL |@t3tools/client-runtime| src/projectFaviconCache.test.ts > persistent project favicon cache > evicts a stale cached icon when the replacement exceeds cache limits while keeping it on transient failures
AssertionError: expected 'data:image/svg+xml;base64,PHN2Zy8+' to be 'https://remote.test/api/assets/token-…' // Object.is equality
Expected: "https://remote.test/api/assets/token-a/v2-icon.svg"
Received: "data:image/svg+xml;base64,PHN2Zy8+"
❯ src/projectFaviconCache.test.ts:95:58
Test Files 1 failed (1)
Tests 1 failed | 2 passed (3)
Head 6764f5c8170f (vp test run packages/client-runtime):
Macroscope's review found this PR approvable — Oversized project icons now display from their current URL rather than leaving a stale cached thumbnail. The change is confined to icon caching and preserves existing size limits and transient-failure fallback.
You can add or adjust custom eligibility rules. Learn more.
Reviewing files that changed from the base of the PR and between 6764f5c and 356d054.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
The favicon loader now reports oversized data and invalid SVG data as invalid results. The cache removes a matching cached entry for an invalid replacement and returns the original URL. Loader errors continue to fall back to the cached URL or original URL.
Bounded reads return null when declared, buffered, or streamed image data exceeds the size limit. The loader can return null for bounded-read failures and invalid SVG data. Other invalid image data still goes through the downscaler.
The cache removes the matching entry when a loaded result is invalid and returns the original URL. Loader errors still preserve the cached value. Tests cover transient fetch failures and oversized replacements.
This change clears a stale cached project favicon when its replacement is too large to cache, and shows the remote icon instead. Network and abort errors still keep the cached icon. No concrete merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: the loader now returns null for oversized icons so the new project icon shows instead of a stale cached one. It uses the conventional commit format and matches the dif…
Description check
The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section states the bug and reproduction steps. The Change section explains the null-return f…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: the loader now returns null for oversized icons so the new project icon shows instead of a stale cached one. It uses the conventional commit format and matches the diff in projectFaviconCache.ts and its test. The title is 76 characters, slightly above a short title, but it stays clear and specific.
Full details: Description check
Explanation
The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section states the bug and reproduction steps. The Change section explains the null-return fix and the eviction logic. The Scope section names the bug, the affected file, and why no issue is linked. The Verification section gives before and after evidence, test output, and the checks run. It also states what was not captured live (Desktop and apps/mobile). It ends with the model and harness line. The description does not include the template's conventional-commit title comment, and the Scope section says no issue is needed for an obvious bug, which the template allows.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Environment on both sides: real web app, headless Chromium on Linux, 1280×800, light theme, fresh isolated server state seeded through project/thread APIs with Replay (dev).
Seed a scratch git project with a small red favicon.svg and a Replay (dev) thread. Open the Projects picker and confirm its red data URL is cached in IndexedDB. Replace it with a valid approximately 46 KB green SVG, reload and reopen the picker, then reload again. Delete the SVG and write a valid 6.75 MB blue PNG, reload and reopen the picker, then reload again. Capture each state and check the rendered pixel, remote asset URL, and persisted cache count.
Scenario: Oversized replacement icons replace the stale cached project icon
Base retained the red data URL and one IndexedDB entry through all four replacement/reload states. Head displayed the green SVG and blue PNG from their current asset URLs and retained zero stale cache entries.
Not shown:
Transient loading failure fallback was not exercised; this scenario covers valid replacements exceeding the SVG data URL and source download limits.
Desktop and mobile clients were not exercised; proof uses the web client.
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
size:S10-29 changed lines (additions + deletions).vouch:unvouchedAuthor is not yet trusted in the VOUCHED list.
2 participants
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.
Problem
When a project has a cached icon and the icon is replaced with one too large to cache (an SVG whose data URL is over 32 KiB, or any image over 4 MiB), the old icon keeps showing, even after a reload. The loader threw on the size limits, and the cache treats every loader error as a network failure and answers with the cached icon. I found this reading
packages/client-runtime/src/projectFaviconCache.tsand reproduced it in T3 Code web by replacing a cached smallfavicon.svgwith a >32 KiB SVG.Change
In
packages/client-runtime/src/projectFaviconCache.ts, the loader returnsnullfor an SVG over the 32 KiB cache limit or a download over 4 MiB instead of throwing. Onnull,resolveevicts the stale cached entry (only if it still matches the entry captured before the load, after the existing abort and clear checks) and returns the remote URL; network, HTTP, abort, and downscale errors still throw, so the cached icon stays.Scope
Bug fix for stale rendered project favicons in
packages/client-runtime(15 non-test lines in 1 file). Small fix for an obvious bug, so no issue.Verification
Setup: Ubuntu 26.04.1 LTS x86_64, T3 Code web in the Browser panel, Light theme, 1280x800, fresh isolated state per commit.
Steps: Open
demo-projectwith 171 B redfavicon.svg→ cached → replacefavicon.svgwith 38,932 B green SVG → reload.Observed: Before (
6be1ac51ef4d), the header<img>kept the v1data:image/svg+xml;base64,...URL and theimagesstore in IndexedDBt3code:project-faviconskept the v1 record. After (6764f5c8170f), the header<img>loaded the v2/api/assets/...URL and theimagesstore was empty ([]).Before (6be1ac51ef4d)
After (6764f5c8170f)
Stale red v1 icon left of demo-project after replacing favicon.svg with a >32 KiB green v2 SVG
Green v2 icon left of demo-project after replacing favicon.svg with a >32 KiB green v2 SVG
Links: Base 6be1ac51ef4d · Head 6764f5c8170f · Regression test
packages/client-runtime/src/projectFaviconCache.test.tsNot shown: Desktop and
apps/mobilenot captured live (both use the shared cache covered by unit tests);apps/mobile-nitrodoes not useprojectFaviconCache.Automated tests and check:changed output (base 6be1ac5 vs head 6764f5c)
Base
6be1ac51ef4dsource with6764f5c8170ftests (vp test run packages/client-runtime/src/projectFaviconCache.test.ts):Head
6764f5c8170f(vp test run packages/client-runtime):Head
6764f5c8170f(vp test run apps/mobile/src/lib/projectFaviconDatabaseCache.test.ts):Head
6764f5c8170f(vp run check:changed 6be1ac51ef4dd3c252eaf4ba1e78888fb4d173b1):Generated with Gemini 4 Neon in T3 Code Nightly