88import { resolveAgentCardModelLabel } from "@/features/agents/lib/agentCardModelLabel" ;
99import { effectiveAgentDescription } from "@/features/agents/lib/agentDescription" ;
1010import { friendlyAgentLastError } from "@/features/agents/lib/friendlyAgentLastError" ;
11- import { useAgentAvailability } from "@/features/agents/lib/useAgentAvailability" ;
11+ import type { AgentAvailabilityReader } from "@/features/agents/lib/useAgentAvailability" ;
1212import { isManagedAgentActive } from "@/features/agents/lib/managedAgentControlActions" ;
1313import { pickProfileAgent } from "@/features/agents/lib/pickProfileAgent" ;
1414import { useIsArchivedPredicate } from "@/features/identity-archive/hooks" ;
@@ -26,6 +26,7 @@ import { buildUnifiedGroups } from "./unifiedAgentGroups";
2626
2727type UnifiedAgentsSectionProps = {
2828 defaultModel : string ;
29+ getAvailability : AgentAvailabilityReader ;
2930 actionErrorMessage : string | null ;
3031 actionNoticeMessage : string | null ;
3132 agents : ManagedAgent [ ] ;
@@ -71,6 +72,7 @@ export function UnifiedAgentsSection(props: UnifiedAgentsSectionProps) {
7172 actionErrorMessage,
7273 actionNoticeMessage,
7374 defaultModel,
75+ getAvailability,
7476 agents,
7577 agentsError,
7678 isActionPending,
@@ -154,6 +156,7 @@ export function UnifiedAgentsSection(props: UnifiedAgentsSectionProps) {
154156 />
155157 ) }
156158 agent = { profileAgent }
159+ getAvailability = { getAvailability }
157160 defaultModel = { defaultModel }
158161 key = { group . persona . id }
159162 persona = { group . persona }
@@ -174,6 +177,7 @@ export function UnifiedAgentsSection(props: UnifiedAgentsSectionProps) {
174177 < CollapsibleAgentGroup
175178 agents = { unknown }
176179 collapsed = { collapsed }
180+ getAvailability = { getAvailability }
177181 defaultModel = { defaultModel }
178182 groupKey = "__unknown__"
179183 label = "Unknown agents"
@@ -189,6 +193,7 @@ export function UnifiedAgentsSection(props: UnifiedAgentsSectionProps) {
189193 < CollapsibleAgentGroup
190194 agents = { ungrouped }
191195 collapsed = { collapsed }
196+ getAvailability = { getAvailability }
192197 defaultModel = { defaultModel }
193198 groupKey = "__ungrouped__"
194199 label = "Custom agents"
@@ -225,6 +230,7 @@ function AgentPersonaCard({
225230 actions,
226231 agent,
227232 defaultModel,
233+ getAvailability,
228234 persona,
229235 restartingAgentPubkey,
230236 startingAgentPubkey,
@@ -241,6 +247,7 @@ function AgentPersonaCard({
241247 ) => React . ReactNode ;
242248 agent : ManagedAgent | undefined ;
243249 defaultModel : string ;
250+ getAvailability : AgentAvailabilityReader ;
244251 persona : AgentPersona ;
245252 restartingAgentPubkey : string | null ;
246253 startingAgentPubkey : string | null ;
@@ -254,7 +261,7 @@ function AgentPersonaCard({
254261 onStartAgent : ( pubkey : string ) => void ;
255262 onStartPersona : ( persona : AgentPersona ) => void ;
256263} ) {
257- const { status : availability } = useAgentAvailability ( agent ?. pubkey ) ;
264+ const availability = getAvailability ( agent ?. pubkey ) ;
258265 const title = persona . displayName ;
259266 // Card face second line: the authored description when one exists;
260267 // otherwise fall back to the model label as before.
@@ -348,6 +355,7 @@ function AgentPersonaCard({
348355function StandaloneAgentCard ( {
349356 agent,
350357 defaultModel,
358+ getAvailability,
351359 restartingAgentPubkey,
352360 startingAgentPubkey,
353361 onOpenAgentProfile,
@@ -356,6 +364,7 @@ function StandaloneAgentCard({
356364} : {
357365 agent : ManagedAgent ;
358366 defaultModel : string ;
367+ getAvailability : AgentAvailabilityReader ;
359368 restartingAgentPubkey : string | null ;
360369 startingAgentPubkey : string | null ;
361370 onOpenAgentProfile : (
@@ -365,7 +374,7 @@ function StandaloneAgentCard({
365374 onRestartAgent : ( pubkey : string ) => void ;
366375 onStartAgent : ( pubkey : string ) => void ;
367376} ) {
368- const { status : availability } = useAgentAvailability ( agent . pubkey ) ;
377+ const availability = getAvailability ( agent . pubkey ) ;
369378 const title = agent . name ;
370379 const profileQuery = useUserProfileQuery ( agent . pubkey ) ;
371380 const friendlyError = friendlyAgentLastError (
@@ -457,6 +466,7 @@ function CollapsibleAgentGroup({
457466 agents,
458467 collapsed,
459468 defaultModel,
469+ getAvailability,
460470 restartingAgentPubkey,
461471 startingAgentPubkey,
462472 onToggle,
@@ -469,6 +479,7 @@ function CollapsibleAgentGroup({
469479 agents : ManagedAgent [ ] ;
470480 collapsed : ReadonlySet < string > ;
471481 defaultModel : string ;
482+ getAvailability : AgentAvailabilityReader ;
472483 restartingAgentPubkey : string | null ;
473484 startingAgentPubkey : string | null ;
474485 onToggle : ( key : string ) => void ;
@@ -500,6 +511,7 @@ function CollapsibleAgentGroup({
500511 { agents . map ( ( agent ) => (
501512 < StandaloneAgentCard
502513 agent = { agent }
514+ getAvailability = { getAvailability }
503515 defaultModel = { defaultModel }
504516 key = { agent . pubkey }
505517 restartingAgentPubkey = { restartingAgentPubkey }
0 commit comments