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
91 changes: 91 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 @@ -1162,4 +1168,89 @@ 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 @@ -43,7 +43,7 @@ export function EnvironmentSelector({
setOpen(false);
useSettingsDialogStore
.getState()
.open("environments", { repoPath: repoPath ?? undefined });
.open("cloud-environments", { repoPath: repoPath ?? undefined });
};

const triggerContent = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
useSessionForTask,
} from "@features/sessions/stores/sessionStore";
import { useSettingsStore } from "@features/settings/stores/settingsStore";
import { useFeatureFlag } from "@hooks/useFeatureFlag";
import { ArrowDown, XCircle } from "@phosphor-icons/react";
import { Box, Button, Flex, Text } from "@radix-ui/themes";
import type { AcpMessage } from "@shared/types/session-events";
Expand Down Expand Up @@ -49,9 +48,8 @@ export function ConversationView({
}: ConversationViewProps) {
const listRef = useRef<VirtualizedListHandle>(null);
const [showScrollButton, setShowScrollButton] = useState(false);
const agentLogsEnabled = useFeatureFlag("posthog-code-background-agent-logs");
const debugLogsCloudRuns = useSettingsStore((s) => s.debugLogsCloudRuns);
const showDebugLogs = agentLogsEnabled && debugLogsCloudRuns;
const showDebugLogs = debugLogsCloudRuns;

const {
items: conversationItems,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {
ArrowLeft,
ArrowsClockwise,
CaretRight,
Cloud,
Code,
Folder,
GearSix,
HardDrives,
Keyboard,
Palette,
Plugs,
Expand All @@ -24,7 +24,7 @@ import { useHotkeys } from "react-hotkeys-hook";
import { AccountSettings } from "./sections/AccountSettings";
import { AdvancedSettings } from "./sections/AdvancedSettings";
import { ClaudeCodeSettings } from "./sections/ClaudeCodeSettings";
import { EnvironmentsSettings } from "./sections/environments/EnvironmentsSettings";
import { CloudEnvironmentsSettings } from "./sections/CloudEnvironmentsSettings";
import { GeneralSettings } from "./sections/GeneralSettings";
import { McpServersSettings } from "./sections/McpServersSettings";
import { PersonalizationSettings } from "./sections/PersonalizationSettings";
Expand All @@ -47,9 +47,9 @@ const SIDEBAR_ITEMS: SidebarItem[] = [
{ id: "workspaces", label: "Workspaces", icon: <Folder size={16} /> },
{ id: "worktrees", label: "Worktrees", icon: <TreeStructure size={16} /> },
{
id: "environments",
label: "Environments",
icon: <HardDrives size={16} />,
id: "cloud-environments",
label: "Cloud environments",
icon: <Cloud size={16} />,
},
{
id: "personalization",
Expand All @@ -74,7 +74,7 @@ const CATEGORY_TITLES: Record<SettingsCategory, string> = {
account: "Account",
workspaces: "Workspaces",
worktrees: "Worktrees",
environments: "Environments",
"cloud-environments": "Cloud environments",
personalization: "Personalization",
"claude-code": "Claude Code",
"mcp-servers": "MCP Servers",
Expand All @@ -90,7 +90,7 @@ const CATEGORY_COMPONENTS: Record<SettingsCategory, React.ComponentType> = {
account: AccountSettings,
workspaces: WorkspacesSettings,
worktrees: WorktreesSettings,
environments: EnvironmentsSettings,
"cloud-environments": CloudEnvironmentsSettings,
personalization: PersonalizationSettings,
"claude-code": ClaudeCodeSettings,
"mcp-servers": McpServersSettings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import { Button, Flex, Switch } from "@radix-ui/themes";
import { clearApplicationStorage } from "@utils/clearStorage";

export function AdvancedSettings() {
const showDebugLogsToggle = useFeatureFlag(
"posthog-code-background-agent-logs",
);
const showDebugLogsToggle =
useFeatureFlag("posthog-code-background-agent-logs") || import.meta.env.DEV;
const debugLogsCloudRuns = useSettingsStore((s) => s.debugLogsCloudRuns);
const setDebugLogsCloudRuns = useSettingsStore(
(s) => s.setDebugLogsCloudRuns,
Expand Down
Loading
Loading