Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions apps/code/src/renderer/api/posthogClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import type {
SandboxEnvironment,
SandboxEnvironmentInput,
SignalReportArtefact,
SignalReportArtefactsResponse,
SignalReportSignalsResponse,
Expand Down Expand Up @@ -502,6 +504,7 @@ export class PostHogAPIClient {
taskId: string,
branch?: string | null,
resumeOptions?: { resumeFromRunId: string; pendingUserMessage: string },
sandboxEnvironmentId?: string,
): Promise<Task> {
const teamId = await this.getTeamId();
const body: Record<string, unknown> = { mode: "interactive" };
Expand All @@ -512,6 +515,9 @@ export class PostHogAPIClient {
body.resume_from_run_id = resumeOptions.resumeFromRunId;
body.pending_user_message = resumeOptions.pendingUserMessage;
}
if (sandboxEnvironmentId) {
body.sandbox_environment_id = sandboxEnvironmentId;
}

const data = await this.api.post(
`/api/projects/{project_id}/tasks/{id}/run/`,
Expand Down Expand Up @@ -1159,4 +1165,81 @@ export class PostHogAPIClient {
return false;
}
}

// Sandbox Environments

async listSandboxEnvironments(): Promise<SandboxEnvironment[]> {
const teamId = await this.getTeamId();
const url = new URL(
`${this.api.baseUrl}/api/projects/${teamId}/sandbox_environments/`,
);
const response = await this.api.fetcher.fetch({
method: "get",
url,
path: `/api/projects/${teamId}/sandbox_environments/`,
});
if (!response.ok) {
throw new Error(`Failed to fetch sandbox environments: ${response.statusText}`);
}
const data = await response.json();
return (data.results ?? data) as SandboxEnvironment[];
}

async createSandboxEnvironment(
input: SandboxEnvironmentInput,
): Promise<SandboxEnvironment> {
const teamId = await this.getTeamId();
const url = new URL(
`${this.api.baseUrl}/api/projects/${teamId}/sandbox_environments/`,
);
const response = await this.api.fetcher.fetch({
method: "post",
url,
path: `/api/projects/${teamId}/sandbox_environments/`,
overrides: {
body: JSON.stringify(input),
},
});
if (!response.ok) {
throw new Error(`Failed to create sandbox environment: ${response.statusText}`);
}
return (await response.json()) as SandboxEnvironment;
}

async updateSandboxEnvironment(
id: string,
input: Partial<SandboxEnvironmentInput>,
): Promise<SandboxEnvironment> {
const teamId = await this.getTeamId();
const url = new URL(
`${this.api.baseUrl}/api/projects/${teamId}/sandbox_environments/${id}/`,
);
const response = await this.api.fetcher.fetch({
method: "patch",
url,
path: `/api/projects/${teamId}/sandbox_environments/${id}/`,
overrides: {
body: JSON.stringify(input),
},
});
if (!response.ok) {
throw new Error(`Failed to update sandbox environment: ${response.statusText}`);
}
return (await response.json()) as SandboxEnvironment;
}

async deleteSandboxEnvironment(id: string): Promise<void> {
const teamId = await this.getTeamId();
const url = new URL(
`${this.api.baseUrl}/api/projects/${teamId}/sandbox_environments/${id}/`,
);
const response = await this.api.fetcher.fetch({
method: "delete",
url,
path: `/api/projects/${teamId}/sandbox_environments/${id}/`,
});
if (!response.ok) {
throw new Error(`Failed to delete sandbox environment: ${response.statusText}`);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
ArrowLeft,
ArrowsClockwise,
CaretRight,
Cloud,
Code,
Folder,
GearSix,
Expand All @@ -31,6 +32,7 @@ import { ShortcutsSettings } from "./sections/ShortcutsSettings";
import { SignalSourcesSettings } from "./sections/SignalSourcesSettings";
import { UpdatesSettings } from "./sections/UpdatesSettings";
import { WorkspacesSettings } from "./sections/WorkspacesSettings";
import { CloudEnvironmentsSettings } from "./sections/CloudEnvironmentsSettings";
import { WorktreesSettings } from "./sections/worktrees/WorktreesSettings";

interface SidebarItem {
Expand All @@ -45,6 +47,11 @@ const SIDEBAR_ITEMS: SidebarItem[] = [
{ id: "account", label: "Account", icon: <User size={16} /> },
{ id: "workspaces", label: "Workspaces", icon: <Folder size={16} /> },
{ id: "worktrees", label: "Worktrees", icon: <TreeStructure size={16} /> },
{
id: "cloud-environments",
label: "Cloud environments",
icon: <Cloud size={16} />,
},
{
id: "personalization",
label: "Personalization",
Expand All @@ -68,6 +75,7 @@ const CATEGORY_TITLES: Record<SettingsCategory, string> = {
account: "Account",
workspaces: "Workspaces",
worktrees: "Worktrees",
"cloud-environments": "Cloud environments",
personalization: "Personalization",
"claude-code": "Claude Code",
"mcp-servers": "MCP Servers",
Expand All @@ -83,6 +91,7 @@ const CATEGORY_COMPONENTS: Record<SettingsCategory, React.ComponentType> = {
account: AccountSettings,
workspaces: WorkspacesSettings,
worktrees: WorktreesSettings,
"cloud-environments": CloudEnvironmentsSettings,
personalization: PersonalizationSettings,
"claude-code": ClaudeCodeSettings,
"mcp-servers": McpServersSettings,
Expand Down
Loading
Loading