Use replace navigation for agent switches

This commit is contained in:
Mohamed Boudra
2026-01-01 16:55:58 +07:00
parent 0c4d1c3a58
commit b3a1729df2
3 changed files with 37 additions and 23 deletions
+23 -19
View File
@@ -4,6 +4,7 @@ import { useDaemonConnections } from "@/contexts/daemon-connections-context";
import { useSessionStore } from "@/stores/session-store";
import type { AgentDirectoryEntry } from "@/types/agent-directory";
import type { Agent } from "@/stores/session-store";
import { isPerfLoggingEnabled } from "@/utils/perf";
export interface AggregatedAgent extends AgentDirectoryEntry {
serverId: string;
@@ -66,7 +67,7 @@ export function useAggregatedAgents(): AggregatedAgentsResult {
if (agent.parentAgentId) {
continue;
}
allAgents.push({
const nextAgent: AggregatedAgent = {
id: agent.id,
serverId,
serverLabel,
@@ -79,7 +80,8 @@ export function useAggregatedAgents(): AggregatedAgentsResult {
attentionReason: agent.attentionReason,
attentionTimestamp: agent.attentionTimestamp,
parentAgentId: agent.parentAgentId,
});
};
allAgents.push(nextAgent);
}
}
@@ -138,25 +140,27 @@ export function useAggregatedAgents(): AggregatedAgentsResult {
// isLoading: Generic loading flag (either initial or revalidating)
const isLoading = isConnecting;
const connectionStatesArray = Array.from(connectionStates.entries()).map(([id, state]) => ({
id: id.substring(0, 20) + (id.length > 20 ? '...' : ''),
status: state.status,
sessionReady: state.sessionReady,
hasEverReceivedSessionState: state.hasEverReceivedSessionState,
}));
if (isPerfLoggingEnabled()) {
const connectionStatesArray = Array.from(connectionStates.entries()).map(([id, state]) => ({
id: id.substring(0, 20) + (id.length > 20 ? '...' : ''),
status: state.status,
sessionReady: state.sessionReady,
hasEverReceivedSessionState: state.hasEverReceivedSessionState,
}));
console.log('[useAggregatedAgents] States:', {
hasAnyData,
isConnecting,
isInitialLoad,
isRevalidating,
totalConnectionStates: connectionStates.size,
connectingReasons: connectingReasons.length > 0 ? connectingReasons : 'none',
});
console.log('[useAggregatedAgents] States:', {
hasAnyData,
isConnecting,
isInitialLoad,
isRevalidating,
totalConnectionStates: connectionStates.size,
connectingReasons: connectingReasons.length > 0 ? connectingReasons : 'none',
});
console.log('[useAggregatedAgents] Connection States Detail:',
JSON.stringify(connectionStatesArray, null, 2)
);
console.log('[useAggregatedAgents] Connection States Detail:',
JSON.stringify(connectionStatesArray, null, 2)
);
}
return {
agents: allAgents,