2026-04-28 09:22:19 -07:00
|
|
|
import { atomWithQuery } from "jotai-tanstack-query";
|
|
|
|
|
import { agentFlagsApiService } from "@/lib/apis/agent-flags-api.service";
|
2026-06-23 13:01:41 +05:30
|
|
|
import { isAuthenticated } from "@/lib/auth-utils";
|
2026-04-28 09:22:19 -07:00
|
|
|
|
|
|
|
|
export const AGENT_FLAGS_QUERY_KEY = ["agent", "flags"] as const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reads the backend agent feature flags. Cached for the lifetime of the
|
|
|
|
|
* page (flags only change on backend restart) so we can drive UI gating
|
|
|
|
|
* without re-hitting the API.
|
|
|
|
|
*/
|
|
|
|
|
export const agentFlagsAtom = atomWithQuery(() => ({
|
|
|
|
|
queryKey: AGENT_FLAGS_QUERY_KEY,
|
|
|
|
|
staleTime: 10 * 60 * 1000,
|
2026-06-23 13:01:41 +05:30
|
|
|
enabled: isAuthenticated(),
|
2026-04-28 09:22:19 -07:00
|
|
|
queryFn: () => agentFlagsApiService.get(),
|
|
|
|
|
}));
|