@devries-cameron20 / t3code Mirror · read-only / commits / c40b32a729
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 22, 12:00 UTC

fix(web): keep ACP agent logos in multi-model selections (#23448)

Co-authored-by: GPT-6.1 Sol <noreply@openai.com>

Victor Vogel committed Oct 30, 2026 at 15:49 UTC c40b32a729dcf21eb14aa9dcb140bf978303f9b1
2 files changed +92
apps/web/src/components/chat/ProviderModelPicker.browser.test.tsx new
+90
@@ -0,0 +1,90 @@
1 +import { ProviderDriverKind, ProviderInstanceId, type ModelSelection } from "@t3tools/contracts";
2 +import { useState } from "react";
3 +import { expect, it, vi } from "vite-plus/test";
4 +import { page, userEvent } from "vite-plus/test/browser";
5 +
6 +import "~/index.css";
7 +
8 +import { render } from "../../../test/render";
9 +import { deriveProviderInstanceEntries } from "../../providerInstances";
10 +import { ProviderModelPicker } from "./ProviderModelPicker";
11 +
12 +it("keeps each registry image when adding a model from another ACP agent", async () => {
13 + const icons = [
14 + "https://cdn.agentclientprotocol.com/registry/icons/picker-explicit.svg",
15 + "https://cdn.agentclientprotocol.com/registry/v1/latest/picker-by-id.svg",
16 + ];
17 + const cache = await caches.open("t3-acp-registry-icons-v1");
18 + await using _cachedIcons = {
19 + async [Symbol.asyncDispose]() {
20 + await Promise.all(icons.map((url) => cache.delete(url)));
21 + },
22 + };
23 + for (const [index, url] of icons.entries()) {
24 + await cache.put(
25 + url,
26 + new Response(
27 + `<svg xmlns="http://www.w3.org/2000/svg" width="${11 + index * 6}" height="10"><path d="M0 0h10v10H0z"/></svg>`,
28 + { headers: { "content-type": "image/svg+xml" } },
29 + ),
30 + );
31 + }
32 + const entries = deriveProviderInstanceEntries(
33 + ["First", "Second"].map((name) => ({
34 + instanceId: ProviderInstanceId.make(name.toLowerCase()),
35 + driver: ProviderDriverKind.make("acpRegistry"),
36 + displayName: `${name} agent`,
37 + enabled: true,
38 + installed: true,
39 + version: null,
40 + status: "ready" as const,
41 + auth: { status: "authenticated" as const },
42 + checkedAt: "2026-01-01T00:00:00.000Z",
43 + models: [
44 + { slug: name.toLowerCase(), name: `${name} model`, isCustom: false, capabilities: {} },
45 + ],
46 + slashCommands: [],
47 + skills: [],
48 + })),
49 + ).map((entry, index) => ({
50 + ...entry,
51 + ...(index === 0 ? { acpRegistryIconUrl: icons[0] } : { acpRegistryAgentId: "picker-by-id" }),
52 + }));
53 + const first = { instanceId: entries[0]!.instanceId, model: "first" };
54 + const options = new Map(entries.map((entry) => [entry.instanceId, entry.models]));
55 +
56 + function Picker() {
57 + const [selection, setSelection] = useState<ReadonlyArray<ModelSelection>>([first]);
58 + return (
59 + <ProviderModelPicker
60 + environmentId={null}
61 + activeInstanceId={first.instanceId}
62 + model={first.model}
63 + {...(selection.length > 1 ? { selectedModels: selection } : {})}
64 + lockedProvider={null}
65 + instanceEntries={entries}
66 + modelOptionsByInstance={options}
67 + onToggleModel={(instanceId, model) => setSelection([...selection, { instanceId, model }])}
68 + onInstanceModelChange={(instanceId, model) => setSelection([{ instanceId, model }])}
69 + />
70 + );
71 + }
72 +
73 + await using screen = await render(<Picker />);
74 + const imageWidths = () =>
75 + Array.from(
76 + screen.container.querySelectorAll<HTMLImageElement>("[data-chat-provider-model-picker] img"),
77 + (image) => image.naturalWidth,
78 + );
79 + await vi.waitFor(() => expect(imageWidths()).toEqual([11]));
80 + await screen.getByRole("button", { name: "First model", exact: true }).click();
81 + await page.getByRole("button", { name: "Second agent", exact: true }).click();
82 + await userEvent.keyboard("{Shift>}");
83 + try {
84 + await page.getByRole("option", { name: /Second model/ }).click();
85 + } finally {
86 + await userEvent.keyboard("{/Shift}");
87 + }
88 + await userEvent.keyboard("{Escape}");
89 + await vi.waitFor(() => expect(imageWidths()).toEqual([11, 17]));
90 +});
apps/web/src/components/chat/ProviderModelPicker.tsx
+2
@@ -221,6 +221,8 @@ export const ProviderModelPicker = memo(function ProviderModelPicker(props: {
221 driverKind={selection.entry.driverKind}
222 displayName={selection.entry.displayName}
223 accentColor={selection.entry.accentColor}
224 + acpRegistryAgentId={selection.entry.acpRegistryAgentId}
225 + acpRegistryIconUrl={selection.entry.acpRegistryIconUrl}
226 className="size-4 rounded-full bg-(--chat-composer-glass-surface,var(--background)) ring-2 ring-(--chat-composer-glass-surface,var(--background))"
227 iconClassName="size-4"
228 />