Remove active host dependency from UI actions

This commit is contained in:
Mohamed Boudra
2025-11-26 18:04:40 +01:00
parent e6d2998904
commit 5807f62f1a
8 changed files with 57 additions and 129 deletions
@@ -26,9 +26,8 @@ const sortAgents = (agents: Agent[]): Agent[] => {
};
export function useAggregatedAgents(fallbackAgents: Map<string, Agent>): AggregatedAgentGroup[] {
const { activeDaemonId, connectionStates } = useDaemonConnections();
const { connectionStates } = useDaemonConnections();
const sessionDirectory = useSessionDirectory();
const activeServerId = activeDaemonId ?? "default";
return useMemo(() => {
const groups = new Map<string, { serverLabel: string; agents: Agent[] }>();
@@ -57,10 +56,11 @@ export function useAggregatedAgents(fallbackAgents: Map<string, Agent>): Aggrega
}
if (groups.size === 0) {
const label = connectionStates.get(activeServerId)?.daemon.label ?? activeServerId;
const fallbackServerId = connectionStates.keys().next().value ?? "default";
const label = connectionStates.get(fallbackServerId)?.daemon.label ?? fallbackServerId;
const fallbackList = Array.from(fallbackAgents.values());
if (fallbackList.length > 0) {
groups.set(activeServerId, { serverLabel: label, agents: fallbackList });
groups.set(fallbackServerId, { serverLabel: label, agents: fallbackList });
}
}
@@ -86,5 +86,5 @@ export function useAggregatedAgents(fallbackAgents: Map<string, Agent>): Aggrega
});
return aggregatedGroups;
}, [sessionDirectory, fallbackAgents, activeServerId, connectionStates]);
}, [sessionDirectory, fallbackAgents, connectionStates]);
}