@devries-cameron20 / t3code-1 / commits / 40f63b468f
Fork 0

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

fix(assets): align app icons and retain a folder placeholder while loading (#37067)

Yash Singh committed Nov 15, 2026 at 00:40 UTC 40f63b468f0b3cbcde8cb2da72803428c4585f29
3 files changed +44 -19
apps/server/src/assets/NativeAppIconResolver.test.ts
+18
@@ -1,6 +1,8 @@
1 import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
2 import * as NodeServices from "@effect/platform-node/NodeServices";
3 import { expect, it } from "@effect/vitest";
4 +import * as Digest from "effect/crypto/Digest";
5 +import * as Hex from "effect/encoding/Hex";
6 import * as Effect from "effect/Effect";
7 import * as FileSystem from "effect/FileSystem";
8 import * as Layer from "effect/Layer";
@@ -28,18 +30,34 @@ it.effect("resolves the exact bundle path without Spotlight and caches the conve
30 commands.push(command.command);
31 if (command.command === "/usr/bin/plutil") return "AppIcon";
32 if (command.command === "/usr/bin/sips") {
33 + expect(command.args.slice(0, 3)).toEqual(["-z", "128", "128"]);
34 yield* fs.writeFileString(String(command.args.at(-1)), "converted icon");
35 }
36 return "";
37 }),
38 });
39 yield* Effect.gen(function* () {
40 + const config = yield* ServerConfig.ServerConfig;
41 + const canonicalBundle = yield* fs.realPath(bundle);
42 + const sourceIcon = path.join(canonicalBundle, "Contents", "Resources", "AppIcon.icns");
43 + const digest = yield* Digest.Digest;
44 + const legacyKey = yield* digest
45 + .digest(
46 + Digest.sha256,
47 + new TextEncoder().encode(`${canonicalBundle}\0AppIcon\0${sourceIcon}`),
48 + )
49 + .pipe(Effect.map(Hex.encode), Effect.orDie);
50 + const cacheDirectory = path.join(config.providerStatusCacheDir, "native-app-icons");
51 + yield* fs.makeDirectory(cacheDirectory, { recursive: true });
52 + const legacyIcon = path.join(cacheDirectory, `${legacyKey}.png`);
53 + yield* fs.writeFileString(legacyIcon, "legacy 64px icon");
54 const resolver = yield* NativeAppIconResolver.make;
55 const reference = { _tag: "app-path" as const, path: bundle };
56 const icon = yield* resolver.resolve(reference);
57 expect(icon).not.toBeNull();
58 if (icon === null) return;
59 expect(yield* fs.readFileString(icon)).toBe("converted icon");
60 + expect(icon).not.toBe(legacyIcon);
61 expect(yield* resolver.resolve(reference)).toBe(icon);
62 expect(yield* resolver.resolve({ _tag: "app-path", path: "~/Build Output/My App.app" })).toBe(
63 icon,
apps/server/src/assets/NativeAppIconResolver.ts
+2 -2
@@ -21,7 +21,7 @@ import * as HostProcess from "@t3tools/shared/HostProcess";
21
22 import * as ServerConfig from "../config.ts";
23
24 -const ICON_SIZE = 64;
24 +const ICON_SIZE = 128;
25 const COMMAND_TIMEOUT = "5 seconds";
26 const RESOLUTION_CACHE_TTL = Duration.hours(1);
27 const RESOLUTION_CACHE_MAX_ENTRIES = 256;
@@ -189,7 +189,7 @@ const resolveNativeAppIconUncached = Effect.fn("NativeAppIconResolver.resolveUnc
189 )
190 .pipe(Effect.map(Hex.encode), Effect.orDie);
191 const cacheDirectory = path.join(config.providerStatusCacheDir, "native-app-icons");
192 - const cachePath = path.join(cacheDirectory, `${cacheKey}.png`);
192 + const cachePath = path.join(cacheDirectory, `${cacheKey}-${ICON_SIZE}.png`);
193 if (yield* existingFile(cachePath)) return cachePath;
194
195 yield* fileSystem.makeDirectory(cacheDirectory, { recursive: true });
apps/web/src/components/chat/MarkdownFileLink.tsx
+24 -17
@@ -7,6 +7,7 @@ import {
7 } from "@t3tools/client-runtime/state/runtime";
8 import type { ContextMenuSource, EnvironmentId, ScopedThreadRef } from "@t3tools/contracts";
9 import { memo, useState, type MouseEvent as ReactMouseEvent } from "react";
10 +import { FolderIcon } from "lucide-react";
11
12 import { contextMenuSourceOf } from "../../contextMenuSource";
13 import { readLocalApi } from "../../localApi";
@@ -24,7 +25,7 @@ import {
25 shouldUseMarkdownFileBrowserPrimaryAction,
26 } from "./MarkdownFileLink.logic";
27 import { reportMarkdownActionFailure } from "./markdownActionFailure";
27 -import { WorkspaceEntryIcon, WorkspaceEntryTooltip } from "./WorkspaceEntryIcon";
28 +import { WorkspaceEntryTooltip } from "./WorkspaceEntryIcon";
29
30 interface MarkdownFileLinkProps {
31 environmentId: EnvironmentId | null;
@@ -350,7 +351,7 @@ export const MarkdownFileLink = memo(function MarkdownFileLink({
351 <FileTagChipContent
352 icon={
353 isAppBundle ? (
353 - <AppBundleIcon environmentId={environmentId} path={iconPath} theme={theme} />
354 + <AppBundleIcon environmentId={environmentId} path={iconPath} />
355 ) : undefined
356 }
357 path={iconPath}
@@ -374,7 +375,7 @@ export const MarkdownFileLink = memo(function MarkdownFileLink({
375 <FileTagChipContent
376 icon={
377 isAppBundle ? (
377 - <AppBundleIcon environmentId={environmentId} path={iconPath} theme={theme} />
378 + <AppBundleIcon environmentId={environmentId} path={iconPath} />
379 ) : undefined
380 }
381 path={iconPath}
@@ -421,25 +422,31 @@ function areMarkdownFileLinkPropsEqual(
422 );
423 }
424
424 -function AppBundleIcon(props: {
425 - environmentId: EnvironmentId | null;
426 - path: string;
427 - theme: "light" | "dark";
428 -}) {
425 +function AppBundleIcon(props: { environmentId: EnvironmentId | null; path: string }) {
426 const asset = useAssetUrlState(props.environmentId, {
427 _tag: "native-app-icon",
428 app: { _tag: "app-path", path: props.path },
429 });
430 const [failedUrl, setFailedUrl] = useState<string | null>(null);
434 - if (asset._tag !== "Success" || asset.url === failedUrl) {
435 - return <WorkspaceEntryIcon {...props} />;
436 - }
431 + const [loadedUrl, setLoadedUrl] = useState<string | null>(null);
432 + const url = asset._tag === "Success" && asset.url !== failedUrl ? asset.url : null;
433 + const loaded = url !== null && loadedUrl === url;
434 return (
438 - <img
439 - src={asset.url}
440 - alt=""
441 - className="size-4 shrink-0 object-contain"
442 - onError={() => setFailedUrl(asset.url)}
443 - />
435 + <span
436 + data-app-bundle-icon=""
437 + aria-hidden="true"
438 + className="relative me-[0.2em] inline-block size-[1em] align-[calc((1cap-1em)/2)]"
439 + >
440 + <FolderIcon className={cn("size-full text-icon-muted", loaded && "invisible")} />
441 + {url !== null && (
442 + <img
443 + src={url}
444 + alt=""
445 + className={cn("absolute inset-0 size-full object-contain", !loaded && "invisible")}
446 + onLoad={() => setLoadedUrl(url)}
447 + onError={() => setFailedUrl(url)}
448 + />
449 + )}
450 + </span>
451 );
452 }