From 5ba0655bb5569df5f51872bb1bed577ccfdc07ee Mon Sep 17 00:00:00 2001 From: Pavlos Koutoglou Date: Mon, 13 Jul 2026 11:17:11 +0200 Subject: [PATCH] fix(INS-2933): let empty-input request creation and re-focus the first-request input on project switch (#10240) * fix: improve request creation handling and input focus behavior * fix: simplify user ownership check in project component * fix: refactor onboarding state loading to use async/await for better readability * fix: enhance request creation button disable logic to include workspace fetcher state --- ...ganizationId.project.$projectId._index.tsx | 2 +- .../ui/components/first-request-creation.tsx | 35 ++++++++++++------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/packages/insomnia/src/routes/organization.$organizationId.project.$projectId._index.tsx b/packages/insomnia/src/routes/organization.$organizationId.project.$projectId._index.tsx index bf5560dbe0..1e3fe2841a 100644 --- a/packages/insomnia/src/routes/organization.$organizationId.project.$projectId._index.tsx +++ b/packages/insomnia/src/routes/organization.$organizationId.project.$projectId._index.tsx @@ -141,7 +141,7 @@ const Component = ({ loaderData }: Route.ComponentProps) => { const [isNewProjectModalOpen, setIsNewProjectModalOpen] = useState(false); const [isUpdateProjectModalOpen, setIsUpdateProjectModalOpen] = useState(false); const organization = organizationData?.organizations.find(o => o.id === organizationId); - const isUserOwner = organization && userSession.accountId && Boolean(organization.is_owner); + const isUserOwner = Boolean(organization?.is_owner); const collectionItems = useMemo( () => localFiles diff --git a/packages/insomnia/src/ui/components/first-request-creation.tsx b/packages/insomnia/src/ui/components/first-request-creation.tsx index 609d688736..c05a09f867 100644 --- a/packages/insomnia/src/ui/components/first-request-creation.tsx +++ b/packages/insomnia/src/ui/components/first-request-creation.tsx @@ -246,6 +246,7 @@ export const FirstRequestCreation = ({ const handleCreateRequest = async () => { if (!trimmedInput) { + handleCreateBlankRequest(); return; } const workspaceId = await ensureWorkspaceId(); @@ -301,6 +302,13 @@ export const FirstRequestCreation = ({ setSelectOpen(false); }, [selectedCollectionId]); + // Focus the request input whenever the pane is (re-)shown for a project. A plain + // `autoFocus` attribute only fires on the input's initial DOM mount, so it misses + // client-side navigations between projects that reuse this component instance. + useEffect(() => { + inputRef.current?.focus(); + }, [projectId]); + // Load the lifetime created-request count, used to decide when to latch the // server-side graduation threshold (see maybeLatchRequestThreshold for how the // device-wide count is scoped back down to this account). @@ -324,18 +332,20 @@ export const FirstRequestCreation = ({ useEffect(() => { let isActive = true; - getCurrentSessionId() - .then(sessionId => (sessionId ? getOnboardingState({ sessionId }) : null)) - .catch(error => { + const loadOnboardingState = async () => { + let state: UserOnboarding | null = null; + try { + const sessionId = await getCurrentSessionId(); + state = sessionId ? await getOnboardingState({ sessionId }) : null; + } catch (error) { console.error('Failed to load onboarding state', error); - return null; - }) - .then(state => { - if (isActive) { - setOnboarding(state); - setOnboardingLoaded(true); - } - }); + } + if (isActive) { + setOnboarding(state); + setOnboardingLoaded(true); + } + }; + loadOnboardingState(); return () => { isActive = false; @@ -543,7 +553,6 @@ export const FirstRequestCreation = ({ handleCreateRequest()} > {createButtonLabel}