Skip to content

fix(client-runtime): show the new project icon when it is too large to cache - #49436

Merged
juliusmarminge merged 2 commits into
pingdotgg:mainfrom
only21mil:fix/client-runtime-favicon-cache-evicts-stale-on-uncacheable
Dec 5, 2026
Merged

juliusmarminge merged 2 commits into
pingdotgg:mainfrom
only21mil:fix/client-runtime-favicon-cache-evicts-stale-on-uncacheable

Conversation

@only21mil

Copy link
Copy Markdown
Contributor

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.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 ([]).

Before (6be1ac51ef4d)

After (6764f5c8170f)

Stale red v1 icon left of demo-project after replacing favicon.svg with a >32 KiB green v2 SVG

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

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):

 ✓ |@t3tools/client-runtime| src/projectFaviconCache.test.ts (3 tests) 49ms

 Test Files  190 passed (190)
      Tests  1413 passed (1413)

Head 6764f5c8170f (vp test run apps/mobile/src/lib/projectFaviconDatabaseCache.test.ts):

 ✓ |@t3tools/mobile (unit)| src/lib/projectFaviconDatabaseCache.test.ts (1 test) 3ms

 Test Files  1 passed (1)
      Tests  1 passed (1)

Head 6764f5c8170f (vp run check:changed 6be1ac51ef4dd3c252eaf4ba1e78888fb4d173b1):

check:changed summary
  pass  format  0.7s
  pass  lint  0.8s
  pass  knip  7.1s
  pass  i18n  17.8s
  pass  typecheck (8 packages)  6.8s
  pass  test (1 files)  0.6s
  CI also runs: full test suites, build
  unused patch check skipped: no dependency files changed

Generated with Gemini 4 Neon in T3 Code Nightly

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Dec 5, 2026
@macroscopeapp

macroscopeapp Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 6764f5c

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.

@coderabbitai

coderabbitai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

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.

Changes: Favicon replacement handling

Layer / File(s) Summary
Bounded image loading
packages/client-runtime/src/projectFaviconCache.ts
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.
Cache replacement resolution
packages/client-runtime/src/projectFaviconCache.ts, packages/client-runtime/src/projectFaviconCache.test.ts
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.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Suggested reviewers: t3dotgg

Merge Risk: Minimal · previous review 6764f

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: Passed 4

Check name Status Explanation
Title check Passed 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 Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 1ffdd91 and 6764f5c.

Files selected for processing: 2

  • packages/client-runtime/src/projectFaviconCache.test.ts
  • packages/client-runtime/src/projectFaviconCache.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Dec 5, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

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

Proven: the scenario fails on base c344f335ab and passes on head 356d054d2f.

Base c344f335ab Head 356d054d2f
Result ❌ failed
ASSERTION_FAILED: expected [{"remote":false,"pixel":[255,0,0,255],"cached":1},{"remote":false,"pixel":[255,0,0,255],"cached":1},{"remote":false,"pixel":[255,0,0,255],"cached":1},{"remote":false,"pixel":[255,0,0,255],"cached":1}] to equal [{"remote":true,"pixel":[0,128,0,255],"cached":0},{"remote":true,"pixel":[0,128,0,255],"cached":0},{"remote":true,"pixel":[0,0,255,255],"cached":0},{"remote":true,"pixel":[0,0,255,255],"cached":0}]
✅ passed
initial cached red icon Base c344f335ab: initial cached red icon Head 356d054d2f: initial cached red icon
oversized green svg Base c344f335ab: oversized green svg Head 356d054d2f: oversized green svg
green svg after second reload Base c344f335ab: green svg after second reload Head 356d054d2f: green svg after second reload
oversized blue png Base c344f335ab: oversized blue png Head 356d054d2f: oversized blue png
blue png after second reload Base c344f335ab: blue png after second reload Head 356d054d2f: blue png after second reload
failure Base c344f335ab: failure

Scenario source

