refactor(app): simplify session directory with direct snapshots and add sessionReady state

Replace subscription-based session accessor pattern with direct snapshot updates in daemon connections context. Add sessionReady flag to connection state to track when initial agent list has been received. Auto-select first ready host in create agent modal. Migrate from app.json to app.config.js. Add android:release script and Playwright testing docs.
This commit is contained in:
Mohamed Boudra
2025-11-27 21:06:48 +01:00
parent a01c3f9b73
commit bf58e81ce8
12 changed files with 339 additions and 277 deletions
@@ -1,35 +1,20 @@
import { useEffect, useMemo, useState } from "react";
import { useMemo } from "react";
import { useDaemonConnections } from "@/contexts/daemon-connections-context";
import type { SessionContextValue } from "@/contexts/session-context";
export function useSessionDirectory(): Map<string, SessionContextValue | null> {
const { sessionAccessors, subscribeToSessionDirectory } = useDaemonConnections();
const [revision, setRevision] = useState(0);
useEffect(() => {
return subscribeToSessionDirectory(() => {
setRevision((current) => current + 1);
});
}, [subscribeToSessionDirectory]);
export function useSessionDirectory(): Map<string, SessionContextValue> {
const { sessionSnapshots } = useDaemonConnections();
return useMemo(() => {
const entries = new Map<string, SessionContextValue | null>();
sessionAccessors.forEach((entry, serverId) => {
try {
entries.set(serverId, entry.getSnapshot());
} catch (error) {
console.error(`[useSessionDirectory] Failed to read session accessor for "${serverId}"`, error);
entries.set(serverId, null);
}
const entries = new Map<string, SessionContextValue>();
sessionSnapshots.forEach((snapshot, serverId) => {
entries.set(serverId, snapshot);
});
return entries;
}, [sessionAccessors, revision]);
}, [sessionSnapshots]);
}
export function useSessionForServer(serverId: string | null): SessionContextValue | null {
const directory = useSessionDirectory();
if (!serverId) {
return null;
}
return directory.get(serverId) ?? null;
const { sessionSnapshots } = useDaemonConnections();
return serverId ? sessionSnapshots.get(serverId) ?? null : null;
}