From 50ca7baf2d12c6f4d0deb2eb38e49ec3516b9926 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 15 Jul 2026 22:58:54 +0000 Subject: [PATCH] Centralize on preload naming for lazy component loading Reverts the earlier preload->prefetch rename of the LazyComponent API and aligns the new route map and hover preloading with the existing preload terminology instead. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01W45zR5AhPpLURRoDQUsAgX --- app/components/Collection/CollectionForm.tsx | 4 +- app/components/LazyLoad.ts | 8 ++-- app/components/Reactions/ReactionPicker.tsx | 2 +- app/components/Sidebar/Settings.tsx | 2 +- .../Sidebar/components/SidebarLink.tsx | 8 ++-- app/hooks/useSettingsConfig.ts | 42 +++++++++---------- app/routes/map.ts | 12 +++--- app/routes/{prefetch.ts => preload.ts} | 8 ++-- 8 files changed, 43 insertions(+), 43 deletions(-) rename app/routes/{prefetch.ts => preload.ts} (79%) diff --git a/app/components/Collection/CollectionForm.tsx b/app/components/Collection/CollectionForm.tsx index 5de15159f0..124d050d53 100644 --- a/app/components/Collection/CollectionForm.tsx +++ b/app/components/Collection/CollectionForm.tsx @@ -121,9 +121,9 @@ export const CollectionForm = observer(function CollectionForm_({ const values = watch(); - // Prefetch the IconPicker component on mount + // Preload the IconPicker component on mount useEffect(() => { - void IconPicker.prefetch(); + void IconPicker.preload(); }, []); useEffect(() => { diff --git a/app/components/LazyLoad.ts b/app/components/LazyLoad.ts index c460d762f0..5edf87559a 100644 --- a/app/components/LazyLoad.ts +++ b/app/components/LazyLoad.ts @@ -4,7 +4,7 @@ import lazyWithRetry from "~/utils/lazyWithRetry"; // oxlint-disable no-explicit-any -- ComponentType is the standard React pattern for generic component constraints export interface LazyComponent> { Component: React.LazyExoticComponent; - prefetch: () => Promise<{ default: T }>; + preload: () => Promise<{ default: T }>; } interface LazyLoadOptions { @@ -15,12 +15,12 @@ interface LazyLoadOptions { } /** - * Creates a lazy-loaded component with prefetching capability and automatic retries on failure. + * Creates a lazy-loaded component with preloading capability and automatic retries on failure. * Supports both default and named exports. * * @param factory A function that returns a promise of a module. * @param options Optional configuration for retry behavior and export name. - * @returns An object containing the lazy Component and a prefetch function. + * @returns An object containing the lazy Component and a preload function. * * @example * ```typescript @@ -48,6 +48,6 @@ export function createLazyComponent>( return { Component: lazyWithRetry(wrappedFactory, retries, interval), - prefetch: wrappedFactory, + preload: wrappedFactory, }; } diff --git a/app/components/Reactions/ReactionPicker.tsx b/app/components/Reactions/ReactionPicker.tsx index c7171a34a8..af0f87b881 100644 --- a/app/components/Reactions/ReactionPicker.tsx +++ b/app/components/Reactions/ReactionPicker.tsx @@ -56,7 +56,7 @@ const ReactionPicker: React.FC = ({ onSelect, className, size }) => { EmojiPanel.prefetch()} + onMouseEnter={() => EmojiPanel.preload()} onClick={(e) => e.stopPropagation()} size={size} > diff --git a/app/components/Sidebar/Settings.tsx b/app/components/Sidebar/Settings.tsx index 2f3f282723..3b993e93dd 100644 --- a/app/components/Sidebar/Settings.tsx +++ b/app/components/Sidebar/Settings.tsx @@ -56,7 +56,7 @@ function SettingsSidebar() { ) => { onClickIntent?.(ev); - // In addition to any data prefetch, warm the code-split chunks for the - // route the link points to. + // In addition to any data prefetch, preload the code-split chunks for + // the route the link points to. if (to) { - prefetchRouteComponents(to); + preloadRouteComponents(to); } }, [onClickIntent, to] diff --git a/app/hooks/useSettingsConfig.ts b/app/hooks/useSettingsConfig.ts index e704a0b124..ef33844015 100644 --- a/app/hooks/useSettingsConfig.ts +++ b/app/hooks/useSettingsConfig.ts @@ -60,7 +60,7 @@ export type ConfigItem = { }>; component: React.ComponentType; description?: string; - prefetch?: () => void; + preload?: () => void; enabled: boolean; group: string; pluginId?: string; @@ -84,7 +84,7 @@ const useSettingsConfig = () => { name: t("Profile"), path: settingsPath(), component: Profile.Component, - prefetch: Profile.prefetch, + preload: Profile.preload, enabled: true, group: t("Account"), icon: ProfileIcon, @@ -93,7 +93,7 @@ const useSettingsConfig = () => { name: t("Preferences"), path: settingsPath("preferences"), component: Preferences.Component, - prefetch: Preferences.prefetch, + preload: Preferences.preload, enabled: true, group: t("Account"), icon: SettingsIcon, @@ -102,7 +102,7 @@ const useSettingsConfig = () => { name: t("Notifications"), path: settingsPath("notifications"), component: Notifications.Component, - prefetch: Notifications.prefetch, + preload: Notifications.preload, enabled: true, group: t("Account"), icon: EmailIcon, @@ -111,7 +111,7 @@ const useSettingsConfig = () => { name: t("API & Access"), path: settingsPath("api-and-access"), component: APIAndAccess.Component, - prefetch: APIAndAccess.prefetch, + preload: APIAndAccess.preload, enabled: true, group: t("Account"), icon: PadlockIcon, @@ -121,7 +121,7 @@ const useSettingsConfig = () => { name: t("Details"), path: settingsPath("details"), component: Details.Component, - prefetch: Details.prefetch, + preload: Details.preload, enabled: can.update, group: t("Workspace"), icon: TeamIcon, @@ -130,7 +130,7 @@ const useSettingsConfig = () => { name: t("Authentication"), path: settingsPath("authentication"), component: Authentication.Component, - prefetch: Authentication.prefetch, + preload: Authentication.preload, enabled: can.update, group: t("Workspace"), icon: PadlockIcon, @@ -139,7 +139,7 @@ const useSettingsConfig = () => { name: t("Security"), path: settingsPath("security"), component: Security.Component, - prefetch: Security.prefetch, + preload: Security.preload, enabled: can.update, group: t("Workspace"), icon: ShieldIcon, @@ -148,7 +148,7 @@ const useSettingsConfig = () => { name: t("AI"), path: settingsPath("features"), component: Features.Component, - prefetch: Features.prefetch, + preload: Features.preload, enabled: can.update, group: t("Workspace"), icon: SparklesIcon, @@ -157,7 +157,7 @@ const useSettingsConfig = () => { name: t("Members"), path: settingsPath("members"), component: Members.Component, - prefetch: Members.prefetch, + preload: Members.preload, enabled: can.listUsers, group: t("Workspace"), icon: UserIcon, @@ -166,7 +166,7 @@ const useSettingsConfig = () => { name: t("Groups"), path: settingsPath("groups"), component: Groups.Component, - prefetch: Groups.prefetch, + preload: Groups.preload, enabled: can.listGroups, group: t("Workspace"), icon: GroupIcon, @@ -175,7 +175,7 @@ const useSettingsConfig = () => { name: t("Templates"), path: settingsPath("templates"), component: Templates.Component, - prefetch: Templates.prefetch, + preload: Templates.preload, enabled: can.readTemplate, group: t("Workspace"), icon: ShapesIcon, @@ -184,7 +184,7 @@ const useSettingsConfig = () => { name: t("Emojis"), path: settingsPath("emojis"), component: CustomEmojis.Component, - prefetch: CustomEmojis.prefetch, + preload: CustomEmojis.preload, enabled: can.update, group: t("Workspace"), icon: SmileyIcon, @@ -193,7 +193,7 @@ const useSettingsConfig = () => { name: t("API Keys"), path: settingsPath("api-keys"), component: ApiKeys.Component, - prefetch: ApiKeys.prefetch, + preload: ApiKeys.preload, enabled: can.listApiKeys, group: t("Workspace"), icon: CodeIcon, @@ -202,7 +202,7 @@ const useSettingsConfig = () => { name: t("Applications"), path: settingsPath("applications"), component: Applications.Component, - prefetch: Applications.prefetch, + preload: Applications.preload, enabled: can.listOAuthClients, group: t("Workspace"), icon: InternetIcon, @@ -211,7 +211,7 @@ const useSettingsConfig = () => { name: t("Shared Links"), path: settingsPath("shares"), component: Shares.Component, - prefetch: Shares.prefetch, + preload: Shares.preload, enabled: can.listShares, group: t("Workspace"), icon: GlobeIcon, @@ -220,7 +220,7 @@ const useSettingsConfig = () => { name: t("Import"), path: settingsPath("import"), component: Import.Component, - prefetch: Import.prefetch, + preload: Import.preload, enabled: can.createImport, group: t("Workspace"), icon: ImportIcon, @@ -229,7 +229,7 @@ const useSettingsConfig = () => { name: t("Export"), path: settingsPath("export"), component: Export.Component, - prefetch: Export.prefetch, + preload: Export.preload, enabled: can.createExport, group: t("Workspace"), icon: ExportIcon, @@ -239,7 +239,7 @@ const useSettingsConfig = () => { name: t("Embeds"), path: integrationSettingsPath("embeds"), component: Embeds.Component, - prefetch: Embeds.prefetch, + preload: Embeds.preload, description: t( "Configure which embed providers are available in the editor." ), @@ -251,7 +251,7 @@ const useSettingsConfig = () => { name: `${t("Install")}…`, path: settingsPath("integrations"), component: Integrations.Component, - prefetch: Integrations.prefetch, + preload: Integrations.preload, enabled: can.update, group: t("Integrations"), icon: PlusIcon, @@ -274,7 +274,7 @@ const useSettingsConfig = () => { pluginId: plugin.id, description: plugin.value.description, component: plugin.value.component.Component, - prefetch: plugin.value.component.prefetch, + preload: plugin.value.component.preload, enabled: plugin.value.enabled ? plugin.value.enabled(team, user) : can.update, diff --git a/app/routes/map.ts b/app/routes/map.ts index 83c506a8a4..6d13f535e8 100644 --- a/app/routes/map.ts +++ b/app/routes/map.ts @@ -18,7 +18,7 @@ import { /** * A lazy-loaded route in the application, pairing the path patterns it - * renders at with the code-split component and a way to prefetch it. + * renders at with the code-split component and a way to preload it. */ export interface RouteMapEntry { /** Patterns, in react-router syntax, matching the locations the scene renders at. */ @@ -26,17 +26,17 @@ export interface RouteMapEntry { /** The lazy-loaded component rendered for the route. */ Component: React.LazyExoticComponent>; /** Imports the code-split chunk(s) for the route ahead of render. */ - prefetch: () => Promise; + preload: () => Promise; } /** * The single source of truth for lazy-loaded routes that are reachable * through in-app navigation. Route definitions (see `./index` and * `./authenticated`) render `Component` at `paths`, and hovering a link is - * used as a signal to call `prefetch` (see `./prefetch`) so the code is + * used as a signal to call `preload` (see `./preload`) so the code is * already available when the user navigates. * - * Note: Prefetch matching checks entries in order and patterns are matched + * Note: Preload matching checks entries in order and patterns are matched * non-exactly, so list more specific routes before routes they share a * prefix with. */ @@ -64,10 +64,10 @@ function defineRoute( paths: string | string[], load: () => Promise<{ default: React.ComponentType }> ): RouteMapEntry { - const { Component, prefetch } = createLazyComponent(load); + const { Component, preload } = createLazyComponent(load); return { paths: Array.isArray(paths) ? paths : [paths], Component, - prefetch, + preload, }; } diff --git a/app/routes/prefetch.ts b/app/routes/preload.ts similarity index 79% rename from app/routes/prefetch.ts rename to app/routes/preload.ts index cf3a58058a..03976f83aa 100644 --- a/app/routes/prefetch.ts +++ b/app/routes/preload.ts @@ -4,7 +4,7 @@ import env from "~/env"; import { routeMap } from "./map"; /** - * Prefetches the lazy-loaded components associated with the route that the + * Preloads the lazy-loaded components associated with the route that the * given location resolves to, so the code is already available by the time * the user navigates there. * @@ -13,7 +13,7 @@ import { routeMap } from "./map"; * * @param to the location the user is expected to navigate to. */ -export function prefetchRouteComponents(to: LocationDescriptor): void { +export function preloadRouteComponents(to: LocationDescriptor): void { const path = typeof to === "string" ? to : to.pathname; if (!path) { return; @@ -28,7 +28,7 @@ export function prefetchRouteComponents(to: LocationDescriptor): void { paths.some((pattern) => matchPath(pathname, { path: pattern })) ); - void route?.prefetch().catch(() => { - // Prefetching is best effort. + void route?.preload().catch(() => { + // Preloading is best effort. }); }