@devries-cameron20 / t3code-1 / commits / e6ced718a3
Fork 0

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

refactor(web): the command palette provider lookup keeps its caching without "use memo" (#20827)

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

Julius Marminge committed Oct 17, 2026 at 00:53 UTC e6ced718a3bb35c58986b12fb9f84624974104c2
1 file changed +17 -29
apps/web/src/components/CommandPalette.tsx
+17 -29
@@ -366,8 +366,9 @@ function notifyThemeSaveFailure(): void {
366 );
367 }
368
369 -// These run in their own hooks so the results stay cached across the palette's
370 -// later hook calls; the thread and project items key on them.
369 +// Kept as "use memo" hooks: inlined, each result reaches the dialog's returned
370 +// <CommandPaletteContent> through the action and thread item arrays built after
371 +// the browse hooks, and the compiler leaves all of them uncached.
372 function useThemeCards(
373 customThemes: ReturnType<typeof useCustomThemes>,
374 environmentThemes: ReturnType<typeof useEnvironmentThemeDefinitions>,
@@ -386,29 +387,6 @@ function useThemeCards(
387 ];
388 }
389
389 -function useProviderEntryMap(
390 - environments: ReturnType<typeof useEnvironments>["environments"],
391 - primaryEnvironmentId: ReturnType<typeof usePrimaryEnvironmentId>,
392 - providers: Parameters<typeof deriveProviderInstanceEntries>[0],
393 -) {
394 - "use memo";
395 - const map = new Map<string, ProviderInstanceEntry>();
396 - for (const environment of environments) {
397 - const serverConfig = environment.serverConfig;
398 - const environmentProviders =
399 - serverConfig?.providers ??
400 - (environment.environmentId === primaryEnvironmentId ? providers : []);
401 - const derived = deriveProviderInstanceEntries(environmentProviders);
402 - const entries = serverConfig
403 - ? applyProviderInstanceSettings(derived, serverConfig.settings, null)
404 - : derived;
405 - for (const entry of entries) {
406 - map.set(`${environment.environmentId}:${entry.instanceId}`, entry);
407 - }
408 - }
409 - return map;
410 -}
411 -
390 function useThreadContentMatchByKey(matches: ReturnType<typeof useThreadSearch>["matches"]) {
391 "use memo";
392 return new Map(
@@ -828,10 +806,20 @@ function OpenCommandPaletteDialog(props: {
806 const environmentThemes = useEnvironmentThemeDefinitions();
807 const themeCards = useThemeCards(customThemes, environmentThemes);
808 const providers = useAtomValue(primaryServerProvidersAtom);
831 - const providerEntryByEnvironmentAndInstanceId = useProviderEntryMap(
832 - environments,
833 - primaryEnvironmentId,
834 - providers,
809 + const providerEntryByEnvironmentAndInstanceId = new Map<string, ProviderInstanceEntry>(
810 + environments.flatMap((environment) => {
811 + const serverConfig = environment.serverConfig;
812 + const derived = deriveProviderInstanceEntries(
813 + serverConfig?.providers ??
814 + (environment.environmentId === primaryEnvironmentId ? providers : []),
815 + );
816 + const entries = serverConfig
817 + ? applyProviderInstanceSettings(derived, serverConfig.settings, null)
818 + : derived;
819 + return entries.map(
820 + (entry) => [`${environment.environmentId}:${entry.instanceId}`, entry] as const,
821 + );
822 + }),
823 );
824 const [viewStack, setViewStack] = useState<CommandPaletteView[]>([]);
825 const currentView = viewStack.at(-1) ?? null;