Remove legacy host auto-connect state
This commit is contained in:
@@ -648,7 +648,6 @@ export default function SettingsScreen() {
|
||||
const created = await addDaemon({
|
||||
label: deriveDaemonLabel(trimmedUrl),
|
||||
wsUrl: trimmedUrl,
|
||||
autoConnect: true,
|
||||
});
|
||||
setSelectedDaemonId(created.id);
|
||||
}
|
||||
|
||||
@@ -1,48 +1,15 @@
|
||||
import { useEffect, useMemo, useRef } from "react";
|
||||
import { SessionProvider } from "@/contexts/session-context";
|
||||
import { useDaemonRegistry, type DaemonProfile } from "@/contexts/daemon-registry-context";
|
||||
import { useDaemonRegistry } from "@/contexts/daemon-registry-context";
|
||||
|
||||
export function MultiDaemonSessionHost() {
|
||||
const { daemons } = useDaemonRegistry();
|
||||
const autoConnectStatesRef = useRef<Map<string, boolean>>(new Map());
|
||||
|
||||
useEffect(() => {
|
||||
const trackedStates = autoConnectStatesRef.current;
|
||||
const activeIds = new Set<string>();
|
||||
|
||||
for (const daemon of daemons) {
|
||||
activeIds.add(daemon.id);
|
||||
const previousAutoConnect = trackedStates.get(daemon.id);
|
||||
if (daemon.autoConnect === false && previousAutoConnect !== false) {
|
||||
console.info("[DaemonConnection]", {
|
||||
event: "auto_connect_skip",
|
||||
daemonId: daemon.id,
|
||||
label: daemon.label,
|
||||
reason: "autoConnect disabled",
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
}
|
||||
trackedStates.set(daemon.id, daemon.autoConnect);
|
||||
}
|
||||
|
||||
for (const daemonId of Array.from(trackedStates.keys())) {
|
||||
if (!activeIds.has(daemonId)) {
|
||||
trackedStates.delete(daemonId);
|
||||
}
|
||||
}
|
||||
}, [daemons]);
|
||||
|
||||
const connectedDaemons = useMemo<DaemonProfile[]>(() => {
|
||||
return daemons.filter((daemon) => daemon.autoConnect !== false);
|
||||
}, [daemons]);
|
||||
|
||||
if (connectedDaemons.length === 0) {
|
||||
if (daemons.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{connectedDaemons.map((daemon) => (
|
||||
{daemons.map((daemon) => (
|
||||
<SessionProvider key={daemon.id} serverUrl={daemon.wsUrl} serverId={daemon.id}>
|
||||
{null}
|
||||
</SessionProvider>
|
||||
|
||||
@@ -13,7 +13,6 @@ export type DaemonProfile = {
|
||||
label: string;
|
||||
wsUrl: string;
|
||||
restUrl?: string | null;
|
||||
autoConnect: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
metadata?: Record<string, unknown> | null;
|
||||
@@ -23,7 +22,6 @@ type CreateDaemonInput = {
|
||||
label: string;
|
||||
wsUrl: string;
|
||||
restUrl?: string | null;
|
||||
autoConnect?: boolean;
|
||||
};
|
||||
|
||||
type UpdateDaemonInput = Partial<Omit<DaemonProfile, "id" | "createdAt">>;
|
||||
@@ -76,7 +74,6 @@ export function DaemonRegistryProvider({ children }: { children: ReactNode }) {
|
||||
label: input.label.trim() || deriveLabelFromUrl(input.wsUrl),
|
||||
wsUrl: input.wsUrl,
|
||||
restUrl: input.restUrl ?? null,
|
||||
autoConnect: input.autoConnect ?? true,
|
||||
createdAt: timestamp,
|
||||
updatedAt: timestamp,
|
||||
metadata: null,
|
||||
@@ -143,7 +140,6 @@ function createProfile(label: string, wsUrl: string): DaemonProfile {
|
||||
label,
|
||||
wsUrl,
|
||||
restUrl: null,
|
||||
autoConnect: true,
|
||||
createdAt: timestamp,
|
||||
updatedAt: timestamp,
|
||||
metadata: null,
|
||||
|
||||
@@ -57,7 +57,7 @@ export function useDaemonSession(serverId?: string | null, options?: UseDaemonSe
|
||||
const label = connection?.daemon.label ?? serverId;
|
||||
const status = connection?.status ?? "unknown";
|
||||
const lastError = connection?.lastError ? `\n${connection.lastError}` : "";
|
||||
const message = `${label} isn't connected yet (${status}). Switch to it or enable auto-connect so Paseo can reach it.${lastError}`;
|
||||
const message = `${label} isn't connected yet (${status}). Switch to it and wait for Paseo to reconnect automatically.${lastError}`;
|
||||
|
||||
if (!suppressUnavailableAlert && !alertedDaemonsRef.current.has(serverId)) {
|
||||
alertedDaemonsRef.current.add(serverId);
|
||||
|
||||
Reference in New Issue
Block a user