Before recording After recording
Base recording Head recording

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.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Dec 5, 2026
@juliusmarminge
juliusmarminge merged commit 5ba0e7a into pingdotgg:main Dec 5, 2026
57 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Dec 5, 2026
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Dec 5, 2026
**v0.1.14-nightly.20261205.5772** · 24 changes from 9 contributors

- **Claude task lists.** Claude and the Agent tasks panel now keep the same task list after /clear.
- **Claude background work.** Long-running Claude subagents and background tasks no longer lose their work to idle cleanup.
- **Faster force stop.** Force stop is faster on long threads.

### Plus 19 more bug fixes and performance improvements.

<details>
<summary>Full changelog</summary>

## What's Changed
* fix(web): hide stale HTML source truncation notice in rendered preview by @only21mil in pingdotgg/t3code#49370
* fix(client-runtime): hiding skills from / also hides Claude's skill commands by @juliusmarminge in pingdotgg/t3code#49382
* fix(web): keep wizard Cancel/Next visible when the content is taller than the dialog by @juliusmarminge in pingdotgg/t3code#49393
* fix(web,mobile): memory warning names the machine first by @t3dotgg in pingdotgg/t3code#49406
* test(web): thread-structure leak test waits for pending work before failing by @t3dotgg in pingdotgg/t3code#49410
* fix(server): cancelling a new project no longer leaves its folder behind by @only21mil in pingdotgg/t3code#49391
* fix(server): an unsettle in the same turn cancels a pending self-settle by @fe-franco in pingdotgg/t3code#49379
* fix(web): model and skill mentions in markdown table cells render as chips by @juliusmarminge in pingdotgg/t3code#49403
* fix(server): a PR watch reports a pass once per head through reruns by @juliusmarminge in pingdotgg/t3code#49395
* fix(desktop): mute hidden browser previews by @Yash-Singh1 in pingdotgg/t3code#49425
* fix(server): ignore rolled-back runs in stopped delegated-task notices by @only21mil in pingdotgg/t3code#49392
* fix(web): download the HEIC decoder once for previews and attachments by @juliusmarminge in pingdotgg/t3code#49412
* fix(server): keep Claude's task list across /clear in the same thread by @juliusmarminge in pingdotgg/t3code#49420
* fix(server): preview file chooser no longer drops JSON file uploads by @taogezhizun in pingdotgg/t3code#49416
* fix(web): ignore modified arrow and space chords in environments map by @only21mil in pingdotgg/t3code#49418
* perf(server): limit history reads for force stop by @juliusmarminge in pingdotgg/t3code#49384
* perf(server): limit reads when stopping delegated tasks by @UtkarshUsername in pingdotgg/t3code#49375
* test(mobile-nitro): Ctrl+C cancels a split paste held at a startup prompt by @StiensWout in pingdotgg/t3code#49399
* fix(server): PR creates and pushes after a heredoc opener are no longer missed by @only21mil in pingdotgg/t3code#49381
* fix(mobile): keep the reading position when the chat column changes width by @juliusmarminge in pingdotgg/t3code#49434
* fix(client-runtime): show the new project icon when it is too large to cache by @only21mil in pingdotgg/t3code#49436
* fix(server): idle cleanup no longer kills Claude background work after four hours by @juliusmarminge in pingdotgg/t3code#49438
* fix(acp): clear background work on runtime exit and settled-turn Stop by @snwchd71 in pingdotgg/t3code#49409
* fix(desktop): Linux payload validation rejects missing or wrong-arch natives by @juliusmarminge in pingdotgg/t3code#49429

## New Contributors
* @taogezhizun made their first contribution in pingdotgg/t3code#49416
* @snwchd71 made their first contribution in pingdotgg/t3code#49409

**Full Changelog**: pingdotgg/t3code@v0.1.14-nightly.20261205.5766...v0.1.14-nightly.20261205.5772

</details>


Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.1.14-nightly.20261205.5772
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants