@devries-cameron20 / t3code-1 / commits / 1994d6396f
Fork 0

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

perf(web): typing in the ACP registry search no longer re-renders every result row (#20817)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 17, 2026 at 02:01 UTC 1994d6396fda6ce6edff03c57b0757edf5e03b28
2 files changed +94 -68
apps/web/src/components/settings/AcpRegistrySearchStep.test.tsx
+16 -2
@@ -1,4 +1,4 @@
1 -import type { ReactElement } from "react";
1 +import { isValidElement, type ReactElement } from "react";
2 import { EnvironmentId, ProviderDriverKind, type AcpRegistrySearchAgent } from "@t3tools/contracts";
3 import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
4
@@ -118,11 +118,25 @@ function findByAriaLabel(
118 tree: ReactElement<Record<string, unknown>>,
119 label: string,
120 ): ReactElement<Record<string, unknown>> {
121 - const found = visitElements(tree, (element) => element.props["aria-label"] === label);
121 + const found = visitElements(expandRows(tree), (element) => element.props["aria-label"] === label);
122 expect(found).not.toBeNull();
123 return found!;
124 }
125
126 +// The harness calls components as plain functions, so result rows stay
127 +// unexpanded elements until rendered here.
128 +function expandRows(node: unknown): unknown {
129 + if (Array.isArray(node)) return node.map(expandRows);
130 + if (!isValidElement<Record<string, unknown>>(node)) return node;
131 + if (typeof node.type === "function" && node.type.name === "AcpRegistryAgentRow") {
132 + return expandRows((node.type as (props: unknown) => unknown)(node.props));
133 + }
134 + const props = Object.fromEntries(
135 + Object.entries(node.props).map(([key, value]) => [key, expandRows(value)]),
136 + );
137 + return { ...node, props };
138 +}
139 +
140 describe("AcpRegistrySearchStep", () => {
141 beforeEach(() => {
142 state.canManage = true;
apps/web/src/components/settings/AcpRegistrySearchStep.tsx
+78 -66
@@ -217,72 +217,16 @@ export function AcpRegistrySearchStep({
217 ) : (
218 <ScrollArea scrollFade className="max-h-64">
219 <div className="pr-2.5">
220 - {results.map((agent) => {
221 - const alreadyAdded = isConfiguredAcpRegistryAgent(providerInstances, agent.id);
222 - const isPreparing = preparingId === agent.id;
223 - const progressLabel = agent.distribution === "binary" ? "Downloading" : "Preparing";
224 - return (
225 - <article className="min-w-0 py-2.5" key={agent.id}>
226 - <div className="flex min-w-0 items-center justify-between gap-3">
227 - <div className="flex min-w-0 flex-1 items-center gap-3">
228 - <ProviderInstanceIcon
229 - driverKind={ProviderDriverKind.make("acpRegistry")}
230 - displayName={agent.name}
231 - acpRegistryAgentId={agent.id}
232 - acpRegistryIconUrl={agent.icon ?? undefined}
233 - iconClassName="size-6 rounded-md text-muted-foreground"
234 - />
235 - <div className="min-w-0 flex-1">
236 - <div className="flex min-w-0 items-baseline gap-2">
237 - <h4 className="min-w-0 truncate text-sm font-medium text-foreground">
238 - {agent.name}
239 - </h4>
240 - </div>
241 - {agent.description ? (
242 - <p className="mt-0.5 truncate text-xs text-muted-foreground">
243 - {agent.description}
244 - </p>
245 - ) : null}
246 - </div>
247 - </div>
248 - <div className="flex shrink-0 items-center gap-1.5">
249 - {agent.website || agent.repository ? (
250 - <Tooltip>
251 - <TooltipTrigger
252 - render={
253 - <Button
254 - size="icon-xs"
255 - variant="ghost-muted"
256 - aria-label={`About ${agent.name}`}
257 - render={
258 - <a
259 - href={agent.website || agent.repository || undefined}
260 - target="_blank"
261 - rel="noreferrer"
262 - />
263 - }
264 - >
265 - <ExternalLinkIcon />
266 - </Button>
267 - }
268 - />
269 - <TooltipPopup>About {agent.name}</TooltipPopup>
270 - </Tooltip>
271 - ) : null}
272 - <Button
273 - aria-label={`${alreadyAdded ? "Already added" : isPreparing ? progressLabel : "Add"} ${agent.name}`}
274 - disabled={!canManageProviders || alreadyAdded || preparingId !== null}
275 - onClick={() => void handlePrepare(agent)}
276 - size="xs"
277 - variant={isPreparing ? "secondary" : "outline"}
278 - >
279 - {alreadyAdded ? "Added" : isPreparing ? progressLabel : "Add"}
280 - </Button>
281 - </div>
282 - </div>
283 - </article>
284 - );
285 - })}
220 + {results.map((agent) => (
221 + <AcpRegistryAgentRow
222 + agent={agent}
223 + alreadyAdded={isConfiguredAcpRegistryAgent(providerInstances, agent.id)}
224 + canAdd={canManageProviders && preparingId === null}
225 + isPreparing={preparingId === agent.id}
226 + key={agent.id}
227 + onAdd={handlePrepare}
228 + />
229 + ))}
230 </div>
231 </ScrollArea>
232 )
@@ -290,3 +234,71 @@ export function AcpRegistrySearchStep({
234 </section>
235 );
236 }
237 +
238 +function AcpRegistryAgentRow({
239 + agent,
240 + alreadyAdded,
241 + canAdd,
242 + isPreparing,
243 + onAdd,
244 +}: {
245 + readonly agent: AcpRegistrySearchAgent;
246 + readonly alreadyAdded: boolean;
247 + readonly canAdd: boolean;
248 + readonly isPreparing: boolean;
249 + readonly onAdd: (agent: AcpRegistrySearchAgent) => void;
250 +}) {
251 + const progressLabel = agent.distribution === "binary" ? "Downloading" : "Preparing";
252 + const aboutUrl = agent.website || agent.repository;
253 + return (
254 + <article className="min-w-0 py-2.5">
255 + <div className="flex min-w-0 items-center justify-between gap-3">
256 + <div className="flex min-w-0 flex-1 items-center gap-3">
257 + <ProviderInstanceIcon
258 + driverKind={ProviderDriverKind.make("acpRegistry")}
259 + displayName={agent.name}
260 + acpRegistryAgentId={agent.id}
261 + acpRegistryIconUrl={agent.icon ?? undefined}
262 + iconClassName="size-6 rounded-md text-muted-foreground"
263 + />
264 + <div className="min-w-0 flex-1">
265 + <div className="flex min-w-0 items-baseline gap-2">
266 + <h4 className="min-w-0 truncate text-sm font-medium text-foreground">{agent.name}</h4>
267 + </div>
268 + {agent.description ? (
269 + <p className="mt-0.5 truncate text-xs text-muted-foreground">{agent.description}</p>
270 + ) : null}
271 + </div>
272 + </div>
273 + <div className="flex shrink-0 items-center gap-1.5">
274 + {aboutUrl ? (
275 + <Tooltip>
276 + <TooltipTrigger
277 + render={
278 + <Button
279 + size="icon-xs"
280 + variant="ghost-muted"
281 + aria-label={`About ${agent.name}`}
282 + render={<a href={aboutUrl} target="_blank" rel="noreferrer" />}
283 + >
284 + <ExternalLinkIcon />
285 + </Button>
286 + }
287 + />
288 + <TooltipPopup>About {agent.name}</TooltipPopup>
289 + </Tooltip>
290 + ) : null}
291 + <Button
292 + aria-label={`${alreadyAdded ? "Already added" : isPreparing ? progressLabel : "Add"} ${agent.name}`}
293 + disabled={!canAdd || alreadyAdded}
294 + onClick={() => onAdd(agent)}
295 + size="xs"
296 + variant={isPreparing ? "secondary" : "outline"}
297 + >
298 + {alreadyAdded ? "Added" : isPreparing ? progressLabel : "Add"}
299 + </Button>
300 + </div>
301 + </div>
302 + </article>
303 + );
304 +}