refactor(app): centralize perf diagnostics and activity coalescing

This commit is contained in:
Mohamed Boudra
2026-02-22 11:52:08 +07:00
parent d7e2ab4437
commit d6b7c2ed2d
24 changed files with 1119 additions and 81 deletions
@@ -48,11 +48,17 @@ export function applyFetchedAgentDirectory(input: {
entries: FetchAgentsEntry[];
}): { agents: Map<string, Agent> } {
const { agents, pendingPermissions } = buildAgentDirectoryState(input);
const store = useSessionStore.getState();
store.setAgents(input.serverId, agents);
const lastActivityByAgentId = new Map<string, Date>();
for (const agent of agents.values()) {
store.setAgentLastActivity(agent.id, agent.lastActivityAt);
lastActivityByAgentId.set(agent.id, agent.lastActivityAt);
}
store.setAgentLastActivityBatch(lastActivityByAgentId);
store.setPendingPermissions(input.serverId, pendingPermissions);
store.setInitializingAgents(input.serverId, new Map());
store.setHasHydratedAgents(input.serverId, true);
@@ -0,0 +1,20 @@
// Compatibility shim while callers move to `@/runtime/perf-diagnostics`.
// Keep this file side-effect free.
export {
consumePersistedPerfDiagnosticReports,
getPerfDiagnosticBreadcrumbs,
getPerfDiagnosticsSnapshot,
installPerfDiagnosticsMonitor,
isPerfDiagnosticsEnabled,
peekPersistedPerfDiagnosticReports,
recordPerfDiagnosticMark,
} from "@/runtime/perf-diagnostics";
export type {
PerfDiagnosticBreadcrumb,
PerfDiagnosticFields,
PerfDiagnosticsReport,
PerfDiagnosticsSnapshot,
PerfDiagnosticsReporter,
RecordPerfDiagnosticMarkOptions,
} from "@/runtime/perf-diagnostics";