diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts index 0610ea740..2ae0ca423 100644 --- a/core/control-plane/client.ts +++ b/core/control-plane/client.ts @@ -608,7 +608,9 @@ export class ControlPlaneClient { * @param agentSessionId - The ID of the agent session * @returns The agent session view including metadata and status */ - public async getAgentSession(agentSessionId: string): Promise { + public async getAgentSession( + agentSessionId: string, + ): Promise { if (!(await this.isSignedIn())) { return null; } @@ -621,7 +623,7 @@ export class ControlPlaneClient { }, ); - return await resp.json(); + return (await resp.json()) as AgentSessionView; } catch (e) { Logger.error(e, { context: "control_plane_get_agent_session", diff --git a/gui/src/components/BackgroundMode/AgentsList.tsx b/gui/src/components/BackgroundMode/AgentsList.tsx index b0e2d00b6..7d74d9d7f 100644 --- a/gui/src/components/BackgroundMode/AgentsList.tsx +++ b/gui/src/components/BackgroundMode/AgentsList.tsx @@ -22,6 +22,12 @@ interface AgentsListProps { isCreatingAgent?: boolean; } +interface WorkspaceInfo { + repoUrl: string; + workspaceDir: string; + workspaceName: string; +} + export function AgentsList({ isCreatingAgent = false }: AgentsListProps) { const { session } = useAuth(); const ideMessenger = useContext(IdeMessengerContext); @@ -29,7 +35,7 @@ export function AgentsList({ isCreatingAgent = false }: AgentsListProps) { const [agents, setAgents] = useState(null); const [totalCount, setTotalCount] = useState(0); const [error, setError] = useState(null); - const [workspaceRepoUrls, setWorkspaceRepoUrls] = useState([]); + const [workspaces, setWorkspaces] = useState([]); // Fetch workspace repo URLs once on mount useEffect(() => { @@ -40,7 +46,7 @@ export function AgentsList({ isCreatingAgent = false }: AgentsListProps) { undefined, ); if (workspaceDirs.status === "success" && workspaceDirs.content) { - const repoUrls: string[] = []; + const workspaceInfos: WorkspaceInfo[] = []; for (const dir of workspaceDirs.content) { const repoNameResult = await ideMessenger.request("getRepoName", { dir, @@ -48,11 +54,17 @@ export function AgentsList({ isCreatingAgent = false }: AgentsListProps) { if (repoNameResult.status === "success" && repoNameResult.content) { const normalizedUrl = normalizeRepoUrl(repoNameResult.content); if (normalizedUrl) { - repoUrls.push(normalizedUrl); + // Extract workspace name from directory path (last segment) + const workspaceName = dir.split("/").pop() || dir; + workspaceInfos.push({ + repoUrl: normalizedUrl, + workspaceDir: dir, + workspaceName, + }); } } } - setWorkspaceRepoUrls(repoUrls); + setWorkspaces(workspaceInfos); } } catch (err) { console.error("Failed to fetch workspace repos:", err); @@ -120,11 +132,30 @@ export function AgentsList({ isCreatingAgent = false }: AgentsListProps) { .filter((url) => url !== ""); // Check if any of the agent URLs match any workspace URL - return workspaceRepoUrls.some((workspaceUrl) => - agentUrls.some((agentUrl) => agentUrl === workspaceUrl), + return workspaces.some((workspace) => + agentUrls.some((agentUrl) => agentUrl === workspace.repoUrl), ); }; + // Helper function to get the agent's repository name (for display in tooltips) + const getAgentRepoName = (agent: Agent): string | null => { + // Try to extract repo name from the agent's repository URL + // Handles URLs like: https://github.com/org/repo or git@github.com:org/repo.git + const repoUrl = agent.metadata?.github_repo || agent.repoUrl; + if (!repoUrl) return null; + + try { + // Remove .git suffix if present + const cleanUrl = repoUrl.replace(/\.git$/, ""); + // Extract the last path segment (repo name) + const parts = cleanUrl.split("/"); + const repoName = parts[parts.length - 1]; + return repoName || null; + } catch { + return null; + } + }; + const handleOpenLocally = (agent: Agent, e: React.MouseEvent) => { e.stopPropagation(); // Prevent opening the agent detail page ideMessenger.post("openAgentLocally", { agentSessionId: agent.id }); @@ -163,6 +194,7 @@ export function AgentsList({ isCreatingAgent = false }: AgentsListProps) { {agents.map((agent) => { const isInWorkspace = isAgentInCurrentWorkspace(agent); const canOpenLocally = isInWorkspace; + const agentRepoName = getAgentRepoName(agent); return (