From 6963772baea890bc308bb2fe9be1ebba992f3a7d Mon Sep 17 00:00:00 2001 From: Curry Yang <1019yanglu@gmail.com> Date: Thu, 29 Oct 2026 17:53:32 +0800 Subject: [PATCH] fix(landing): read the import modal's workspace name inside the cache providers `Root` read `useWorkspaceLoaderData()` in its own body for the import modal's header. Since the workspace facade derives its project fields from the organization data query, that read calls `useDBQueryClient`, and Root's body sits outside `AppDataCacheProvider`, which Root itself renders: every render threw "useDBQueryClient must be used within an AppDataCacheProvider". The read moves into `RootImportModal`, rendered inside the providers. It also means Root no longer subscribes to organization data, so it doesn't re-render on every change to it; the modal only reads it while open. Co-Authored-By: Claude Opus 5.5 --- packages/insomnia/src/root.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/insomnia/src/root.tsx b/packages/insomnia/src/root.tsx index 7371d1b8a0..ec7dec4ccc 100644 --- a/packages/insomnia/src/root.tsx +++ b/packages/insomnia/src/root.tsx @@ -1,7 +1,7 @@ import { config } from '@fortawesome/fontawesome-svg-core'; import type { IpcRendererEvent } from 'electron'; import { models, services } from 'insomnia-data'; -import type { FC } from 'react'; +import type { ComponentProps, FC } from 'react'; import { useEffect, useState } from 'react'; import { Button } from 'react-aria-components'; import { @@ -333,6 +333,14 @@ export const HydrateFallback = () => { ); }; +// Root's import modal, with the workspace name for its header. Reads workspace data, which comes from +// the query caches, so it renders inside the cache providers — unlike Root's own body, which +// renders them. Reading it here also keeps Root from re-rendering on every organization data change. +const RootImportModal = (props: Omit, 'workspaceName'>) => { + const workspaceName = useWorkspaceLoaderData()?.activeWorkspace?.name; + return ; +}; + const Root = () => { const { organizationId, projectId, workspaceId } = useParams() as { organizationId: string; @@ -350,8 +358,7 @@ const Root = () => { // INS-3544: pasting a cURL while no editable surface has focus starts the // import flow. Inside a workspace the current collection is offered as the - // default import target, which needs the workspace name for the modal header. - const workspaceName = useWorkspaceLoaderData()?.activeWorkspace?.name; + // default import target (see `RootImportModal`). const handleCurlPaste = async (curl: string) => { // The Scratchpad project holds a single collection; keep the import flow // out of it so a paste cannot create extra collections there. @@ -817,12 +824,11 @@ const Root = () => { {/* triggered by insomnia://app/import and pasting a cURL with no focus */} {importTrigger && ( - setImportTrigger(null)} defaultProjectId={projectId} organizationId={organizationId} - workspaceName={workspaceName} defaultWorkspaceId={importTrigger.workspaceId} from={importTrigger.source} />