From af992849a43b69ea1c4af2b1f8f4eae4b70c0e11 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Mon, 13 Oct 2025 14:07:39 -0700 Subject: [PATCH] fix: list agents request --- .../components/BackgroundMode/AgentsList.tsx | 14 +++++++++++--- .../BackgroundMode/BackgroundModeView.tsx | 19 ++++++++++++++----- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/gui/src/components/BackgroundMode/AgentsList.tsx b/gui/src/components/BackgroundMode/AgentsList.tsx index c42ab2918..29ff0d2fe 100644 --- a/gui/src/components/BackgroundMode/AgentsList.tsx +++ b/gui/src/components/BackgroundMode/AgentsList.tsx @@ -40,9 +40,17 @@ export function AgentsList() { organizationId, }); - if (result && Array.isArray(result)) { - setAgents(result); - setError(null); + // Handle wrapped response format + if ("status" in result && result.status === "success") { + if (Array.isArray(result.content)) { + setAgents(result.content); + setError(null); + } else { + setAgents([]); + } + } else if ("error" in result) { + setError(result.error); + setAgents([]); } else { setAgents([]); } diff --git a/gui/src/components/BackgroundMode/BackgroundModeView.tsx b/gui/src/components/BackgroundMode/BackgroundModeView.tsx index be1635380..10df5107c 100644 --- a/gui/src/components/BackgroundMode/BackgroundModeView.tsx +++ b/gui/src/components/BackgroundMode/BackgroundModeView.tsx @@ -49,12 +49,21 @@ export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) { setCheckingGitHub(true); // Try to list agents - if this fails with GitHub token error, // we know GitHub isn't connected - const agents = await ideMessenger.request("listBackgroundAgents", {}); + const result = await ideMessenger.request("listBackgroundAgents", {}); - // If we got here without error and have agents, GitHub is connected - // If we have no agents, we still don't know for sure, so we'll show - // the setup warning anyway (it will be dismissed after first agent creation) - setShowGitHubSetup(false); + // Check for error response + if ("error" in result) { + // Check if error is related to GitHub token + if ( + result.error?.includes("GitHub token") || + result.error?.includes("GitHub App") + ) { + setShowGitHubSetup(true); + } + } else { + // If we got here without error, GitHub is connected + setShowGitHubSetup(false); + } } catch (error: any) { // Check if error is related to GitHub token if (