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:
Mohamed Boudra
2026-04-18 16:03:13 +07:00
parent 5d76cc8840
commit 72e4476acc
4 changed files with 17 additions and 19 deletions
@@ -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}
/>