Skip to content

Commit c0ad9a5

Browse files
joshsnytatoalo
authored andcommitted
cloud environments
1 parent dd244a0 commit c0ad9a5

10 files changed

Lines changed: 915 additions & 46 deletions

File tree

apps/code/src/renderer/api/posthogClient.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import type {
2+
SandboxEnvironment,
3+
SandboxEnvironmentInput,
24
SignalReportArtefact,
35
SignalReportArtefactsResponse,
46
SignalReportSignalsResponse,
@@ -504,6 +506,7 @@ export class PostHogAPIClient {
504506
taskId: string,
505507
branch?: string | null,
506508
resumeOptions?: { resumeFromRunId: string; pendingUserMessage: string },
509+
sandboxEnvironmentId?: string,
507510
): Promise<Task> {
508511
const teamId = await this.getTeamId();
509512
const body: Record<string, unknown> = { mode: "interactive" };
@@ -514,6 +517,9 @@ export class PostHogAPIClient {
514517
body.resume_from_run_id = resumeOptions.resumeFromRunId;
515518
body.pending_user_message = resumeOptions.pendingUserMessage;
516519
}
520+
if (sandboxEnvironmentId) {
521+
body.sandbox_environment_id = sandboxEnvironmentId;
522+
}
517523

518524
const data = await this.api.post(
519525
`/api/projects/{project_id}/tasks/{id}/run/`,
@@ -1164,4 +1170,81 @@ export class PostHogAPIClient {
11641170
return false;
11651171
}
11661172
}
1173+
1174+
// Sandbox Environments
1175+
1176+
async listSandboxEnvironments(): Promise<SandboxEnvironment[]> {
1177+
const teamId = await this.getTeamId();
1178+
const url = new URL(
1179+
`${this.api.baseUrl}/api/projects/${teamId}/sandbox_environments/`,
1180+
);
1181+
const response = await this.api.fetcher.fetch({
1182+
method: "get",
1183+
url,
1184+
path: `/api/projects/${teamId}/sandbox_environments/`,
1185+
});
1186+
if (!response.ok) {
1187+
throw new Error(`Failed to fetch sandbox environments: ${response.statusText}`);
1188+
}
1189+
const data = await response.json();
1190+
return (data.results ?? data) as SandboxEnvironment[];
1191+
}
1192+
1193+
async createSandboxEnvironment(
1194+
input: SandboxEnvironmentInput,
1195+
): Promise<SandboxEnvironment> {
1196+
const teamId = await this.getTeamId();
1197+
const url = new URL(
1198+
`${this.api.baseUrl}/api/projects/${teamId}/sandbox_environments/`,
1199+
);
1200+
const response = await this.api.fetcher.fetch({
1201+
method: "post",
1202+
url,
1203+
path: `/api/projects/${teamId}/sandbox_environments/`,
1204+
overrides: {
1205+
body: JSON.stringify(input),
1206+
},
1207+
});
1208+
if (!response.ok) {
1209+
throw new Error(`Failed to create sandbox environment: ${response.statusText}`);
1210+
}
1211+
return (await response.json()) as SandboxEnvironment;
1212+
}
1213+
1214+
async updateSandboxEnvironment(
1215+
id: string,
1216+
input: Partial<SandboxEnvironmentInput>,
1217+
): Promise<SandboxEnvironment> {
1218+
const teamId = await this.getTeamId();
1219+
const url = new URL(
1220+
`${this.api.baseUrl}/api/projects/${teamId}/sandbox_environments/${id}/`,
1221+
);
1222+
const response = await this.api.fetcher.fetch({
1223+
method: "patch",
1224+
url,
1225+
path: `/api/projects/${teamId}/sandbox_environments/${id}/`,
1226+
overrides: {
1227+
body: JSON.stringify(input),
1228+
},
1229+
});
1230+
if (!response.ok) {
1231+
throw new Error(`Failed to update sandbox environment: ${response.statusText}`);
1232+
}
1233+
return (await response.json()) as SandboxEnvironment;
1234+
}
1235+
1236+
async deleteSandboxEnvironment(id: string): Promise<void> {
1237+
const teamId = await this.getTeamId();
1238+
const url = new URL(
1239+
`${this.api.baseUrl}/api/projects/${teamId}/sandbox_environments/${id}/`,
1240+
);
1241+
const response = await this.api.fetcher.fetch({
1242+
method: "delete",
1243+
url,
1244+
path: `/api/projects/${teamId}/sandbox_environments/${id}/`,
1245+
});
1246+
if (!response.ok) {
1247+
throw new Error(`Failed to delete sandbox environment: ${response.statusText}`);
1248+
}
1249+
}
11671250
}

apps/code/src/renderer/features/settings/components/SettingsDialog.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
ArrowLeft,
77
ArrowsClockwise,
88
CaretRight,
9+
Cloud,
910
Code,
1011
Folder,
1112
GearSix,
@@ -32,6 +33,7 @@ import { ShortcutsSettings } from "./sections/ShortcutsSettings";
3233
import { SignalSourcesSettings } from "./sections/SignalSourcesSettings";
3334
import { UpdatesSettings } from "./sections/UpdatesSettings";
3435
import { WorkspacesSettings } from "./sections/WorkspacesSettings";
36+
import { CloudEnvironmentsSettings } from "./sections/CloudEnvironmentsSettings";
3537
import { WorktreesSettings } from "./sections/worktrees/WorktreesSettings";
3638

3739
interface SidebarItem {
@@ -47,9 +49,9 @@ const SIDEBAR_ITEMS: SidebarItem[] = [
4749
{ id: "workspaces", label: "Workspaces", icon: <Folder size={16} /> },
4850
{ id: "worktrees", label: "Worktrees", icon: <TreeStructure size={16} /> },
4951
{
50-
id: "environments",
51-
label: "Environments",
52-
icon: <HardDrives size={16} />,
52+
id: "cloud-environments",
53+
label: "Cloud environments",
54+
icon: <Cloud size={16} />,
5355
},
5456
{
5557
id: "personalization",
@@ -74,7 +76,7 @@ const CATEGORY_TITLES: Record<SettingsCategory, string> = {
7476
account: "Account",
7577
workspaces: "Workspaces",
7678
worktrees: "Worktrees",
77-
environments: "Environments",
79+
"cloud-environments": "Cloud environments",
7880
personalization: "Personalization",
7981
"claude-code": "Claude Code",
8082
"mcp-servers": "MCP Servers",
@@ -90,7 +92,7 @@ const CATEGORY_COMPONENTS: Record<SettingsCategory, React.ComponentType> = {
9092
account: AccountSettings,
9193
workspaces: WorkspacesSettings,
9294
worktrees: WorktreesSettings,
93-
environments: EnvironmentsSettings,
95+
"cloud-environments": CloudEnvironmentsSettings,
9496
personalization: PersonalizationSettings,
9597
"claude-code": ClaudeCodeSettings,
9698
"mcp-servers": McpServersSettings,

0 commit comments

Comments
 (0)