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,