Fix create agent modal incorrectly showing hosts as offline

The availability check was failing for online hosts due to a timing
issue: connectionStates would show "online" before SessionProvider
registered its session accessor, causing session to be null.

Changed selectedDaemonIsUnavailable to selectedDaemonIsOffline which
only checks connectionStates status (the single source of truth for
connection state), removing the redundant session and ws.isConnected
checks. isTargetDaemonReady still requires session for actual operations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Mohamed Boudra
2025-11-26 20:12:11 +01:00
parent 0c571f6f43
commit 135bcf13a8
2 changed files with 29 additions and 14 deletions

View File

@@ -330,17 +330,16 @@ function AgentFlowModal({
"Selected host";
const selectedDaemonStatusLabel = formatConnectionStatus(selectedDaemonStatus);
const hasSelectedDaemon = Boolean(selectedServerId);
const selectedDaemonIsUnavailable =
!session || selectedDaemonStatus !== "online" || !ws?.isConnected;
const selectedDaemonIsOffline = selectedDaemonStatus !== "online";
const selectedDaemonLastError = selectedDaemonConnection?.lastError?.trim();
const daemonAvailabilityError = !hasSelectedDaemon
? "Select a host before creating or importing agents."
: selectedDaemonIsUnavailable
: selectedDaemonIsOffline
? `${selectedDaemonLabel} is ${selectedDaemonStatusLabel}. We'll reconnect automatically and enable actions once it's online.${
selectedDaemonLastError ? ` ${selectedDaemonLastError}` : ""
}`
: null;
const isTargetDaemonReady = Boolean(hasSelectedDaemon && session && !selectedDaemonIsUnavailable);
const isTargetDaemonReady = Boolean(hasSelectedDaemon && session && !selectedDaemonIsOffline);
const [isMounted, setIsMounted] = useState(isVisible);
const [workingDir, setWorkingDir] = useState("");