refactor(app): replace providers-snapshot invalidate with refetchIfStale
invalidate() flagged the query stale and kicked off a refetch unconditionally, causing a loading flash every time the model selector opened. Expose refetchIfStale() instead so callers only refetch when data is actually stale.
This commit is contained in:
@@ -867,8 +867,7 @@ export const AgentStatusBar = memo(function AgentStatusBar({
|
||||
const {
|
||||
entries: snapshotEntries,
|
||||
isLoading: snapshotIsLoading,
|
||||
isFetching: snapshotIsFetching,
|
||||
invalidate: invalidateSnapshot,
|
||||
refetchIfStale: refetchSnapshotIfStale,
|
||||
} = useProvidersSnapshot(serverId, agent?.cwd);
|
||||
|
||||
const snapshotModels = useMemo(() => {
|
||||
@@ -1034,8 +1033,8 @@ export const AgentStatusBar = memo(function AgentStatusBar({
|
||||
console.warn("[AgentStatusBar] setAgentFeature failed", error);
|
||||
});
|
||||
}}
|
||||
isModelLoading={snapshotIsLoading || snapshotIsFetching}
|
||||
onModelSelectorOpen={invalidateSnapshot}
|
||||
isModelLoading={snapshotIsLoading}
|
||||
onModelSelectorOpen={refetchSnapshotIfStale}
|
||||
onDropdownClose={onDropdownClose}
|
||||
disabled={!client}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user