Skip to content

Commit 5ac8779

Browse files
goodnight000claude
andcommitted
feat(acp): local ACP commands can show their own icon
Local ACP commands always showed the generic ACP glyph: the driver sent no icon for them, the web client cleared any icon for local instances, and the icon components only accepted the Registry CDN. Add an "Icon file" setting for local commands. The server reads the SVG or PNG (absolute path, up to 8 KB) when the instance starts and sends it as a base64 data URL in the provider snapshot. Clients accept that data URL next to official Registry URLs, render it without the CDN fetch pipeline, and tint it like Registry icons. A missing, relative, oversized or unsupported file logs a warning and keeps the generic icon. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 54c5f25 commit 5ac8779

15 files changed

Lines changed: 241 additions & 18 deletions

File tree

‎apps/mobile/src/components/ProviderIcon.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
providerInstanceInitials,
88
} from "@t3tools/client-runtime/state/provider-instance-display";
99
import { useId, useState } from "react";
10-
import { resolveOfficialAcpRegistryIconUrl } from "@t3tools/contracts";
10+
import { resolveAcpRegistryIconUrl } from "@t3tools/contracts";
1111
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
1212
import { AppText as Text } from "./ui/AppText";
1313
import { getProviderClient } from "@t3tools/client-runtime/provider-clients";
@@ -34,7 +34,7 @@ function AcpRegistryProviderIcon(props: {
3434
readonly iconUrl: string | null | undefined;
3535
readonly size: number;
3636
}) {
37-
const iconUrl = resolveOfficialAcpRegistryIconUrl(props.iconUrl);
37+
const iconUrl = resolveAcpRegistryIconUrl(props.iconUrl);
3838
const [image, setImage] = useState<{
3939
readonly iconUrl: string;
4040
readonly status: "loaded" | "failed";

‎apps/web/src/components/chat/ProviderInstanceIcon.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { ProviderPackageIcon } from "./ProviderPackageIcon";
1515
import {
1616
AcpRegistryAgentIcon,
1717
officialAcpRegistryIconUrlForAgentId,
18-
resolveOfficialAcpRegistryIconUrl,
18+
resolveAcpRegistryIconUrl,
1919
} from "../settings/AcpRegistryIcon";
2020

2121
const PROVIDER_ICON_BY_PROVIDER: Partial<Record<ProviderDriverKind, Icon>> = {
@@ -52,7 +52,7 @@ export function resolveProviderInstanceAcpRegistryIconUrl(input: {
5252
}): string | null {
5353
if (input.driverKind !== "acpRegistry") return null;
5454
return (
55-
resolveOfficialAcpRegistryIconUrl(input.iconUrl ?? null) ??
55+
resolveAcpRegistryIconUrl(input.iconUrl ?? null) ??
5656
officialAcpRegistryIconUrlForAgentId(input.agentId?.trim() || null)
5757
);
5858
}

‎apps/web/src/components/settings/AcpRegistryIcon.tsx‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as Effect from "effect/Effect";
33
import { AsyncResult, Atom } from "effect/reactivity";
44
import { useId, useState } from "react";
55
import {
6+
resolveAcpRegistryIconUrl,
67
resolveOfficialAcpRegistryIconUrl,
78
officialAcpRegistryIconUrlForAgentId,
89
} from "@t3tools/contracts";
@@ -14,7 +15,11 @@ const ACP_REGISTRY_ICON_CACHE = "t3-acp-registry-icons-v1";
1415
const MAX_ICON_BYTES = 512 * 1_024;
1516
const inFlightIcons = new Map<string, Promise<Blob>>();
1617

17-
export { officialAcpRegistryIconUrlForAgentId, resolveOfficialAcpRegistryIconUrl };
18+
export {
19+
officialAcpRegistryIconUrlForAgentId,
20+
resolveAcpRegistryIconUrl,
21+
resolveOfficialAcpRegistryIconUrl,
22+
};
1823

1924
async function checkedIconBlob(response: Response): Promise<Blob> {
2025
if (!response.ok || response.redirected) throw new Error("ACP registry icon request failed.");
@@ -106,13 +111,19 @@ export function AcpRegistryAgentIcon({
106111
readonly fallbackClassName?: string;
107112
}) {
108113
const colorFilterId = useId();
109-
const iconUrl = resolveOfficialAcpRegistryIconUrl(icon);
110-
// Render only after the load pipeline resolves, so the fallback icon does
111-
// not flash a broken image.
112-
const source = AsyncResult.getOrElse(
113-
useAtomValue(iconUrl === null ? NO_ICON_SOURCE_ATOM : acpRegistryIconSourceAtom(iconUrl)),
114+
const iconUrl = resolveAcpRegistryIconUrl(icon);
115+
// An inline icon from a local file renders as-is; Registry icons go through the
116+
// load pipeline, and render only after it resolves so the fallback icon does not
117+
// flash a broken image.
118+
const inlineSource = iconUrl?.startsWith("data:") ? iconUrl : null;
119+
const registryIconUrl = inlineSource === null ? iconUrl : null;
120+
const loadedSource = AsyncResult.getOrElse(
121+
useAtomValue(
122+
registryIconUrl === null ? NO_ICON_SOURCE_ATOM : acpRegistryIconSourceAtom(registryIconUrl),
123+
),
114124
() => null,
115125
);
126+
const source = inlineSource ?? loadedSource;
116127
const [image, setImage] = useState<{
117128
readonly source: string;
118129
readonly status: "loaded" | "failed";

‎apps/web/src/components/settings/ProviderInstanceCard.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,9 @@ export function ProviderInstanceCard({
875875
}
876876
acpRegistryIconUrl={
877877
readConfigString(instance.config, "source") === "local"
878-
? undefined
878+
? liveProvider?.iconUrl?.startsWith("data:")
879+
? liveProvider.iconUrl
880+
: undefined
879881
: (readConfigString(instance.config, "registryIconUrl") ?? undefined)
880882
}
881883
showBadge={Boolean(accentColor)}

‎apps/web/src/components/settings/ProviderSettingsForm.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ describe("ProviderSettingsForm helpers", () => {
3434
]);
3535
});
3636

37+
it("offers an icon file only for local ACP commands", () => {
38+
const acp = providerClients.get(ProviderDriverKind.make("acpRegistry"));
39+
expect(acp).toBeDefined();
40+
const keys = (source: string) =>
41+
deriveProviderSettingsFields(acp!, { source }).map(({ key }) => key);
42+
43+
expect(keys("local")).toEqual(["source", "commandPath", "iconPath"]);
44+
expect(keys("registry")).not.toContain("iconPath");
45+
});
46+
3747
it("preserves unknown config keys while omitting empty configurable fields", () => {
3848
const opencode = providerClients.get(ProviderDriverKind.make("opencode"));
3949
expect(opencode).toBeDefined();

‎apps/web/src/components/settings/ProviderSettingsForm.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ export function deriveProviderSettingsFields(
114114
const fieldSchema = definition.settingsSchema.fields[key]!;
115115
const formAnnotation = readProviderSettingsFormAnnotation(fieldSchema);
116116
if (formAnnotation.hidden) return [];
117-
if (isLocalAcp && key !== "source" && key !== "commandPath") return [];
117+
if (isLocalAcp && key !== "source" && key !== "commandPath" && key !== "iconPath") return [];
118+
if (!isLocalAcp && key === "iconPath") return [];
118119

119120
const annotatedTitle = readFieldAnnotationString(fieldSchema, "title");
120121
const annotatedDescription = readFieldAnnotationString(fieldSchema, "description");

‎apps/web/src/providerInstances.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,4 +563,25 @@ describe("provider icon metadata", () => {
563563
expect(restoredEntry?.acpRegistryIconUrl).toBe(iconUrl);
564564
expect(restoredEntry?.enabled).toBe(true);
565565
});
566+
567+
it("keeps a local command's icon file", () => {
568+
const instanceId = ProviderInstanceId.make("steed");
569+
const driver = ProviderDriverKind.make("acpRegistry");
570+
const iconUrl = "data:image/svg+xml;base64,PHN2Zz48L3N2Zz4=";
571+
const [entry] = applyProviderInstanceSettings(
572+
deriveProviderInstanceEntries([{ ...provider({ provider: driver, instanceId }), iconUrl }]),
573+
{
574+
providerInstances: {
575+
[instanceId]: {
576+
driver,
577+
enabled: true,
578+
config: { source: "local", commandPath: "steed-acp", iconPath: "/icons/steed.svg" },
579+
},
580+
},
581+
projectSettingsOverrides: {},
582+
},
583+
null,
584+
);
585+
expect(entry?.acpRegistryIconUrl).toBe(iconUrl);
586+
});
566587
});

‎apps/web/src/providerInstances.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ function applyProviderInstanceBranding(
133133
? (explicitInstance.config as Readonly<Record<string, unknown>>)
134134
: null;
135135
if (config?.source === "local") {
136-
return { ...entry, acpRegistryAgentId: undefined, acpRegistryIconUrl: undefined };
136+
// Drop stale Registry branding; keep only the inline icon from the instance's icon file.
137+
const iconFileUrl = entry.snapshot.iconUrl?.startsWith("data:")
138+
? entry.snapshot.iconUrl
139+
: undefined;
140+
return { ...entry, acpRegistryAgentId: undefined, acpRegistryIconUrl: iconFileUrl };
137141
}
138142
const agentId = config?.agentId;
139143
const iconUrl = config?.registryIconUrl;

‎docs/user/providers-acp.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ credentials and skills remain managed by the installed agent or its wrapper. Mod
3939
options come from ACP, including model IDs that contain JSON. T3 Code launches the executable directly
4040
without expanding shell expressions.
4141

42+
Local commands show a generic ACP icon. To use the agent's own logo, set **Icon file** in the
43+
provider's settings to the absolute path of an SVG or PNG (up to 8 KB) on the same environment.
44+
T3 Code tints it to match the theme, like Registry icons, and reads the file when the provider
45+
starts, so save the provider settings again after replacing the file.
46+
4247
## Where agents run
4348

4449
Registry agents always run on the machine that hosts your T3 Code server. That stays true when you

‎packages/contracts/src/acpRegistry.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import { describe, expect, it } from "@effect/vitest";
22
import * as Schema from "effect/Schema";
33

44
import {
5+
ACP_REGISTRY_ICON_URL_MAX_LENGTH,
56
AcpRegistryManagedBinaryUninstallInput,
67
AcpRegistryManagedBinaryUninstallResult,
78
officialAcpRegistryIconUrlForAgentId,
9+
resolveAcpRegistryIconUrl,
810
resolveOfficialAcpRegistryIconUrl,
911
} from "./acpRegistry.ts";
1012

@@ -34,6 +36,25 @@ describe("ACP Registry contracts", () => {
3436
).toBeNull();
3537
});
3638

39+
it("accepts small inline SVG and PNG icons alongside official Registry URLs", () => {
40+
const svg = "data:image/svg+xml;base64,PHN2Zz48L3N2Zz4=";
41+
expect(resolveAcpRegistryIconUrl(svg)).toBe(svg);
42+
expect(resolveAcpRegistryIconUrl("data:image/png;base64,iVBORw0KGgo=")).toBe(
43+
"data:image/png;base64,iVBORw0KGgo=",
44+
);
45+
expect(
46+
resolveAcpRegistryIconUrl("https://cdn.agentclientprotocol.com/registry/v1/latest/pi.svg"),
47+
).toBe("https://cdn.agentclientprotocol.com/registry/v1/latest/pi.svg");
48+
expect(resolveAcpRegistryIconUrl("data:text/html;base64,PGgxPg==")).toBeNull();
49+
expect(resolveAcpRegistryIconUrl("data:image/svg+xml,<svg></svg>")).toBeNull();
50+
expect(resolveAcpRegistryIconUrl("https://example.com/icon.svg")).toBeNull();
51+
expect(
52+
resolveAcpRegistryIconUrl(
53+
`data:image/svg+xml;base64,${"A".repeat(ACP_REGISTRY_ICON_URL_MAX_LENGTH)}`,
54+
),
55+
).toBeNull();
56+
});
57+
3758
it("decodes managed binary uninstall payloads and rejects unsafe agent IDs", () => {
3859
expect(decodeUninstallInput({ agentId: " example-agent " })).toEqual({
3960
agentId: "example-agent",

0 commit comments

Comments
 (0)