优化agent配置选项加载逻辑

This commit is contained in:
xintaofei
2026-03-26 21:37:30 +08:00
parent d1eaa8f725
commit 5e5c48338b
2 changed files with 17 additions and 7 deletions

View File

@@ -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

View File

@@ -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,