@devries-cameron20 / t3code Mirror · read-only / commits / 3409651912
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 23:00 UTC

chore(mobile): name the two project favicon caches by their job (#13160)

Julius Marminge committed Sep 22, 2026 at 17:20 UTC 34096519121033ccf72cd43ea5350f9482df188a
8 files changed +31 -15
apps/mobile/src/components/ProjectFavicon.tsx
+1 -1
@@ -18,7 +18,7 @@ import {
18 hasLoadedProjectFavicon,
19 markProjectFaviconFailed,
20 markProjectFaviconLoaded,
21 -} from "./projectFaviconCache";
21 +} from "../lib/projectFaviconRequests";
22
23 const EMPTY_FAVICON_URL = Atom.make<string | null>(null);
24
apps/mobile/src/connection/environment-cache-store.ts
+6 -3
@@ -15,7 +15,10 @@ import * as Option from "effect/Option";
15 import * as Schema from "effect/Schema";
16
17 import * as MobileDatabase from "../persistence/mobile-database";
18 -import { attachProjectFaviconDatabase, projectFaviconCache } from "../lib/projectFaviconCache";
18 +import {
19 + attachProjectFaviconDatabase,
20 + projectFaviconDatabaseCache,
21 +} from "../lib/projectFaviconDatabaseCache";
22
23 const SHELL_SNAPSHOT_CACHE_SCHEMA_VERSION = 1;
24 // v3 adds windowed (paginated) snapshots carrying `page` metadata; the bump
@@ -130,7 +133,7 @@ export const make = Effect.fn("MobileEnvironmentCacheStore.make")(function* () {
133 decode: decodeStoredShellSnapshot,
134 select: (stored) =>
135 stored.environmentId === environmentId ? Option.some(stored.snapshot) : Option.none(),
133 - }).pipe(Effect.tap(() => Effect.promise(() => projectFaviconCache.hydrate()))),
136 + }).pipe(Effect.tap(() => Effect.promise(() => projectFaviconDatabaseCache.hydrate()))),
137 ),
138 saveShell: Effect.fn("MobileEnvironmentCache.saveShell")(function* (environmentId, snapshot) {
139 const payload = yield* encodeStoredShellSnapshot({
@@ -241,7 +244,7 @@ export const make = Effect.fn("MobileEnvironmentCacheStore.make")(function* () {
244 .pipe(Effect.mapError(mapDatabaseError("clear-vcs-refs"))),
245 ),
246 clear: Effect.fn("MobileEnvironmentCache.clear")((environmentId) =>
244 - Effect.promise(() => projectFaviconCache.clearEnvironment(environmentId)).pipe(
247 + Effect.promise(() => projectFaviconDatabaseCache.clearEnvironment(environmentId)).pipe(
248 Effect.andThen(database.clearEnvironmentCache(environmentId)),
249 Effect.mapError(mapDatabaseError("clear-environment")),
250 ),
apps/mobile/src/lib/projectFaviconDatabaseCache.test.ts renamed
+1 -1
@@ -27,7 +27,7 @@ vi.mock("expo-file-system", () => ({
27 },
28 }));
29
30 -import { downscaleProjectFavicon } from "./projectFaviconCache";
30 +import { downscaleProjectFavicon } from "./projectFaviconDatabaseCache";
31
32 const png = "iVBORw0KGgoAAAAA";
33 const image = { url: "https://remote/icon.png" };
apps/mobile/src/lib/projectFaviconDatabaseCache.ts renamed
+8 -3
@@ -1,5 +1,5 @@
1 import {
2 - createProjectFaviconCache,
2 + createProjectFaviconCache as createSharedProjectFaviconCache,
3 createProjectFaviconImageLoader,
4 PROJECT_FAVICON_MAX_DATA_URL_LENGTH,
5 PROJECT_FAVICON_THUMBNAIL_SIZE,
@@ -78,8 +78,13 @@ export async function downscaleProjectFavicon(
78 throw new Error("Project icon thumbnail exceeds the cache limit.");
79 }
80
81 -/** Rows live in `client_cache` so Settings → Client storage counts and clears them. */
82 -export const projectFaviconCache = createProjectFaviconCache({
81 +/**
82 + * The database-backed project favicon cache. Named apart from the shared
83 + * `createProjectFaviconCache` factory it calls and from the in-flight request
84 + * registry in `projectFaviconRequests`. Rows live in `client_cache` so
85 + * Settings → Client storage counts and clears them.
86 + */
87 +export const projectFaviconDatabaseCache = createSharedProjectFaviconCache({
88 storage: {
89 list: () =>
90 runDatabase((database) =>
apps/mobile/src/lib/projectFaviconRequests.test.ts renamed
+2 -2
@@ -6,9 +6,9 @@ import {
6 hasLoadedProjectFavicon,
7 markProjectFaviconFailed,
8 markProjectFaviconLoaded,
9 -} from "./projectFaviconCache";
9 +} from "./projectFaviconRequests";
10
11 -describe("project favicon cache", () => {
11 +describe("project favicon requests", () => {
12 it("ignores callbacks from a superseded URL", () => {
13 const cacheKey = "environment-1:/workspace:v1-favicon.svg";
14 const expiredUrl = "https://environment.example/api/assets/expired/v1-favicon.svg";
apps/mobile/src/lib/projectFaviconRequests.ts renamed
+8
@@ -1,3 +1,11 @@
1 +/**
2 + * Request bookkeeping behind `ProjectFavicon`: tracks the favicon URLs with
3 + * mounted views per cache key, keeps one of them current, and remembers which
4 + * keys have already loaded so superseded or already-shown loads settle without
5 + * churn. This is not request coalescing — each mount still issues its own
6 + * load — and it is not the cache; persistence lives in
7 + * `projectFaviconDatabaseCache`.
8 + */
9 export interface ProjectFaviconRequest {
10 readonly cacheKey: string;
11 readonly faviconUrl: string;
apps/mobile/src/state/assets.ts
+2 -2
@@ -16,7 +16,7 @@ import { useCallback } from "react";
16
17 import { environmentCatalog } from "../connection/catalog";
18 import { connectionAtomRuntime } from "../connection/runtime";
19 -import { projectFaviconCache } from "../lib/projectFaviconCache";
19 +import { projectFaviconDatabaseCache } from "../lib/projectFaviconDatabaseCache";
20 import { type AssetUrlState, deriveAssetUrlState } from "./asset-url-state";
21 import { environmentSession, usePreparedConnection } from "./session";
22 import { useAtomQueryRunner } from "./use-atom-query-runner";
@@ -26,7 +26,7 @@ export type { AssetUrlFailureReason, AssetUrlState } from "./asset-url-state";
26 export const assetEnvironment = createAssetEnvironmentAtoms(connectionAtomRuntime);
27
28 export const projectFaviconUrlAtom = createProjectFaviconUrlAtomFamily({
29 - imageCache: projectFaviconCache,
29 + imageCache: projectFaviconDatabaseCache,
30 createUrl: assetEnvironment.createUrl,
31 preparedConnection: environmentSession.preparedConnectionValueAtom,
32 });
apps/mobile/src/state/client-cache-state.ts
+3 -3
@@ -3,7 +3,7 @@ import * as Effect from "effect/Effect";
3 import { Atom } from "effect/unstable/reactivity";
4
5 import { type ClientCacheKind, MobileDatabase } from "../persistence/mobile-database";
6 -import { projectFaviconCache } from "../lib/projectFaviconCache";
6 +import { projectFaviconDatabaseCache } from "../lib/projectFaviconDatabaseCache";
7 import * as Runtime from "../lib/runtime";
8
9 export interface EnvironmentClientCacheSummary {
@@ -74,8 +74,8 @@ export const clearClientCacheAtom = clientCacheRuntime
74 .fn((scope: ClientCacheClearScope, get) =>
75 Effect.promise(() =>
76 scope.type === "all"
77 - ? projectFaviconCache.clearAll()
78 - : projectFaviconCache.clearEnvironment(scope.environmentId),
77 + ? projectFaviconDatabaseCache.clearAll()
78 + : projectFaviconDatabaseCache.clearEnvironment(scope.environmentId),
79 ).pipe(
80 Effect.andThen(MobileDatabase),
81 Effect.flatMap((database) =>