The best way to control Claude Code, Codex and more from any computer or phone
refactor(shared): test favicon selection through public API (#10005)
Julius Marminge committed
Sep 5, 2026 at 00:28 UTC
3e544f8cda371dc565c806508a9ab38b80c96ff7
2 files changed
+18
-13
packages/shared/src/favicon.test.ts
+16
-11
@@ -1,11 +1,6 @@
1
import { describe, expect, it } from "@effect/vitest";
2
3
-import {
4
- explicitFaviconUrl,
5
- faviconUrlForOrigin,
6
- faviconUrlForPage,
7
- toolActivityFaviconUrl,
8
-} from "./favicon.ts";
3
+import { faviconUrlForOrigin, toolActivityFaviconUrl } from "./favicon.ts";
4
5
describe("faviconUrlForOrigin", () => {
6
it.each([
@@ -46,12 +41,12 @@ describe("faviconUrlForOrigin", () => {
41
);
42
});
43
49
-describe("faviconUrlForPage", () => {
44
+describe("toolActivityFaviconUrl", () => {
45
it("uses the page origin instead of a third-party favicon service", () => {
51
- expect(faviconUrlForPage("https://example.com/docs/page?q=1")).toBe(
46
+ expect(toolActivityFaviconUrl({ pageUrl: "https://example.com/docs/page?q=1" }, "light")).toBe(
47
"https://example.com/favicon.ico",
48
);
54
- expect(faviconUrlForPage("http://localhost:5173/app")).toBe(
49
+ expect(toolActivityFaviconUrl({ pageUrl: "http://localhost:5173/app" }, "light")).toBe(
50
"http://localhost:5173/favicon.ico",
51
);
52
});
@@ -86,7 +81,17 @@ describe("faviconUrlForPage", () => {
81
});
82
83
it("accepts provider-supplied image URLs but rejects extension URLs", () => {
89
- expect(explicitFaviconUrl("https://example.com/icon.png")).toBe("https://example.com/icon.png");
90
- expect(explicitFaviconUrl("chrome-extension://example/_favicon/")).toBeNull();
84
+ expect(
85
+ toolActivityFaviconUrl(
86
+ { pageUrl: "https://example.com/docs", faviconUrl: "https://example.com/icon.png" },
87
+ "light",
88
+ ),
89
+ ).toBe("https://example.com/icon.png");
90
+ expect(
91
+ toolActivityFaviconUrl(
92
+ { pageUrl: "https://example.com/docs", faviconUrl: "chrome-extension://example/_favicon/" },
93
+ "light",
94
+ ),
95
+ ).toBe("https://example.com/favicon.ico");
96
});
97
});
packages/shared/src/favicon.ts
+2
-2
@@ -5,7 +5,7 @@ import { isPublicFaviconHost } from "./hostClassification.ts";
5
* conventional favicon and let the image element fall back to a browser glyph.
6
* Chrome-backed tools can pass their tab's explicit favicon URL separately.
7
*/
8
-export function faviconUrlForPage(rawUrl: string | null | undefined, _size = 32): string | null {
8
+function faviconUrlForPage(rawUrl: string | null | undefined, _size = 32): string | null {
9
if (!rawUrl || rawUrl.length > 4096) return null;
10
try {
11
const pageUrl = new URL(rawUrl);
@@ -40,7 +40,7 @@ function themedFaviconUrlForPage(
40
}
41
42
/** Accepts image URLs supplied by a trusted provider event. */
43
-export function explicitFaviconUrl(rawUrl: string | null | undefined): string | null {
43
+function explicitFaviconUrl(rawUrl: string | null | undefined): string | null {
44
if (!rawUrl || rawUrl.length > 4096) return null;
45
try {
46
const url = new URL(rawUrl);