Eliminate hidden host defaults

This commit is contained in:
Mohamed Boudra
2025-11-26 19:02:47 +01:00
parent 670c38ab8c
commit 4f00e07284
3 changed files with 34 additions and 30 deletions
@@ -9,8 +9,6 @@ export interface AggregatedAgentGroup {
agents: Agent[];
}
const EMPTY_AGENT_MAP: Map<string, Agent> = new Map();
const sortAgents = (agents: Agent[]): Agent[] => {
return [...agents].sort((left, right) => {
const leftRunning = left.status === "running";
@@ -27,10 +25,9 @@ const sortAgents = (agents: Agent[]): Agent[] => {
});
};
export function useAggregatedAgents(fallbackAgents?: Map<string, Agent>): AggregatedAgentGroup[] {
export function useAggregatedAgents(): AggregatedAgentGroup[] {
const { connectionStates } = useDaemonConnections();
const sessionDirectory = useSessionDirectory();
const fallback = fallbackAgents ?? EMPTY_AGENT_MAP;
return useMemo(() => {
const groups = new Map<string, { serverLabel: string; agents: Agent[] }>();
@@ -58,15 +55,6 @@ export function useAggregatedAgents(fallbackAgents?: Map<string, Agent>): Aggreg
});
}
if (groups.size === 0 && fallback.size > 0) {
const fallbackServerId = connectionStates.keys().next().value ?? "default";
const label = connectionStates.get(fallbackServerId)?.daemon.label ?? fallbackServerId;
const fallbackList = Array.from(fallback.values());
if (fallbackList.length > 0) {
groups.set(fallbackServerId, { serverLabel: label, agents: fallbackList });
}
}
const aggregatedGroups = Array.from(groups.entries()).map(([serverId, { serverLabel, agents }]) => ({
serverId,
serverLabel,
@@ -89,5 +77,5 @@ export function useAggregatedAgents(fallbackAgents?: Map<string, Agent>): Aggreg
});
return aggregatedGroups;
}, [sessionDirectory, fallback, connectionStates]);
}, [sessionDirectory, connectionStates]);
}