From 5e5c48338b57455b68a8e87f545fd459ddba12d6 Mon Sep 17 00:00:00 2001 From: xintaofei Date: Thu, 26 Mar 2026 21:37:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96agent=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=80=89=E9=A1=B9=E5=8A=A0=E8=BD=BD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/use-connection-lifecycle.ts | 20 +++++++++++++------- src/hooks/use-connection.ts | 4 ++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/hooks/use-connection-lifecycle.ts b/src/hooks/use-connection-lifecycle.ts index cdf982f..2459889 100644 --- a/src/hooks/use-connection-lifecycle.ts +++ b/src/hooks/use-connection-lifecycle.ts @@ -64,6 +64,7 @@ export function useConnectionLifecycle({ respondPermission: connRespondPermission, modes, configOptions, + hasCachedSelectors, } = conn const isInteractiveStatus = status === "connected" || status === "prompting" const hasSelectorsData = modes !== null || configOptions !== null @@ -73,15 +74,20 @@ export function useConnectionLifecycle({ null ) const selectorTaskSuppressedRef = useRef(false) - // Visual-only loading indicators for selector chips + // Visual-only loading indicators for selector chips. + // Skip loading indicators when we have cached selectors — even if the + // cache contains no modes/configOptions (the agent simply doesn't have + // them), we already know what to show and don't need a loading state. const modeLoading = - status === "connecting" || - status === "downloading" || - (isInteractiveStatus && !effectiveSelectorsReady) + !hasCachedSelectors && + (status === "connecting" || + status === "downloading" || + (isInteractiveStatus && !effectiveSelectorsReady)) const configOptionsLoading = - status === "connecting" || - status === "downloading" || - (isInteractiveStatus && !effectiveSelectorsReady) + !hasCachedSelectors && + (status === "connecting" || + status === "downloading" || + (isInteractiveStatus && !effectiveSelectorsReady)) // Gate for send button: block until the backend session is fully // initialized (selectorsReady from the real backend event, not cache). const selectorsLoading = isInteractiveStatus && !selectorsReady diff --git a/src/hooks/use-connection.ts b/src/hooks/use-connection.ts index 2f6d6cc..039c214 100644 --- a/src/hooks/use-connection.ts +++ b/src/hooks/use-connection.ts @@ -33,6 +33,7 @@ export interface UseConnectionReturn { promptCapabilities: PromptCapabilitiesInfo supportsFork: boolean selectorsReady: boolean + hasCachedSelectors: boolean sessionId: string | null modes: SessionModeStateInfo | null configOptions: SessionConfigOptionInfo[] | null @@ -84,6 +85,7 @@ export function useConnection(contextKey: string): UseConnectionReturn { const cached = connection?.agentType ? getCachedSelectors(connection.agentType) : null + const hasCachedSelectors = cached !== null const modes = connection?.modes ?? cached?.modes ?? null const configOptions = connection?.configOptions ?? cached?.configOptions ?? null @@ -142,6 +144,7 @@ export function useConnection(contextKey: string): UseConnectionReturn { promptCapabilities, supportsFork, selectorsReady, + hasCachedSelectors, sessionId, modes, configOptions, @@ -164,6 +167,7 @@ export function useConnection(contextKey: string): UseConnectionReturn { promptCapabilities, supportsFork, selectorsReady, + hasCachedSelectors, sessionId, modes, configOptions,