Download src/hooks/use-active-agent-profile.ts from SaylorTwift/openhands: direct link, hf CLI and curl.
- Browser
- Download file 1.41 kB
-
https://huggingface.co/SaylorTwift/openhands/resolve/main/src/hooks/use-active-agent-profile.ts
- Command line
-
hf download hf://SaylorTwift/openhands/src/hooks/use-active-agent-profile.ts
-
curl -L -o use-active-agent-profile.ts https://huggingface.co/SaylorTwift/openhands/resolve/main/src/hooks/use-active-agent-profile.ts
1.41 kB
| import type { AgentKind } from "@openhands/typescript-client"; | |
| import type { AgentProfileSummary } from "#/api/agent-profiles-service/agent-profiles-service.api"; | |
| import { useAgentProfiles } from "#/hooks/query/use-agent-profiles"; | |
| /** | |
| * The agent profile the user has activated β the authoritative "current agent" | |
| * now that Settings β Agent IS the profile library (#1571). `activate` is | |
| * pointer-only and never writes `settings.agent_settings`, so the active | |
| * profile β not the global agent settings β is the source of truth for what | |
| * kind of agent (OpenHands vs ACP) is in effect. | |
| */ | |
| export function useActiveAgentProfile(): { | |
| activeProfile: AgentProfileSummary | null; | |
| isLoading: boolean; | |
| } { | |
| const { data, isLoading } = useAgentProfiles(); | |
| const activeId = data?.active_agent_profile_id ?? null; | |
| const activeProfile = | |
| data?.profiles?.find((p) => p.id != null && p.id === activeId) ?? null; | |
| return { activeProfile, isLoading }; | |
| } | |
| /** | |
| * The effective agent kind from the active profile. `undefined` while the | |
| * profile list is loading or when no profile is active β callers should fall | |
| * back to `settings.agent_settings.agent_kind` in that window to avoid a flash | |
| * of the wrong (OpenHands-default) UI. | |
| */ | |
| export function useActiveAgentKind(): AgentKind | undefined { | |
| const { activeProfile } = useActiveAgentProfile(); | |
| return activeProfile?.agent_kind; | |
| } | |