From 2edcd6ae027f31b53e8f2b0d63e430e50b5a9430 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 9 Oct 2025 12:42:43 -0700 Subject: [PATCH 01/27] feat: background agents --- core/index.d.ts | 2 +- .../components/BackgroundMode/AgentsList.tsx | 166 ++++++++++++++++++ .../BackgroundMode/BackgroundModeView.tsx | 55 ++++++ gui/src/components/ModeSelect/ModeIcon.tsx | 3 + gui/src/components/ModeSelect/ModeSelect.tsx | 28 ++- gui/src/pages/gui/Chat.tsx | 25 ++- 6 files changed, 275 insertions(+), 4 deletions(-) create mode 100644 gui/src/components/BackgroundMode/AgentsList.tsx create mode 100644 gui/src/components/BackgroundMode/BackgroundModeView.tsx diff --git a/core/index.d.ts b/core/index.d.ts index fb59d97bd..56e65d3f2 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -462,7 +462,7 @@ export interface PromptLog { completion: string; } -export type MessageModes = "chat" | "agent" | "plan"; +export type MessageModes = "chat" | "agent" | "plan" | "background"; export type ToolStatus = | "generating" // Tool call arguments are being streamed from the LLM diff --git a/gui/src/components/BackgroundMode/AgentsList.tsx b/gui/src/components/BackgroundMode/AgentsList.tsx new file mode 100644 index 000000000..dad28dbe5 --- /dev/null +++ b/gui/src/components/BackgroundMode/AgentsList.tsx @@ -0,0 +1,166 @@ +import { Loader2 } from "lucide-react"; +import { useContext, useEffect, useState } from "react"; +import { useAuth } from "../../context/Auth"; +import { IdeMessengerContext } from "../../context/IdeMessenger"; + +interface Agent { + id: string; + name: string | null; + status: string; + repoUrl: string; + createdAt: string; + metadata?: { + github_repo?: string; + }; +} + +export function AgentsList() { + const { session } = useAuth(); + const ideMessenger = useContext(IdeMessengerContext); + const [agents, setAgents] = useState([]); + const [isLoading, setIsLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + async function fetchAgents() { + if (!session) { + setAgents([]); + setIsLoading(false); + return; + } + + try { + setIsLoading(true); + // Request agent list from IDE + const result = await ideMessenger.request("listBackgroundAgents", {}); + + if (result && Array.isArray(result)) { + setAgents(result); + setError(null); + } else { + setAgents([]); + } + } catch (err: any) { + console.error("Failed to fetch agents:", err); + setError(err.message || "Failed to load agents"); + setAgents([]); + } finally { + setIsLoading(false); + } + } + + void fetchAgents(); + + // Poll for updates every 10 seconds + const interval = setInterval(() => { + void fetchAgents(); + }, 10000); + + return () => clearInterval(interval); + }, [session, ideMessenger]); + + if (isLoading) { + return ( +
+ +
+ ); + } + + if (error) { + return ( +
+ Error loading agents: {error} +
+ ); + } + + if (agents.length === 0) { + return ( +
+ No background agents yet. Submit a message above to create one. +
+ ); + } + + return ( +
+
+ Recent Agents +
+
+ {agents.map((agent) => ( +
{ + // Open agent detail in browser + const agentUrl = `https://app.continue.dev/agents/${agent.id}`; + ideMessenger.post("openUrl", agentUrl); + }} + > +
+
+
+ {agent.name || "Unnamed Agent"} +
+
+ {agent.metadata?.github_repo || agent.repoUrl} +
+
+
+ +
+
+
+ {formatRelativeTime(agent.createdAt)} +
+
+ ))} +
+
+ ); +} + +function AgentStatusBadge({ status }: { status: string }) { + const statusColors: Record = { + running: "bg-green-100 text-green-800", + pending: "bg-yellow-100 text-yellow-800", + creating: "bg-blue-100 text-blue-800", + failure: "bg-red-100 text-red-800", + suspended: "bg-gray-100 text-gray-800", + }; + + const color = statusColors[status] || "bg-gray-100 text-gray-800"; + + return ( + + {status} + + ); +} + +function formatRelativeTime(dateString: string): string { + try { + const date = new Date(dateString); + const now = new Date(); + const diffMs = now.getTime() - date.getTime(); + const diffMins = Math.floor(diffMs / 60000); + const diffHours = Math.floor(diffMs / 3600000); + const diffDays = Math.floor(diffMs / 86400000); + + if (diffMins < 1) { + return "just now"; + } else if (diffMins < 60) { + return `${diffMins}m ago`; + } else if (diffHours < 24) { + return `${diffHours}h ago`; + } else { + return `${diffDays}d ago`; + } + } catch { + return dateString; + } +} diff --git a/gui/src/components/BackgroundMode/BackgroundModeView.tsx b/gui/src/components/BackgroundMode/BackgroundModeView.tsx new file mode 100644 index 000000000..0c3d68aa8 --- /dev/null +++ b/gui/src/components/BackgroundMode/BackgroundModeView.tsx @@ -0,0 +1,55 @@ +import { RocketLaunchIcon } from "@heroicons/react/24/outline"; +import { useCallback, useState } from "react"; +import { useAuth } from "../../context/Auth"; +import { AgentsList } from "./AgentsList"; + +interface BackgroundModeViewProps { + onCreateAgent: (prompt: string) => void; +} + +export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) { + const { session, login } = useAuth(); + const [isLoggingIn, setIsLoggingIn] = useState(false); + + const handleSignIn = useCallback(async () => { + setIsLoggingIn(true); + try { + await login(false); + } catch (error) { + console.error("Login failed:", error); + } finally { + setIsLoggingIn(false); + } + }, [login]); + + if (!session) { + return ( +
+ +
+

Background Agents

+

+ Trigger long-running background agents that work on your codebase + autonomously. Sign in to Continue to get started. +

+ +
+
+ ); + } + + return ( +
+
+ Agents you trigger will run in the background and appear below. +
+ +
+ ); +} diff --git a/gui/src/components/ModeSelect/ModeIcon.tsx b/gui/src/components/ModeSelect/ModeIcon.tsx index 92dfc1723..074185886 100644 --- a/gui/src/components/ModeSelect/ModeIcon.tsx +++ b/gui/src/components/ModeSelect/ModeIcon.tsx @@ -1,5 +1,6 @@ import { ChatBubbleLeftIcon, + RocketLaunchIcon, SparklesIcon, SwatchIcon, } from "@heroicons/react/24/outline"; @@ -21,5 +22,7 @@ export function ModeIcon({ return ; case "chat": return ; + case "background": + return ; } } diff --git a/gui/src/components/ModeSelect/ModeSelect.tsx b/gui/src/components/ModeSelect/ModeSelect.tsx index 88a549012..19904d8d3 100644 --- a/gui/src/components/ModeSelect/ModeSelect.tsx +++ b/gui/src/components/ModeSelect/ModeSelect.tsx @@ -39,6 +39,8 @@ export function ModeSelect() { dispatch(setMode("plan")); } else if (mode === "plan") { dispatch(setMode("agent")); + } else if (mode === "agent") { + dispatch(setMode("background")); } else { dispatch(setMode("chat")); } @@ -96,7 +98,13 @@ export function ModeSelect() { > - {mode === "chat" ? "Chat" : mode === "agent" ? "Agent" : "Plan"} + {mode === "chat" + ? "Chat" + : mode === "agent" + ? "Agent" + : mode === "background" + ? "Background" + : "Plan"} + +
+ + Background + + + +
+ +
+
{`${metaKeyLabel} . for next mode`}
diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 61fc0a859..0d7f1a71b 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -44,6 +44,7 @@ import { isJetBrains, isMetaEquivalentKeyPressed } from "../../util"; import { ToolCallDiv } from "./ToolCallDiv"; import { useStore } from "react-redux"; +import { BackgroundModeView } from "../../components/BackgroundMode/BackgroundModeView"; import { CliInstallBanner } from "../../components/CliInstallBanner"; import { FatalErrorIndicator } from "../../components/config/FatalErrorNotice"; import InlineErrorMessage from "../../components/mainInput/InlineErrorMessage"; @@ -125,6 +126,7 @@ export function Chat() { const hasDismissedExploreDialog = useAppSelector( (state) => state.ui.hasDismissedExploreDialog, ); + const mode = useAppSelector((state) => state.session.mode); const jetbrains = useMemo(() => { return isJetBrains(); }, []); @@ -169,6 +171,17 @@ export function Chat() { const codeToEditSnapshot = stateSnapshot.editModeState.codeToEdit; const selectedModelByRole = stateSnapshot.config.config.selectedModelByRole; + const currentMode = stateSnapshot.session.mode; + + // Handle background mode specially + if (currentMode === "background" && !isCurrentlyInEdit) { + // Background mode triggers agent creation instead of chat + ideMessenger.post("createBackgroundAgent", { editorState }); + if (editorToClearOnSend) { + editorToClearOnSend.commands.clearContent(); + } + return; + } // Cancel all pending tool calls latestPendingToolCalls.forEach((toolCallState) => { @@ -457,8 +470,16 @@ export function Chat() { {!hasDismissedExploreDialog && } - {history.length === 0 && ( - + {mode === "background" ? ( + { + ideMessenger.post("createBackgroundAgent", { prompt }); + }} + /> + ) : ( + history.length === 0 && ( + + ) )} From 87170203f5a6e24e61b37e4a382f8eca7b48dbe3 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 9 Oct 2025 13:14:59 -0700 Subject: [PATCH 02/27] feat: background agents --- core/control-plane/client.ts | 83 +++++++++++++ core/protocol/ideWebview.ts | 14 +++ .../vscode/src/extension/VsCodeMessenger.ts | 111 ++++++++++++++++++ .../components/BackgroundMode/AgentsList.tsx | 4 +- 4 files changed, 210 insertions(+), 2 deletions(-) diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts index 0a0650804..0cb51d468 100644 --- a/core/control-plane/client.ts +++ b/core/control-plane/client.ts @@ -440,4 +440,87 @@ export class ControlPlaneClient { ); } } + + /** + * Create a new background agent + */ + public async createBackgroundAgent( + prompt: string, + repoUrl: string, + branch?: string, + ): Promise<{ id: string } | null> { + if (!(await this.isSignedIn())) { + return null; + } + + try { + const resp = await this.requestAndHandleError("agents/devboxes", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + prompt, + repoUrl, + branch, + }), + }); + + return (await resp.json()) as { id: string }; + } catch (e) { + Logger.error(e, { + context: "control_plane_create_background_agent", + prompt, + repoUrl, + branch, + }); + return null; + } + } + + /** + * List all background agents for the current user + */ + public async listBackgroundAgents(): Promise< + Array<{ + id: string; + name: string | null; + status: string; + repoUrl: string; + createdAt: string; + metadata?: { + github_repo?: string; + }; + }> + > { + if (!(await this.isSignedIn())) { + return []; + } + + try { + const resp = await this.requestAndHandleError("agents/devboxes", { + method: "GET", + }); + + const agents = (await resp.json()) as any[]; + + return agents.map((agent: any) => ({ + id: agent.id, + name: agent.name || null, + status: agent.status, + repoUrl: agent.repo_url || agent.repoUrl || "", + createdAt: new Date( + agent.created_at || agent.create_time_ms, + ).toISOString(), + metadata: { + github_repo: agent.metadata?.github_repo || agent.repo_url, + }, + })); + } catch (e) { + Logger.error(e, { + context: "control_plane_list_background_agents", + }); + return []; + } + } } diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index 79e7de10b..0c3dfd1fc 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -50,6 +50,20 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { "edit/addCurrentSelection": [undefined, void]; "edit/clearDecorations": [undefined, void]; "session/share": [{ sessionId: string }, void]; + createBackgroundAgent: [{ editorState: any }, void]; + listBackgroundAgents: [ + undefined, + Array<{ + id: string; + name: string | null; + status: string; + repoUrl: string; + createdAt: string; + metadata?: { + github_repo?: string; + }; + }>, + ]; }; export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & { diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index ac6427f5b..409f69dc7 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -263,6 +263,117 @@ export class VsCodeMessenger { ); }); + this.onWebview("createBackgroundAgent", async (msg) => { + const configHandler = await configHandlerPromise; + const { editorState } = msg.data; + + // Import utilities for processing editor content + const { stripImages } = await import("core/util/messageContent"); + + // Extract text from editor state + // editorState is a TipTap JSONContent object + let prompt = ""; + if (editorState && editorState.content) { + // Simple extraction - concatenate text from paragraphs + for (const node of editorState.content) { + if (node.type === "paragraph" && node.content) { + for (const child of node.content) { + if (child.type === "text" && child.text) { + prompt += child.text; + } + } + prompt += "\n"; + } + } + prompt = prompt.trim(); + } + + if (!prompt) { + vscode.window.showErrorMessage( + "Please enter a prompt to create a background agent", + ); + return; + } + + // Get workspace information + const workspaceDirs = await this.ide.getWorkspaceDirs(); + if (workspaceDirs.length === 0) { + vscode.window.showErrorMessage( + "No workspace folder found. Please open a workspace to create a background agent.", + ); + return; + } + + const workspaceDir = workspaceDirs[0]; + let repoUrl = ""; + let branch = ""; + + try { + // Get repo name/URL + const repoName = await this.ide.getRepoName(workspaceDir); + if (repoName) { + // If repo name looks like "owner/repo", convert to GitHub URL + if (repoName.includes("/") && !repoName.startsWith("http")) { + repoUrl = `https://github.com/${repoName}`; + } else { + repoUrl = repoName; + } + } + + // Get current branch + const branchInfo = await this.ide.getBranch(workspaceDir); + if (branchInfo) { + branch = branchInfo; + } + } catch (e) { + console.error("Error getting repo info:", e); + } + + if (!repoUrl) { + vscode.window.showErrorMessage( + "Unable to determine repository URL. Make sure you're in a git repository.", + ); + return; + } + + // Create the background agent + try { + const result = + await configHandler.controlPlaneClient.createBackgroundAgent( + prompt, + repoUrl, + branch, + ); + + if (result) { + vscode.window.showInformationMessage( + `Background agent created successfully! Agent ID: ${result.id}`, + ); + } else { + vscode.window.showErrorMessage( + "Failed to create background agent. Make sure you're signed in to Continue.", + ); + } + } catch (e) { + vscode.window.showErrorMessage( + `Error creating background agent: ${e instanceof Error ? e.message : "Unknown error"}`, + ); + } + }); + + this.onWebview("listBackgroundAgents", async (msg) => { + const configHandler = await configHandlerPromise; + + try { + const agents = + await configHandler.controlPlaneClient.listBackgroundAgents(); + return agents; + } catch (e) { + console.error("Error listing background agents:", e); + return []; + } + }); + /** PASS THROUGH FROM WEBVIEW TO CORE AND BACK **/ WEBVIEW_TO_CORE_PASS_THROUGH.forEach((messageType) => { this.onWebview(messageType, async (msg) => { diff --git a/gui/src/components/BackgroundMode/AgentsList.tsx b/gui/src/components/BackgroundMode/AgentsList.tsx index dad28dbe5..a61448769 100644 --- a/gui/src/components/BackgroundMode/AgentsList.tsx +++ b/gui/src/components/BackgroundMode/AgentsList.tsx @@ -1,4 +1,4 @@ -import { Loader2 } from "lucide-react"; +import { ArrowPathIcon } from "@heroicons/react/24/outline"; import { useContext, useEffect, useState } from "react"; import { useAuth } from "../../context/Auth"; import { IdeMessengerContext } from "../../context/IdeMessenger"; @@ -62,7 +62,7 @@ export function AgentsList() { if (isLoading) { return (
- +
); } From 357c9b2bfa463a46980284dfd77cfb8e5d5607d8 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 9 Oct 2025 13:51:50 -0700 Subject: [PATCH 03/27] improv: error handling --- core/control-plane/client.ts | 34 +++++++------------ .../vscode/src/extension/VsCodeMessenger.ts | 23 +++++++------ 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts index 0cb51d468..83eaa228b 100644 --- a/core/control-plane/client.ts +++ b/core/control-plane/client.ts @@ -448,34 +448,24 @@ export class ControlPlaneClient { prompt: string, repoUrl: string, branch?: string, - ): Promise<{ id: string } | null> { + ): Promise<{ id: string }> { if (!(await this.isSignedIn())) { - return null; + throw new Error("Not signed in to Continue"); } - try { - const resp = await this.requestAndHandleError("agents/devboxes", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - prompt, - repoUrl, - branch, - }), - }); - - return (await resp.json()) as { id: string }; - } catch (e) { - Logger.error(e, { - context: "control_plane_create_background_agent", + const resp = await this.requestAndHandleError("agents/devboxes", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ prompt, repoUrl, branch, - }); - return null; - } + }), + }); + + return (await resp.json()) as { id: string }; } /** diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 409f69dc7..98a0e5e06 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -338,6 +338,12 @@ export class VsCodeMessenger { // Create the background agent try { + console.log("Creating background agent with:", { + prompt: prompt.substring(0, 50) + "...", + repoUrl, + branch, + }); + const result = await configHandler.controlPlaneClient.createBackgroundAgent( prompt, @@ -345,18 +351,15 @@ export class VsCodeMessenger { branch, ); - if (result) { - vscode.window.showInformationMessage( - `Background agent created successfully! Agent ID: ${result.id}`, - ); - } else { - vscode.window.showErrorMessage( - "Failed to create background agent. Make sure you're signed in to Continue.", - ); - } + vscode.window.showInformationMessage( + `Background agent created successfully! Agent ID: ${result.id}`, + ); } catch (e) { + console.error("Failed to create background agent:", e); + const errorMessage = + e instanceof Error ? e.message : "Unknown error occurred"; vscode.window.showErrorMessage( - `Error creating background agent: ${e instanceof Error ? e.message : "Unknown error"}`, + `Failed to create background agent: ${errorMessage}`, ); } }); From bddda3664443f975e8e26b68b9866382872da636 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 9 Oct 2025 14:12:19 -0700 Subject: [PATCH 04/27] fix: requests --- core/control-plane/client.ts | 21 +++++++++++-------- .../vscode/src/extension/VsCodeMessenger.ts | 13 ++++++++++++ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts index 83eaa228b..c299cfc1f 100644 --- a/core/control-plane/client.ts +++ b/core/control-plane/client.ts @@ -447,13 +447,14 @@ export class ControlPlaneClient { public async createBackgroundAgent( prompt: string, repoUrl: string, + name: string, branch?: string, ): Promise<{ id: string }> { if (!(await this.isSignedIn())) { throw new Error("Not signed in to Continue"); } - const resp = await this.requestAndHandleError("agents/devboxes", { + const resp = await this.requestAndHandleError("agents", { method: "POST", headers: { "Content-Type": "application/json", @@ -461,7 +462,8 @@ export class ControlPlaneClient { body: JSON.stringify({ prompt, repoUrl, - branch, + name, + branchName: branch, }), }); @@ -488,7 +490,7 @@ export class ControlPlaneClient { } try { - const resp = await this.requestAndHandleError("agents/devboxes", { + const resp = await this.requestAndHandleError("agents", { method: "GET", }); @@ -496,14 +498,15 @@ export class ControlPlaneClient { return agents.map((agent: any) => ({ id: agent.id, - name: agent.name || null, + name: agent.name || agent.metadata?.name || null, status: agent.status, - repoUrl: agent.repo_url || agent.repoUrl || "", - createdAt: new Date( - agent.created_at || agent.create_time_ms, - ).toISOString(), + repoUrl: agent.metadata?.repo_url || agent.repo_url || "", + createdAt: + agent.created_at || agent.create_time_ms + ? new Date(agent.created_at || agent.create_time_ms).toISOString() + : new Date().toISOString(), metadata: { - github_repo: agent.metadata?.github_repo || agent.repo_url, + github_repo: agent.metadata?.github_repo || agent.metadata?.repo_url, }, })); } catch (e) { diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 98a0e5e06..f847e81e2 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -336,9 +336,21 @@ export class VsCodeMessenger { return; } + // Generate a name from the prompt (first 50 chars, cleaned up) + let name = prompt.substring(0, 50).replace(/\n/g, " ").trim(); + if (prompt.length > 50) { + name += "..."; + } + // Fallback to a generic name if prompt is too short + if (name.length < 3) { + const repoName = await this.ide.getRepoName(workspaceDir); + name = `Agent for ${repoName || "repository"}`; + } + // Create the background agent try { console.log("Creating background agent with:", { + name, prompt: prompt.substring(0, 50) + "...", repoUrl, branch, @@ -348,6 +360,7 @@ export class VsCodeMessenger { await configHandler.controlPlaneClient.createBackgroundAgent( prompt, repoUrl, + name, branch, ); From 3c00349c2fe11b6da9f9bd5b4b818f337927f165 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 9 Oct 2025 14:37:35 -0700 Subject: [PATCH 05/27] fix: github connection --- .../vscode/src/extension/VsCodeMessenger.ts | 27 ++++++- .../BackgroundMode/BackgroundModeView.tsx | 75 ++++++++++++++++++- 2 files changed, 97 insertions(+), 5 deletions(-) diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index f847e81e2..9f8c7a2dc 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -371,9 +371,30 @@ export class VsCodeMessenger { console.error("Failed to create background agent:", e); const errorMessage = e instanceof Error ? e.message : "Unknown error occurred"; - vscode.window.showErrorMessage( - `Failed to create background agent: ${errorMessage}`, - ); + + // Check if this is a GitHub authorization error + if ( + errorMessage.includes("GitHub token") || + errorMessage.includes("GitHub App") + ) { + const selection = await vscode.window.showErrorMessage( + "Background agents need GitHub access. Please connect your GitHub account to Continue.", + "Connect GitHub", + "Cancel", + ); + + if (selection === "Connect GitHub") { + vscode.env.openExternal( + vscode.Uri.parse( + "https://hub.continue.dev/settings/integrations", + ), + ); + } + } else { + vscode.window.showErrorMessage( + `Failed to create background agent: ${errorMessage}`, + ); + } } }); diff --git a/gui/src/components/BackgroundMode/BackgroundModeView.tsx b/gui/src/components/BackgroundMode/BackgroundModeView.tsx index 0c3d68aa8..bbdec59e6 100644 --- a/gui/src/components/BackgroundMode/BackgroundModeView.tsx +++ b/gui/src/components/BackgroundMode/BackgroundModeView.tsx @@ -1,6 +1,10 @@ -import { RocketLaunchIcon } from "@heroicons/react/24/outline"; -import { useCallback, useState } from "react"; +import { + ExclamationTriangleIcon, + RocketLaunchIcon, +} from "@heroicons/react/24/outline"; +import { useCallback, useContext, useEffect, useState } from "react"; import { useAuth } from "../../context/Auth"; +import { IdeMessengerContext } from "../../context/IdeMessenger"; import { AgentsList } from "./AgentsList"; interface BackgroundModeViewProps { @@ -9,7 +13,10 @@ interface BackgroundModeViewProps { export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) { const { session, login } = useAuth(); + const ideMessenger = useContext(IdeMessengerContext); const [isLoggingIn, setIsLoggingIn] = useState(false); + const [showGitHubSetup, setShowGitHubSetup] = useState(false); + const [checkingGitHub, setCheckingGitHub] = useState(true); const handleSignIn = useCallback(async () => { setIsLoggingIn(true); @@ -22,6 +29,48 @@ export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) { } }, [login]); + const handleOpenGitHubSettings = useCallback(() => { + // Open the hub settings page for GitHub integration + ideMessenger.post( + "openUrl", + "https://hub.continue.dev/settings/integrations/github", + ); + }, [ideMessenger]); + + // Check if user has GitHub installations when signed in + useEffect(() => { + async function checkGitHubAuth() { + if (!session) { + setCheckingGitHub(false); + return; + } + + try { + 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", {}); + + // 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); + } catch (error: any) { + // Check if error is related to GitHub token + if ( + error?.message?.includes("GitHub token") || + error?.message?.includes("GitHub App") + ) { + setShowGitHubSetup(true); + } + } finally { + setCheckingGitHub(false); + } + } + + void checkGitHubAuth(); + }, [session, ideMessenger]); + if (!session) { return (
@@ -46,6 +95,28 @@ export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) { return (
+ {!checkingGitHub && showGitHubSetup && ( +
+
+ +
+

+ Connect GitHub +

+

+ Background agents need access to your GitHub repositories. + Connect your GitHub account to get started. +

+ +
+
+
+ )}
Agents you trigger will run in the background and appear below.
From d9c16e41033030f7825970ce59c2b0aa08cd3775 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 9 Oct 2025 15:30:21 -0700 Subject: [PATCH 06/27] feat: background agent creation --- core/control-plane/client.ts | 19 +++++++++++++------ core/protocol/ideWebview.ts | 2 +- .../vscode/src/extension/VsCodeMessenger.ts | 5 ++++- gui/src/pages/gui/Chat.tsx | 14 ++++++++++++-- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts index c299cfc1f..d98320f9a 100644 --- a/core/control-plane/client.ts +++ b/core/control-plane/client.ts @@ -449,22 +449,29 @@ export class ControlPlaneClient { repoUrl: string, name: string, branch?: string, + organizationId?: string, ): Promise<{ id: string }> { if (!(await this.isSignedIn())) { throw new Error("Not signed in to Continue"); } + const requestBody: any = { + prompt, + repoUrl, + name, + branchName: branch, + }; + + if (organizationId) { + requestBody.organizationId = organizationId; + } + const resp = await this.requestAndHandleError("agents", { method: "POST", headers: { "Content-Type": "application/json", }, - body: JSON.stringify({ - prompt, - repoUrl, - name, - branchName: branch, - }), + body: JSON.stringify(requestBody), }); return (await resp.json()) as { id: string }; diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index 0c3dfd1fc..13f012828 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -50,7 +50,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { "edit/addCurrentSelection": [undefined, void]; "edit/clearDecorations": [undefined, void]; "session/share": [{ sessionId: string }, void]; - createBackgroundAgent: [{ editorState: any }, void]; + createBackgroundAgent: [{ editorState: any; organizationId?: string }, void]; listBackgroundAgents: [ undefined, Array<{ diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 9f8c7a2dc..3afad6f95 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -265,7 +265,7 @@ export class VsCodeMessenger { this.onWebview("createBackgroundAgent", async (msg) => { const configHandler = await configHandlerPromise; - const { editorState } = msg.data; + const { editorState, organizationId } = msg.data; // Import utilities for processing editor content const { stripImages } = await import("core/util/messageContent"); @@ -347,6 +347,8 @@ export class VsCodeMessenger { name = `Agent for ${repoName || "repository"}`; } + // debugger; + // Create the background agent try { console.log("Creating background agent with:", { @@ -362,6 +364,7 @@ export class VsCodeMessenger { repoUrl, name, branch, + organizationId, ); vscode.window.showInformationMessage( diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 0d7f1a71b..c01f59726 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -31,6 +31,7 @@ import { selectDoneApplyStates, selectPendingToolCalls, } from "../../redux/selectors/selectToolCalls"; +import { selectCurrentOrg } from "../../redux/slices/profilesSlice"; import { cancelToolCall, ChatHistoryItemWithMessageId, @@ -127,6 +128,7 @@ export function Chat() { (state) => state.ui.hasDismissedExploreDialog, ); const mode = useAppSelector((state) => state.session.mode); + const currentOrg = useAppSelector(selectCurrentOrg); const jetbrains = useMemo(() => { return isJetBrains(); }, []); @@ -176,7 +178,11 @@ export function Chat() { // Handle background mode specially if (currentMode === "background" && !isCurrentlyInEdit) { // Background mode triggers agent creation instead of chat - ideMessenger.post("createBackgroundAgent", { editorState }); + const organizationId = selectCurrentOrg(stateSnapshot)?.id; + ideMessenger.post("createBackgroundAgent", { + editorState, + organizationId, + }); if (editorToClearOnSend) { editorToClearOnSend.commands.clearContent(); } @@ -473,7 +479,11 @@ export function Chat() { {mode === "background" ? ( { - ideMessenger.post("createBackgroundAgent", { prompt }); + const organizationId = currentOrg?.id; + ideMessenger.post("createBackgroundAgent", { + prompt, + organizationId, + }); }} /> ) : ( From a476c1ed7d717655f9bbaf8adb6dc1d40f1ab624 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Fri, 10 Oct 2025 11:29:19 -0700 Subject: [PATCH 07/27] fix: pass org id --- core/control-plane/client.ts | 13 ++++++++++--- core/protocol/ideWebview.ts | 2 +- extensions/vscode/src/extension/VsCodeMessenger.ts | 5 ++++- gui/src/components/BackgroundMode/AgentsList.tsx | 10 ++++++++-- .../BackgroundMode/BackgroundModeView.tsx | 2 +- gui/src/pages/gui/Chat.tsx | 4 ++-- 6 files changed, 26 insertions(+), 10 deletions(-) diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts index d98320f9a..ca2f4e1b2 100644 --- a/core/control-plane/client.ts +++ b/core/control-plane/client.ts @@ -478,9 +478,10 @@ export class ControlPlaneClient { } /** - * List all background agents for the current user + * List all background agents for the current user or organization + * @param organizationId - Optional organization ID to filter agents by organization scope */ - public async listBackgroundAgents(): Promise< + public async listBackgroundAgents(organizationId?: string): Promise< Array<{ id: string; name: string | null; @@ -497,7 +498,13 @@ export class ControlPlaneClient { } try { - const resp = await this.requestAndHandleError("agents", { + // Build URL with optional organizationId query parameter + let url = "agents"; + if (organizationId) { + url += `?organizationId=${encodeURIComponent(organizationId)}`; + } + + const resp = await this.requestAndHandleError(url, { method: "GET", }); diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index 13f012828..2376edb71 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -52,7 +52,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { "session/share": [{ sessionId: string }, void]; createBackgroundAgent: [{ editorState: any; organizationId?: string }, void]; listBackgroundAgents: [ - undefined, + { organizationId?: string }, Array<{ id: string; name: string | null; diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 3afad6f95..a3098aa74 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -403,10 +403,13 @@ export class VsCodeMessenger { this.onWebview("listBackgroundAgents", async (msg) => { const configHandler = await configHandlerPromise; + const { organizationId } = msg.data; try { const agents = - await configHandler.controlPlaneClient.listBackgroundAgents(); + await configHandler.controlPlaneClient.listBackgroundAgents( + organizationId, + ); return agents; } catch (e) { console.error("Error listing background agents:", e); diff --git a/gui/src/components/BackgroundMode/AgentsList.tsx b/gui/src/components/BackgroundMode/AgentsList.tsx index a61448769..c42ab2918 100644 --- a/gui/src/components/BackgroundMode/AgentsList.tsx +++ b/gui/src/components/BackgroundMode/AgentsList.tsx @@ -2,6 +2,8 @@ import { ArrowPathIcon } from "@heroicons/react/24/outline"; import { useContext, useEffect, useState } from "react"; import { useAuth } from "../../context/Auth"; import { IdeMessengerContext } from "../../context/IdeMessenger"; +import { useAppSelector } from "../../redux/hooks"; +import { selectCurrentOrg } from "../../redux/slices/profilesSlice"; interface Agent { id: string; @@ -17,6 +19,7 @@ interface Agent { export function AgentsList() { const { session } = useAuth(); const ideMessenger = useContext(IdeMessengerContext); + const currentOrg = useAppSelector(selectCurrentOrg); const [agents, setAgents] = useState([]); const [isLoading, setIsLoading] = useState(true); const [error, setError] = useState(null); @@ -32,7 +35,10 @@ export function AgentsList() { try { setIsLoading(true); // Request agent list from IDE - const result = await ideMessenger.request("listBackgroundAgents", {}); + const organizationId = currentOrg?.id; + const result = await ideMessenger.request("listBackgroundAgents", { + organizationId, + }); if (result && Array.isArray(result)) { setAgents(result); @@ -57,7 +63,7 @@ export function AgentsList() { }, 10000); return () => clearInterval(interval); - }, [session, ideMessenger]); + }, [session, ideMessenger, currentOrg]); if (isLoading) { return ( diff --git a/gui/src/components/BackgroundMode/BackgroundModeView.tsx b/gui/src/components/BackgroundMode/BackgroundModeView.tsx index bbdec59e6..be1635380 100644 --- a/gui/src/components/BackgroundMode/BackgroundModeView.tsx +++ b/gui/src/components/BackgroundMode/BackgroundModeView.tsx @@ -8,7 +8,7 @@ import { IdeMessengerContext } from "../../context/IdeMessenger"; import { AgentsList } from "./AgentsList"; interface BackgroundModeViewProps { - onCreateAgent: (prompt: string) => void; + onCreateAgent: (editorState: any) => void; } export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) { diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index c01f59726..892ec59f5 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -478,10 +478,10 @@ export function Chat() { {!hasDismissedExploreDialog && } {mode === "background" ? ( { + onCreateAgent={(editorState) => { const organizationId = currentOrg?.id; ideMessenger.post("createBackgroundAgent", { - prompt, + editorState, organizationId, }); }} From af992849a43b69ea1c4af2b1f8f4eae4b70c0e11 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Mon, 13 Oct 2025 14:07:39 -0700 Subject: [PATCH 08/27] 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 ( From 7212a63cb44b83ad825e3b244cb0d3835e596e92 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Mon, 13 Oct 2025 14:20:40 -0700 Subject: [PATCH 09/27] fix: urls --- extensions/vscode/src/extension/VsCodeMessenger.ts | 6 +++--- gui/src/components/BackgroundMode/AgentsList.tsx | 5 +++-- gui/src/components/BackgroundMode/BackgroundModeView.tsx | 7 +++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index a3098aa74..455a2465d 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -1,4 +1,5 @@ import { ConfigHandler } from "core/config/ConfigHandler"; +import { getControlPlaneEnv } from "core/control-plane/env"; import { DataLogger } from "core/data/log"; import { EDIT_MODE_STREAM_ID } from "core/edit/constants"; import { @@ -387,10 +388,9 @@ export class VsCodeMessenger { ); if (selection === "Connect GitHub") { + const env = await getControlPlaneEnv(this.ide.getIdeSettings()); vscode.env.openExternal( - vscode.Uri.parse( - "https://hub.continue.dev/settings/integrations", - ), + vscode.Uri.parse(`${env.APP_URL}settings/integrations`), ); } } else { diff --git a/gui/src/components/BackgroundMode/AgentsList.tsx b/gui/src/components/BackgroundMode/AgentsList.tsx index 29ff0d2fe..d61cd3b10 100644 --- a/gui/src/components/BackgroundMode/AgentsList.tsx +++ b/gui/src/components/BackgroundMode/AgentsList.tsx @@ -109,8 +109,9 @@ export function AgentsList() { className="cursor-pointer rounded-lg border border-gray-200 bg-gray-50 p-3 transition-colors hover:bg-gray-100" onClick={() => { // Open agent detail in browser - const agentUrl = `https://app.continue.dev/agents/${agent.id}`; - ideMessenger.post("openUrl", agentUrl); + ideMessenger.post("controlPlane/openUrl", { + path: `agents/${agent.id}`, + }); }} >
diff --git a/gui/src/components/BackgroundMode/BackgroundModeView.tsx b/gui/src/components/BackgroundMode/BackgroundModeView.tsx index 10df5107c..d09fbcd5e 100644 --- a/gui/src/components/BackgroundMode/BackgroundModeView.tsx +++ b/gui/src/components/BackgroundMode/BackgroundModeView.tsx @@ -31,10 +31,9 @@ export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) { const handleOpenGitHubSettings = useCallback(() => { // Open the hub settings page for GitHub integration - ideMessenger.post( - "openUrl", - "https://hub.continue.dev/settings/integrations/github", - ); + ideMessenger.post("controlPlane/openUrl", { + path: "settings/integrations/github", + }); }, [ideMessenger]); // Check if user has GitHub installations when signed in From 542efb8244f6d10976fd3d135b109e170d3b6eb7 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Mon, 13 Oct 2025 14:24:08 -0700 Subject: [PATCH 10/27] fix: urls --- extensions/vscode/src/extension/VsCodeMessenger.ts | 10 ++++++---- gui/src/components/BackgroundMode/AgentsList.tsx | 1 + .../components/BackgroundMode/BackgroundModeView.tsx | 6 +++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 455a2465d..2cfda4608 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -1,5 +1,4 @@ import { ConfigHandler } from "core/config/ConfigHandler"; -import { getControlPlaneEnv } from "core/control-plane/env"; import { DataLogger } from "core/data/log"; import { EDIT_MODE_STREAM_ID } from "core/edit/constants"; import { @@ -388,9 +387,12 @@ export class VsCodeMessenger { ); if (selection === "Connect GitHub") { - const env = await getControlPlaneEnv(this.ide.getIdeSettings()); - vscode.env.openExternal( - vscode.Uri.parse(`${env.APP_URL}settings/integrations`), + await this.inProcessMessenger.externalRequest( + "controlPlane/openUrl", + { + path: "settings/integrations", + orgSlug: configHandler.currentOrg?.slug, + }, ); } } else { diff --git a/gui/src/components/BackgroundMode/AgentsList.tsx b/gui/src/components/BackgroundMode/AgentsList.tsx index d61cd3b10..6bb160617 100644 --- a/gui/src/components/BackgroundMode/AgentsList.tsx +++ b/gui/src/components/BackgroundMode/AgentsList.tsx @@ -111,6 +111,7 @@ export function AgentsList() { // Open agent detail in browser ideMessenger.post("controlPlane/openUrl", { path: `agents/${agent.id}`, + orgSlug: currentOrg?.slug, }); }} > diff --git a/gui/src/components/BackgroundMode/BackgroundModeView.tsx b/gui/src/components/BackgroundMode/BackgroundModeView.tsx index d09fbcd5e..1abd94d01 100644 --- a/gui/src/components/BackgroundMode/BackgroundModeView.tsx +++ b/gui/src/components/BackgroundMode/BackgroundModeView.tsx @@ -5,6 +5,8 @@ import { import { useCallback, useContext, useEffect, useState } from "react"; import { useAuth } from "../../context/Auth"; import { IdeMessengerContext } from "../../context/IdeMessenger"; +import { useAppSelector } from "../../redux/hooks"; +import { selectCurrentOrg } from "../../redux/slices/profilesSlice"; import { AgentsList } from "./AgentsList"; interface BackgroundModeViewProps { @@ -14,6 +16,7 @@ interface BackgroundModeViewProps { export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) { const { session, login } = useAuth(); const ideMessenger = useContext(IdeMessengerContext); + const currentOrg = useAppSelector(selectCurrentOrg); const [isLoggingIn, setIsLoggingIn] = useState(false); const [showGitHubSetup, setShowGitHubSetup] = useState(false); const [checkingGitHub, setCheckingGitHub] = useState(true); @@ -33,8 +36,9 @@ export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) { // Open the hub settings page for GitHub integration ideMessenger.post("controlPlane/openUrl", { path: "settings/integrations/github", + orgSlug: currentOrg?.slug, }); - }, [ideMessenger]); + }, [ideMessenger, currentOrg]); // Check if user has GitHub installations when signed in useEffect(() => { From ae25084c3cf1fccba57e585a99adf160480aa6b6 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Mon, 13 Oct 2025 15:47:50 -0700 Subject: [PATCH 11/27] fix: urls --- core/core.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/core.ts b/core/core.ts index 0d1b5ffba..082694f49 100644 --- a/core/core.ts +++ b/core/core.ts @@ -472,9 +472,11 @@ export class Core { const urlPath = msg.data.path.startsWith("/") ? msg.data.path.slice(1) : msg.data.path; - let url = `${env.APP_URL}${urlPath}`; + let url; if (msg.data.orgSlug) { - url += `?org=${msg.data.orgSlug}`; + url = `${env.APP_URL}organizations/${msg.data.orgSlug}/${urlPath}`; + } else { + url = `${env.APP_URL}${urlPath}`; } await this.messenger.request("openUrl", url); }); From 8c0b215faf0a5c92c4a7d7e106326b13b26b5d0c Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Mon, 13 Oct 2025 16:02:19 -0700 Subject: [PATCH 12/27] fix: local agents --- gui/src/components/ModeSelect/ModeSelect.tsx | 29 +++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/gui/src/components/ModeSelect/ModeSelect.tsx b/gui/src/components/ModeSelect/ModeSelect.tsx index 19904d8d3..4a9c2616a 100644 --- a/gui/src/components/ModeSelect/ModeSelect.tsx +++ b/gui/src/components/ModeSelect/ModeSelect.tsx @@ -8,6 +8,7 @@ import { MessageModes } from "core"; import { isRecommendedAgentModel } from "core/llm/toolSupport"; import { capitalize } from "lodash"; import { useCallback, useEffect, useMemo } from "react"; +import { useAuth } from "../../context/Auth"; import { useAppDispatch, useAppSelector } from "../../redux/hooks"; import { selectSelectedChatModel } from "../../redux/slices/configSlice"; import { setMode } from "../../redux/slices/sessionSlice"; @@ -21,6 +22,7 @@ export function ModeSelect() { const dispatch = useAppDispatch(); const mode = useAppSelector((store) => store.session.mode); const selectedModel = useAppSelector(selectSelectedChatModel); + const { selectedProfile } = useAuth(); const isGoodAtAgentMode = useMemo(() => { if (!selectedModel) { @@ -29,6 +31,10 @@ export function ModeSelect() { return isRecommendedAgentModel(selectedModel.model); }, [selectedModel]); + const isLocalAgent = useMemo(() => { + return selectedProfile?.profileType === "local"; + }, [selectedProfile]); + const { mainEditor } = useMainEditor(); const metaKeyLabel = useMemo(() => { return getMetaKeyLabel(); @@ -40,7 +46,8 @@ export function ModeSelect() { } else if (mode === "plan") { dispatch(setMode("agent")); } else if (mode === "agent") { - dispatch(setMode("background")); + // Skip background mode if local agent is selected + dispatch(setMode(isLocalAgent ? "chat" : "background")); } else { dispatch(setMode("chat")); } @@ -48,7 +55,7 @@ export function ModeSelect() { if (!document.activeElement?.classList?.contains("ProseMirror")) { mainEditor?.commands.focus(); } - }, [mode, mainEditor]); + }, [mode, mainEditor, isLocalAgent]); const selectMode = useCallback( (newMode: MessageModes) => { @@ -75,6 +82,13 @@ export function ModeSelect() { return () => document.removeEventListener("keydown", handleKeyDown); }, [cycleMode]); + // Auto-switch from background mode when local agent is selected + useEffect(() => { + if (mode === "background" && isLocalAgent) { + dispatch(setMode("agent")); + } + }, [mode, isLocalAgent, dispatch]); + const notGreatAtAgent = ( <> - +
Background @@ -181,11 +199,14 @@ export function ModeSelect() { style={{ zIndex: 200001, }} - content="Trigger background agents" + content={"Background mode cannot be used with local agents."} >
+ {isLocalAgent && ( + + )} From 9306b95016dae8456cd4a645f7ff999503990c78 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Mon, 13 Oct 2025 16:17:43 -0700 Subject: [PATCH 13/27] fix: personal agents --- gui/src/pages/gui/Chat.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 892ec59f5..e654a6e1e 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -178,7 +178,9 @@ export function Chat() { // Handle background mode specially if (currentMode === "background" && !isCurrentlyInEdit) { // Background mode triggers agent creation instead of chat - const organizationId = selectCurrentOrg(stateSnapshot)?.id; + const currentOrg = selectCurrentOrg(stateSnapshot); + const organizationId = + currentOrg?.id !== "personal" ? currentOrg?.id : undefined; ideMessenger.post("createBackgroundAgent", { editorState, organizationId, @@ -479,7 +481,8 @@ export function Chat() { {mode === "background" ? ( { - const organizationId = currentOrg?.id; + const organizationId = + currentOrg?.id !== "personal" ? currentOrg?.id : undefined; ideMessenger.post("createBackgroundAgent", { editorState, organizationId, From c2088f76b969c83395399083b8da953d724bfb08 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Mon, 13 Oct 2025 16:27:53 -0700 Subject: [PATCH 14/27] fix: load agents --- gui/src/components/BackgroundMode/AgentsList.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gui/src/components/BackgroundMode/AgentsList.tsx b/gui/src/components/BackgroundMode/AgentsList.tsx index 6bb160617..e3a2cdea8 100644 --- a/gui/src/components/BackgroundMode/AgentsList.tsx +++ b/gui/src/components/BackgroundMode/AgentsList.tsx @@ -35,7 +35,8 @@ export function AgentsList() { try { setIsLoading(true); // Request agent list from IDE - const organizationId = currentOrg?.id; + const organizationId = + currentOrg?.id !== "personal" ? currentOrg?.id : undefined; const result = await ideMessenger.request("listBackgroundAgents", { organizationId, }); From 425c3eb20df29f9c70617cfdec507f7711935ecb Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Mon, 13 Oct 2025 16:36:27 -0700 Subject: [PATCH 15/27] improv: styles --- .../components/BackgroundMode/AgentsList.tsx | 30 +++++++++---------- .../BackgroundMode/BackgroundModeView.tsx | 8 ++--- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/gui/src/components/BackgroundMode/AgentsList.tsx b/gui/src/components/BackgroundMode/AgentsList.tsx index e3a2cdea8..f663bbf50 100644 --- a/gui/src/components/BackgroundMode/AgentsList.tsx +++ b/gui/src/components/BackgroundMode/AgentsList.tsx @@ -77,14 +77,14 @@ export function AgentsList() { if (isLoading) { return (
- +
); } if (error) { return ( -
+
Error loading agents: {error}
); @@ -92,7 +92,7 @@ export function AgentsList() { if (agents.length === 0) { return ( -
+
No background agents yet. Submit a message above to create one.
); @@ -100,14 +100,14 @@ export function AgentsList() { return (
-
+
Recent Agents
{agents.map((agent) => (
{ // Open agent detail in browser ideMessenger.post("controlPlane/openUrl", { @@ -118,10 +118,10 @@ export function AgentsList() { >
-
+
{agent.name || "Unnamed Agent"}
-
+
{agent.metadata?.github_repo || agent.repoUrl}
@@ -129,7 +129,7 @@ export function AgentsList() {
-
+
{formatRelativeTime(agent.createdAt)}
@@ -141,18 +141,18 @@ export function AgentsList() { function AgentStatusBadge({ status }: { status: string }) { const statusColors: Record = { - running: "bg-green-100 text-green-800", - pending: "bg-yellow-100 text-yellow-800", - creating: "bg-blue-100 text-blue-800", - failure: "bg-red-100 text-red-800", - suspended: "bg-gray-100 text-gray-800", + running: "border-success text-success", + pending: "border-warning text-warning", + creating: "border-info text-info", + failure: "border-error text-error", + suspended: "border-description text-description", }; - const color = statusColors[status] || "bg-gray-100 text-gray-800"; + const color = statusColors[status] || "border-description text-description"; return ( {status} diff --git a/gui/src/components/BackgroundMode/BackgroundModeView.tsx b/gui/src/components/BackgroundMode/BackgroundModeView.tsx index 1abd94d01..fe5105e37 100644 --- a/gui/src/components/BackgroundMode/BackgroundModeView.tsx +++ b/gui/src/components/BackgroundMode/BackgroundModeView.tsx @@ -86,17 +86,17 @@ export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) { if (!session) { return (
- +

Background Agents

-

+

Trigger long-running background agents that work on your codebase autonomously. Sign in to Continue to get started.

@@ -129,7 +129,7 @@ export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) {
)} -
+
Agents you trigger will run in the background and appear below.
From 8fb46fe39275759a8b55254c89c0e1acb28e3a9e Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Mon, 13 Oct 2025 16:38:05 -0700 Subject: [PATCH 16/27] fix: agents --- gui/src/components/BackgroundMode/AgentsList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/components/BackgroundMode/AgentsList.tsx b/gui/src/components/BackgroundMode/AgentsList.tsx index f663bbf50..216026176 100644 --- a/gui/src/components/BackgroundMode/AgentsList.tsx +++ b/gui/src/components/BackgroundMode/AgentsList.tsx @@ -103,7 +103,7 @@ export function AgentsList() {
Recent Agents
-
+
{agents.map((agent) => (
Date: Mon, 13 Oct 2025 16:56:53 -0700 Subject: [PATCH 17/27] improv: ui / ux --- .../components/BackgroundMode/AgentsList.tsx | 10 +++-- .../BackgroundMode/BackgroundModeView.tsx | 22 +++++++++-- gui/src/pages/gui/Chat.tsx | 37 +++++++++++++------ 3 files changed, 50 insertions(+), 19 deletions(-) diff --git a/gui/src/components/BackgroundMode/AgentsList.tsx b/gui/src/components/BackgroundMode/AgentsList.tsx index 216026176..7e45ee2c1 100644 --- a/gui/src/components/BackgroundMode/AgentsList.tsx +++ b/gui/src/components/BackgroundMode/AgentsList.tsx @@ -16,7 +16,11 @@ interface Agent { }; } -export function AgentsList() { +interface AgentsListProps { + isCreatingAgent?: boolean; +} + +export function AgentsList({ isCreatingAgent = false }: AgentsListProps) { const { session } = useAuth(); const ideMessenger = useContext(IdeMessengerContext); const currentOrg = useAppSelector(selectCurrentOrg); @@ -93,7 +97,7 @@ export function AgentsList() { if (agents.length === 0) { return (
- No background agents yet. Submit a message above to create one. + No background tasks yet. Submit a message above to create one.
); } @@ -101,7 +105,7 @@ export function AgentsList() { return (
- Recent Agents + Background Tasks
{agents.map((agent) => ( diff --git a/gui/src/components/BackgroundMode/BackgroundModeView.tsx b/gui/src/components/BackgroundMode/BackgroundModeView.tsx index fe5105e37..fdcf92bcd 100644 --- a/gui/src/components/BackgroundMode/BackgroundModeView.tsx +++ b/gui/src/components/BackgroundMode/BackgroundModeView.tsx @@ -1,4 +1,5 @@ import { + ArrowPathIcon, ExclamationTriangleIcon, RocketLaunchIcon, } from "@heroicons/react/24/outline"; @@ -11,9 +12,13 @@ import { AgentsList } from "./AgentsList"; interface BackgroundModeViewProps { onCreateAgent: (editorState: any) => void; + isCreatingAgent?: boolean; } -export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) { +export function BackgroundModeView({ + onCreateAgent, + isCreatingAgent = false, +}: BackgroundModeViewProps) { const { session, login } = useAuth(); const ideMessenger = useContext(IdeMessengerContext); const currentOrg = useAppSelector(selectCurrentOrg); @@ -129,10 +134,19 @@ export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) {
)} -
- Agents you trigger will run in the background and appear below. +
+
+ Submit a task above to run a background agent. Your task will appear + below in ~30 seconds once the container starts. +
+ {isCreatingAgent && ( +
+ + Creating task... +
+ )}
- +
); } diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index e654a6e1e..1b22647c9 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -110,6 +110,7 @@ export function Chat() { ); const isStreaming = useAppSelector((state) => state.session.isStreaming); const [stepsOpen] = useState<(boolean | undefined)[]>([]); + const [isCreatingAgent, setIsCreatingAgent] = useState(false); const mainTextInputRef = useRef(null); const stepsDivRef = useRef(null); const tabsRef = useRef(null); @@ -181,13 +182,28 @@ export function Chat() { const currentOrg = selectCurrentOrg(stateSnapshot); const organizationId = currentOrg?.id !== "personal" ? currentOrg?.id : undefined; - ideMessenger.post("createBackgroundAgent", { - editorState, - organizationId, - }); + + setIsCreatingAgent(true); + + // Clear input immediately for better UX if (editorToClearOnSend) { editorToClearOnSend.commands.clearContent(); } + + // Create agent and track loading state + (async () => { + try { + await ideMessenger.request("createBackgroundAgent", { + editorState, + organizationId, + }); + setIsCreatingAgent(false); + } catch (error) { + console.error("Failed to create background agent:", error); + setIsCreatingAgent(false); + } + })(); + return; } @@ -257,7 +273,7 @@ export function Chat() { } } }, - [dispatch, ideMessenger, reduxStore], + [dispatch, ideMessenger, reduxStore, setIsCreatingAgent], ); useWebviewListener( @@ -480,14 +496,11 @@ export function Chat() { {!hasDismissedExploreDialog && } {mode === "background" ? ( { - const organizationId = - currentOrg?.id !== "personal" ? currentOrg?.id : undefined; - ideMessenger.post("createBackgroundAgent", { - editorState, - organizationId, - }); + onCreateAgent={() => { + // This callback is kept for compatibility but not used + // Agent creation is now handled in sendInput for better loading state management }} + isCreatingAgent={isCreatingAgent} /> ) : ( history.length === 0 && ( From a83d281fbcb939b78275430cd5af0f25e8297b94 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Mon, 13 Oct 2025 17:06:58 -0700 Subject: [PATCH 18/27] improv: use void --- gui/src/pages/gui/Chat.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 1b22647c9..98956d1c1 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -191,7 +191,7 @@ export function Chat() { } // Create agent and track loading state - (async () => { + void (async () => { try { await ideMessenger.request("createBackgroundAgent", { editorState, From 5adcf1e7c6b323410adc40d90fc647756e9ae267 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Mon, 13 Oct 2025 17:14:17 -0700 Subject: [PATCH 19/27] fix: failing tests --- gui/src/context/MockIdeMessenger.ts | 30 ++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/gui/src/context/MockIdeMessenger.ts b/gui/src/context/MockIdeMessenger.ts index e2e8a8ec9..6bc645942 100644 --- a/gui/src/context/MockIdeMessenger.ts +++ b/gui/src/context/MockIdeMessenger.ts @@ -56,14 +56,37 @@ const DEFAULT_MOCK_CORE_RESPONSES: MockResponses = { }, }, "config/getSerializedProfileInfo": { - organizations: [], - profileId: "test-profile", + organizations: [ + { + id: "personal", + profiles: [ + { + title: "Local Agent", + id: "local", + errors: [], + profileType: "local", + uri: "", + iconUrl: "", + fullSlug: { + ownerSlug: "", + packageSlug: "", + versionSlug: "", + }, + }, + ], + slug: "", + selectedProfileId: "local", + name: "Personal", + iconUrl: "", + }, + ], + profileId: "local", result: { config: undefined, errors: [], configLoadInterrupted: false, }, - selectedOrgId: "local", + selectedOrgId: "personal", }, "chatDescriber/describe": "Session summary", applyToFile: undefined, @@ -102,6 +125,7 @@ const DEFAULT_MOCK_CORE_RESPONSES: MockResponses = { }, }, ], + listBackgroundAgents: [], }; const DEFAULT_MOCK_CORE_RESPONSE_HANDLERS: MockResponseHandlers = { From b83133b835206144015fddda78b2ae46fe92f077 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Mon, 13 Oct 2025 17:46:33 -0700 Subject: [PATCH 20/27] improv: add context handling --- core/control-plane/client.ts | 21 +++++++++++++ core/protocol/ideWebview.ts | 12 +++++++- .../vscode/src/extension/VsCodeMessenger.ts | 30 +++++-------------- gui/src/pages/gui/Chat.tsx | 21 ++++++++++++- 4 files changed, 60 insertions(+), 24 deletions(-) diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts index ca2f4e1b2..76470e2ce 100644 --- a/core/control-plane/client.ts +++ b/core/control-plane/client.ts @@ -450,6 +450,8 @@ export class ControlPlaneClient { name: string, branch?: string, organizationId?: string, + contextItems?: any[], + selectedCode?: any[], ): Promise<{ id: string }> { if (!(await this.isSignedIn())) { throw new Error("Not signed in to Continue"); @@ -466,6 +468,25 @@ export class ControlPlaneClient { requestBody.organizationId = organizationId; } + // Include context items if provided + if (contextItems && contextItems.length > 0) { + requestBody.contextItems = contextItems.map((item) => ({ + content: item.content, + description: item.description, + name: item.name, + uri: item.uri, + })); + } + + // Include selected code if provided + if (selectedCode && selectedCode.length > 0) { + requestBody.selectedCode = selectedCode.map((code) => ({ + filepath: code.filepath, + range: code.range, + contents: code.contents, + })); + } + const resp = await this.requestAndHandleError("agents", { method: "POST", headers: { diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index 2376edb71..c5d52a2a0 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -6,8 +6,10 @@ import { AddToChatPayload, ApplyState, ApplyToFilePayload, + ContextItemWithId, HighlightedCodePayload, MessageContent, + RangeInFile, RangeInFileWithContents, SetCodeToEditPayload, ShowFilePayload, @@ -50,7 +52,15 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { "edit/addCurrentSelection": [undefined, void]; "edit/clearDecorations": [undefined, void]; "session/share": [{ sessionId: string }, void]; - createBackgroundAgent: [{ editorState: any; organizationId?: string }, void]; + createBackgroundAgent: [ + { + content: MessageContent; + contextItems: ContextItemWithId[]; + selectedCode: RangeInFile[]; + organizationId?: string; + }, + void, + ]; listBackgroundAgents: [ { organizationId?: string }, Array<{ diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 2cfda4608..7e14bdd71 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -265,30 +265,12 @@ export class VsCodeMessenger { this.onWebview("createBackgroundAgent", async (msg) => { const configHandler = await configHandlerPromise; - const { editorState, organizationId } = msg.data; + const { content, contextItems, selectedCode, organizationId } = msg.data; - // Import utilities for processing editor content - const { stripImages } = await import("core/util/messageContent"); + // Convert resolved content to plain text prompt + const prompt = stripImages(content); - // Extract text from editor state - // editorState is a TipTap JSONContent object - let prompt = ""; - if (editorState && editorState.content) { - // Simple extraction - concatenate text from paragraphs - for (const node of editorState.content) { - if (node.type === "paragraph" && node.content) { - for (const child of node.content) { - if (child.type === "text" && child.text) { - prompt += child.text; - } - } - prompt += "\n"; - } - } - prompt = prompt.trim(); - } - - if (!prompt) { + if (!prompt || prompt.trim().length === 0) { vscode.window.showErrorMessage( "Please enter a prompt to create a background agent", ); @@ -356,6 +338,8 @@ export class VsCodeMessenger { prompt: prompt.substring(0, 50) + "...", repoUrl, branch, + contextItemsCount: contextItems?.length || 0, + selectedCodeCount: selectedCode?.length || 0, }); const result = @@ -365,6 +349,8 @@ export class VsCodeMessenger { name, branch, organizationId, + contextItems, + selectedCode, ); vscode.window.showInformationMessage( diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 98956d1c1..71614487e 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -49,6 +49,7 @@ import { BackgroundModeView } from "../../components/BackgroundMode/BackgroundMo import { CliInstallBanner } from "../../components/CliInstallBanner"; import { FatalErrorIndicator } from "../../components/config/FatalErrorNotice"; import InlineErrorMessage from "../../components/mainInput/InlineErrorMessage"; +import { resolveEditorContent } from "../../components/mainInput/TipTapEditor/utils/resolveEditorContent"; import { RootState } from "../../redux/store"; import { cancelStream } from "../../redux/thunks/cancelStream"; import { EmptyChatBody } from "./EmptyChatBody"; @@ -193,8 +194,26 @@ export function Chat() { // Create agent and track loading state void (async () => { try { + // Resolve context items from editor content (same as normal chat) + const defaultContextProviders = + stateSnapshot.config.config.experimental?.defaultContext ?? []; + + const { selectedContextItems, selectedCode, content } = + await resolveEditorContent({ + editorState, + modifiers, + ideMessenger, + defaultContextProviders, + availableSlashCommands: + stateSnapshot.config.config.slashCommands, + dispatch, + getState: () => reduxStore.getState(), + }); + await ideMessenger.request("createBackgroundAgent", { - editorState, + content, + contextItems: selectedContextItems, + selectedCode, organizationId, }); setIsCreatingAgent(false); From 008fff9ab07d42ac81c1c3184dd1137d8239fe58 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Mon, 13 Oct 2025 18:07:51 -0700 Subject: [PATCH 21/27] improv: clean up code --- .../components/BackgroundMode/AgentsList.tsx | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/gui/src/components/BackgroundMode/AgentsList.tsx b/gui/src/components/BackgroundMode/AgentsList.tsx index 7e45ee2c1..07d3de045 100644 --- a/gui/src/components/BackgroundMode/AgentsList.tsx +++ b/gui/src/components/BackgroundMode/AgentsList.tsx @@ -24,35 +24,26 @@ export function AgentsList({ isCreatingAgent = false }: AgentsListProps) { const { session } = useAuth(); const ideMessenger = useContext(IdeMessengerContext); const currentOrg = useAppSelector(selectCurrentOrg); - const [agents, setAgents] = useState([]); - const [isLoading, setIsLoading] = useState(true); + const [agents, setAgents] = useState(null); const [error, setError] = useState(null); useEffect(() => { async function fetchAgents() { if (!session) { setAgents([]); - setIsLoading(false); return; } try { - setIsLoading(true); - // Request agent list from IDE const organizationId = currentOrg?.id !== "personal" ? currentOrg?.id : undefined; const result = await ideMessenger.request("listBackgroundAgents", { organizationId, }); - // Handle wrapped response format if ("status" in result && result.status === "success") { - if (Array.isArray(result.content)) { - setAgents(result.content); - setError(null); - } else { - setAgents([]); - } + setAgents(Array.isArray(result.content) ? result.content : []); + setError(null); } else if ("error" in result) { setError(result.error); setAgents([]); @@ -63,8 +54,6 @@ export function AgentsList({ isCreatingAgent = false }: AgentsListProps) { console.error("Failed to fetch agents:", err); setError(err.message || "Failed to load agents"); setAgents([]); - } finally { - setIsLoading(false); } } @@ -78,14 +67,6 @@ export function AgentsList({ isCreatingAgent = false }: AgentsListProps) { return () => clearInterval(interval); }, [session, ideMessenger, currentOrg]); - if (isLoading) { - return ( -
- -
- ); - } - if (error) { return (
@@ -94,6 +75,14 @@ export function AgentsList({ isCreatingAgent = false }: AgentsListProps) { ); } + if (agents === null) { + return ( +
+ +
+ ); + } + if (agents.length === 0) { return (
From fd28478e7082d20b60f07045c7a62e0aefd85de8 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Mon, 13 Oct 2025 18:12:16 -0700 Subject: [PATCH 22/27] improv: clean up code --- gui/src/components/BackgroundMode/BackgroundModeView.tsx | 2 -- gui/src/pages/gui/Chat.tsx | 8 +------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/gui/src/components/BackgroundMode/BackgroundModeView.tsx b/gui/src/components/BackgroundMode/BackgroundModeView.tsx index fdcf92bcd..db917b651 100644 --- a/gui/src/components/BackgroundMode/BackgroundModeView.tsx +++ b/gui/src/components/BackgroundMode/BackgroundModeView.tsx @@ -11,12 +11,10 @@ import { selectCurrentOrg } from "../../redux/slices/profilesSlice"; import { AgentsList } from "./AgentsList"; interface BackgroundModeViewProps { - onCreateAgent: (editorState: any) => void; isCreatingAgent?: boolean; } export function BackgroundModeView({ - onCreateAgent, isCreatingAgent = false, }: BackgroundModeViewProps) { const { session, login } = useAuth(); diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 71614487e..113cbf71d 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -514,13 +514,7 @@ export function Chat() { {!hasDismissedExploreDialog && } {mode === "background" ? ( - { - // This callback is kept for compatibility but not used - // Agent creation is now handled in sendInput for better loading state management - }} - isCreatingAgent={isCreatingAgent} - /> + ) : ( history.length === 0 && ( From 608fbdf80e34c0c104af5c40c8d7de6ce6b37d95 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Mon, 13 Oct 2025 18:27:59 -0700 Subject: [PATCH 23/27] improv: ui, pagination --- core/control-plane/client.ts | 63 ++++++++++++------- core/protocol/ideWebview.ts | 25 ++++---- .../vscode/src/extension/VsCodeMessenger.ts | 9 +-- .../components/BackgroundMode/AgentsList.tsx | 28 ++++++++- 4 files changed, 86 insertions(+), 39 deletions(-) diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts index 76470e2ce..43fea391a 100644 --- a/core/control-plane/client.ts +++ b/core/control-plane/client.ts @@ -501,9 +501,13 @@ export class ControlPlaneClient { /** * List all background agents for the current user or organization * @param organizationId - Optional organization ID to filter agents by organization scope + * @param limit - Optional limit for number of agents to return (default: 5) */ - public async listBackgroundAgents(organizationId?: string): Promise< - Array<{ + public async listBackgroundAgents( + organizationId?: string, + limit?: number, + ): Promise<{ + agents: Array<{ id: string; name: string | null; status: string; @@ -512,43 +516,56 @@ export class ControlPlaneClient { metadata?: { github_repo?: string; }; - }> - > { + }>; + totalCount: number; + }> { if (!(await this.isSignedIn())) { - return []; + return { agents: [], totalCount: 0 }; } try { - // Build URL with optional organizationId query parameter - let url = "agents"; + // Build URL with query parameters + const params = new URLSearchParams(); if (organizationId) { - url += `?organizationId=${encodeURIComponent(organizationId)}`; + params.set("organizationId", organizationId); } + if (limit !== undefined) { + params.set("limit", limit.toString()); + } + + const url = `agents${params.toString() ? `?${params.toString()}` : ""}`; const resp = await this.requestAndHandleError(url, { method: "GET", }); - const agents = (await resp.json()) as any[]; + const result = (await resp.json()) as { + agents: any[]; + totalCount: number; + }; - return agents.map((agent: any) => ({ - id: agent.id, - name: agent.name || agent.metadata?.name || null, - status: agent.status, - repoUrl: agent.metadata?.repo_url || agent.repo_url || "", - createdAt: - agent.created_at || agent.create_time_ms - ? new Date(agent.created_at || agent.create_time_ms).toISOString() - : new Date().toISOString(), - metadata: { - github_repo: agent.metadata?.github_repo || agent.metadata?.repo_url, - }, - })); + return { + agents: result.agents.map((agent: any) => ({ + id: agent.id, + name: agent.name || agent.metadata?.name || null, + status: agent.status, + repoUrl: agent.metadata?.repo_url || agent.repo_url || "", + createdAt: + agent.created_at || agent.create_time_ms + ? new Date(agent.created_at || agent.create_time_ms).toISOString() + : new Date().toISOString(), + metadata: { + github_repo: + agent.metadata?.github_repo || agent.metadata?.repo_url, + }, + })), + totalCount: result.totalCount, + }; } catch (e) { Logger.error(e, { context: "control_plane_list_background_agents", }); - return []; + return { agents: [], totalCount: 0 }; } } } diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index c5d52a2a0..8efb1a8d2 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -62,17 +62,20 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { void, ]; listBackgroundAgents: [ - { organizationId?: string }, - Array<{ - id: string; - name: string | null; - status: string; - repoUrl: string; - createdAt: string; - metadata?: { - github_repo?: string; - }; - }>, + { organizationId?: string; limit?: number }, + { + agents: Array<{ + id: string; + name: string | null; + status: string; + repoUrl: string; + createdAt: string; + metadata?: { + github_repo?: string; + }; + }>; + totalCount: number; + }, ]; }; diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 7e14bdd71..02679e0ab 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -391,17 +391,18 @@ export class VsCodeMessenger { this.onWebview("listBackgroundAgents", async (msg) => { const configHandler = await configHandlerPromise; - const { organizationId } = msg.data; + const { organizationId, limit } = msg.data; try { - const agents = + const result = await configHandler.controlPlaneClient.listBackgroundAgents( organizationId, + limit, ); - return agents; + return result; } catch (e) { console.error("Error listing background agents:", e); - return []; + return { agents: [], totalCount: 0 }; } }); diff --git a/gui/src/components/BackgroundMode/AgentsList.tsx b/gui/src/components/BackgroundMode/AgentsList.tsx index 07d3de045..ee1468b91 100644 --- a/gui/src/components/BackgroundMode/AgentsList.tsx +++ b/gui/src/components/BackgroundMode/AgentsList.tsx @@ -25,12 +25,14 @@ export function AgentsList({ isCreatingAgent = false }: AgentsListProps) { const ideMessenger = useContext(IdeMessengerContext); const currentOrg = useAppSelector(selectCurrentOrg); const [agents, setAgents] = useState(null); + const [totalCount, setTotalCount] = useState(0); const [error, setError] = useState(null); useEffect(() => { async function fetchAgents() { if (!session) { setAgents([]); + setTotalCount(0); return; } @@ -39,21 +41,30 @@ export function AgentsList({ isCreatingAgent = false }: AgentsListProps) { currentOrg?.id !== "personal" ? currentOrg?.id : undefined; const result = await ideMessenger.request("listBackgroundAgents", { organizationId, + limit: 5, }); if ("status" in result && result.status === "success") { - setAgents(Array.isArray(result.content) ? result.content : []); + const content = result.content as { + agents: Agent[]; + totalCount: number; + }; + setAgents(content.agents || []); + setTotalCount(content.totalCount || 0); setError(null); } else if ("error" in result) { setError(result.error); setAgents([]); + setTotalCount(0); } else { setAgents([]); + setTotalCount(0); } } catch (err: any) { console.error("Failed to fetch agents:", err); setError(err.message || "Failed to load agents"); setAgents([]); + setTotalCount(0); } } @@ -127,6 +138,21 @@ export function AgentsList({ isCreatingAgent = false }: AgentsListProps) {
))} + {totalCount > agents.length && ( +
+ +
+ )}
); From cee03bf46951e81dc2753510c9d52b328802b571 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Tue, 14 Oct 2025 09:27:04 -0700 Subject: [PATCH 24/27] fix: type errors --- gui/src/context/MockIdeMessenger.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/context/MockIdeMessenger.ts b/gui/src/context/MockIdeMessenger.ts index 6bc645942..e23abc446 100644 --- a/gui/src/context/MockIdeMessenger.ts +++ b/gui/src/context/MockIdeMessenger.ts @@ -125,7 +125,7 @@ const DEFAULT_MOCK_CORE_RESPONSES: MockResponses = { }, }, ], - listBackgroundAgents: [], + listBackgroundAgents: { agents: [], totalCount: 0 }, }; const DEFAULT_MOCK_CORE_RESPONSE_HANDLERS: MockResponseHandlers = { From 01efdd15a9c87ed7119d0878fea378e894141e3e Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Tue, 14 Oct 2025 13:22:21 -0700 Subject: [PATCH 25/27] fix: specify agent --- core/control-plane/client.ts | 6 ++++++ core/protocol/ideWebview.ts | 1 + .../vscode/src/extension/VsCodeMessenger.ts | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts index 43fea391a..d33374565 100644 --- a/core/control-plane/client.ts +++ b/core/control-plane/client.ts @@ -452,6 +452,7 @@ export class ControlPlaneClient { organizationId?: string, contextItems?: any[], selectedCode?: any[], + agent?: string, ): Promise<{ id: string }> { if (!(await this.isSignedIn())) { throw new Error("Not signed in to Continue"); @@ -487,6 +488,11 @@ export class ControlPlaneClient { })); } + // Include agent configuration if provided + if (agent) { + requestBody.agent = agent; + } + const resp = await this.requestAndHandleError("agents", { method: "POST", headers: { diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index 8efb1a8d2..c61844cca 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -58,6 +58,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { contextItems: ContextItemWithId[]; selectedCode: RangeInFile[]; organizationId?: string; + agent?: string; }, void, ]; diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 02679e0ab..d16e2a0e6 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -1,3 +1,4 @@ +import { encodeFullSlug } from "@continuedev/config-yaml"; import { ConfigHandler } from "core/config/ConfigHandler"; import { DataLogger } from "core/data/log"; import { EDIT_MODE_STREAM_ID } from "core/edit/constants"; @@ -331,6 +332,22 @@ export class VsCodeMessenger { // debugger; + // Get the current agent configuration from the selected profile + let agent: string | undefined; + try { + const currentProfile = configHandler.currentProfile; + if ( + currentProfile && + currentProfile.profileDescription.profileType !== "local" + ) { + // Encode the full slug to pass as the agent parameter + agent = encodeFullSlug(currentProfile.profileDescription.fullSlug); + } + } catch (e) { + console.error("Error getting agent configuration from profile:", e); + // Continue without agent config - will use default + } + // Create the background agent try { console.log("Creating background agent with:", { @@ -340,6 +357,7 @@ export class VsCodeMessenger { branch, contextItemsCount: contextItems?.length || 0, selectedCodeCount: selectedCode?.length || 0, + agent: agent || "default", }); const result = @@ -351,6 +369,7 @@ export class VsCodeMessenger { organizationId, contextItems, selectedCode, + agent, ); vscode.window.showInformationMessage( From f4d35c29ce537e20ca5d59a99e5523e2f82763f8 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Tue, 14 Oct 2025 13:32:32 -0700 Subject: [PATCH 26/27] fix: broken imports --- extensions/vscode/src/extension/VsCodeMessenger.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index d16e2a0e6..7c855100c 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -1,4 +1,3 @@ -import { encodeFullSlug } from "@continuedev/config-yaml"; import { ConfigHandler } from "core/config/ConfigHandler"; import { DataLogger } from "core/data/log"; import { EDIT_MODE_STREAM_ID } from "core/edit/constants"; @@ -32,6 +31,7 @@ import { getExtensionUri } from "../util/vscode"; import { VsCodeIde } from "../VsCodeIde"; import { VsCodeWebviewProtocol } from "../webviewProtocol"; +import { encodeFullSlug } from "../../../../packages/config-yaml/dist"; import { VsCodeExtension } from "./VsCodeExtension"; type ToIdeOrWebviewFromCoreProtocol = ToIdeFromCoreProtocol & From a5de87abe0d6986fb811eb5c2957dcfbe155c8a9 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 16 Oct 2025 15:29:49 -0700 Subject: [PATCH 27/27] fix: open correct link --- gui/src/components/BackgroundMode/AgentsList.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/gui/src/components/BackgroundMode/AgentsList.tsx b/gui/src/components/BackgroundMode/AgentsList.tsx index ee1468b91..2af6400bb 100644 --- a/gui/src/components/BackgroundMode/AgentsList.tsx +++ b/gui/src/components/BackgroundMode/AgentsList.tsx @@ -116,7 +116,6 @@ export function AgentsList({ isCreatingAgent = false }: AgentsListProps) { // Open agent detail in browser ideMessenger.post("controlPlane/openUrl", { path: `agents/${agent.id}`, - orgSlug: currentOrg?.slug, }); }} >