Skip to content

Commit a476c1e

Browse files
fix: pass org id
1 parent d9c16e4 commit a476c1e

File tree

6 files changed

+26
-10
lines changed

6 files changed

+26
-10
lines changed

core/control-plane/client.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,10 @@ export class ControlPlaneClient {
478478
}
479479

480480
/**
481-
* List all background agents for the current user
481+
* List all background agents for the current user or organization
482+
* @param organizationId - Optional organization ID to filter agents by organization scope
482483
*/
483-
public async listBackgroundAgents(): Promise<
484+
public async listBackgroundAgents(organizationId?: string): Promise<
484485
Array<{
485486
id: string;
486487
name: string | null;
@@ -497,7 +498,13 @@ export class ControlPlaneClient {
497498
}
498499

499500
try {
500-
const resp = await this.requestAndHandleError("agents", {
501+
// Build URL with optional organizationId query parameter
502+
let url = "agents";
503+
if (organizationId) {
504+
url += `?organizationId=${encodeURIComponent(organizationId)}`;
505+
}
506+
507+
const resp = await this.requestAndHandleError(url, {
501508
method: "GET",
502509
});
503510

core/protocol/ideWebview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & {
5252
"session/share": [{ sessionId: string }, void];
5353
createBackgroundAgent: [{ editorState: any; organizationId?: string }, void];
5454
listBackgroundAgents: [
55-
undefined,
55+
{ organizationId?: string },
5656
Array<{
5757
id: string;
5858
name: string | null;

extensions/vscode/src/extension/VsCodeMessenger.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,10 +403,13 @@ export class VsCodeMessenger {
403403

404404
this.onWebview("listBackgroundAgents", async (msg) => {
405405
const configHandler = await configHandlerPromise;
406+
const { organizationId } = msg.data;
406407

407408
try {
408409
const agents =
409-
await configHandler.controlPlaneClient.listBackgroundAgents();
410+
await configHandler.controlPlaneClient.listBackgroundAgents(
411+
organizationId,
412+
);
410413
return agents;
411414
} catch (e) {
412415
console.error("Error listing background agents:", e);

gui/src/components/BackgroundMode/AgentsList.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { ArrowPathIcon } from "@heroicons/react/24/outline";
22
import { useContext, useEffect, useState } from "react";
33
import { useAuth } from "../../context/Auth";
44
import { IdeMessengerContext } from "../../context/IdeMessenger";
5+
import { useAppSelector } from "../../redux/hooks";
6+
import { selectCurrentOrg } from "../../redux/slices/profilesSlice";
57

68
interface Agent {
79
id: string;
@@ -17,6 +19,7 @@ interface Agent {
1719
export function AgentsList() {
1820
const { session } = useAuth();
1921
const ideMessenger = useContext(IdeMessengerContext);
22+
const currentOrg = useAppSelector(selectCurrentOrg);
2023
const [agents, setAgents] = useState<Agent[]>([]);
2124
const [isLoading, setIsLoading] = useState(true);
2225
const [error, setError] = useState<string | null>(null);
@@ -32,7 +35,10 @@ export function AgentsList() {
3235
try {
3336
setIsLoading(true);
3437
// Request agent list from IDE
35-
const result = await ideMessenger.request("listBackgroundAgents", {});
38+
const organizationId = currentOrg?.id;
39+
const result = await ideMessenger.request("listBackgroundAgents", {
40+
organizationId,
41+
});
3642

3743
if (result && Array.isArray(result)) {
3844
setAgents(result);
@@ -57,7 +63,7 @@ export function AgentsList() {
5763
}, 10000);
5864

5965
return () => clearInterval(interval);
60-
}, [session, ideMessenger]);
66+
}, [session, ideMessenger, currentOrg]);
6167

6268
if (isLoading) {
6369
return (

gui/src/components/BackgroundMode/BackgroundModeView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { IdeMessengerContext } from "../../context/IdeMessenger";
88
import { AgentsList } from "./AgentsList";
99

1010
interface BackgroundModeViewProps {
11-
onCreateAgent: (prompt: string) => void;
11+
onCreateAgent: (editorState: any) => void;
1212
}
1313

1414
export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) {

gui/src/pages/gui/Chat.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,10 +478,10 @@ export function Chat() {
478478
{!hasDismissedExploreDialog && <ExploreDialogWatcher />}
479479
{mode === "background" ? (
480480
<BackgroundModeView
481-
onCreateAgent={(prompt) => {
481+
onCreateAgent={(editorState) => {
482482
const organizationId = currentOrg?.id;
483483
ideMessenger.post("createBackgroundAgent", {
484-
prompt,
484+
editorState,
485485
organizationId,
486486
});
487487
}}

0 commit comments

Comments
 (0)