feat(web): add executor settings popover with reset environment action
A new button on the task top bar opens a popover showing the active TaskEnvironment — executor type, status, container/sprite/worktree identifiers, and a copy-ready 'docker exec' command for local Docker. The popover hosts the destructive Reset Environment action so users have one obvious place to inspect and manage the environment without cluttering the New Session dialog. The reset confirmation dialog requires explicit acknowledgement that uncommitted changes will be lost. When the environment has a host-side worktree it offers an opt-in 'push branch before resetting' checkbox so committed work can be pushed first; the backend aborts the reset on push failure. - task-environment-api.ts: fetchTaskEnvironment + resetTaskEnvironment - executor-settings-button.tsx: popover trigger + identity panel - task-reset-env-confirm-dialog.tsx: destructive confirm with push opt-in - task-top-bar.tsx: wire the new button into the right-side controls - e2e: replace fresh-env-toggle test with reset-from-popover flow
This commit is contained in:
@@ -0,0 +1,267 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import {
|
||||
IconBox,
|
||||
IconCopy,
|
||||
IconLoader,
|
||||
IconRefresh,
|
||||
IconTrash,
|
||||
} from "@tabler/icons-react";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@kandev/ui/popover";
|
||||
import { Button } from "@kandev/ui/button";
|
||||
import { toast } from "sonner";
|
||||
|
||||
import {
|
||||
fetchTaskEnvironment,
|
||||
resetTaskEnvironment,
|
||||
type TaskEnvironment,
|
||||
} from "@/lib/api/domains/task-environment-api";
|
||||
import { TaskResetEnvConfirmDialog } from "./task-reset-env-confirm-dialog";
|
||||
|
||||
type ExecutorSettingsButtonProps = {
|
||||
taskId?: string | null;
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
export function ExecutorSettingsButton({ taskId, disabled }: ExecutorSettingsButtonProps) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [env, setEnv] = useState<TaskEnvironment | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [resetDialogOpen, setResetDialogOpen] = useState(false);
|
||||
const [isResetting, setIsResetting] = useState(false);
|
||||
|
||||
const loadEnv = useCallback(async () => {
|
||||
if (!taskId) {
|
||||
setEnv(null);
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
try {
|
||||
const data = await fetchTaskEnvironment(taskId);
|
||||
setEnv(data);
|
||||
} catch {
|
||||
// 404 when there's no environment yet — normal state, not an error
|
||||
setEnv(null);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [taskId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
void loadEnv();
|
||||
}
|
||||
}, [open, loadEnv]);
|
||||
|
||||
const handleReset = useCallback(
|
||||
async ({ pushBranch }: { pushBranch: boolean }) => {
|
||||
if (!taskId) return;
|
||||
setIsResetting(true);
|
||||
try {
|
||||
await resetTaskEnvironment(taskId, { push_branch: pushBranch });
|
||||
toast.success("Environment reset");
|
||||
setEnv(null);
|
||||
setResetDialogOpen(false);
|
||||
setOpen(false);
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : "Unknown error";
|
||||
toast.error(`Reset failed: ${msg}`);
|
||||
} finally {
|
||||
setIsResetting(false);
|
||||
}
|
||||
},
|
||||
[taskId],
|
||||
);
|
||||
|
||||
if (!taskId) return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="cursor-pointer px-2"
|
||||
disabled={disabled}
|
||||
data-testid="executor-settings-button"
|
||||
aria-label="Executor settings"
|
||||
>
|
||||
<IconBox className="h-4 w-4" />
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent
|
||||
align="end"
|
||||
className="w-[340px] p-0 text-sm"
|
||||
data-testid="executor-settings-popover"
|
||||
>
|
||||
<EnvironmentInfo env={env} loading={loading} />
|
||||
<div className="border-t border-border p-2 flex items-center justify-between gap-2">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="cursor-pointer text-xs"
|
||||
onClick={() => void loadEnv()}
|
||||
disabled={loading}
|
||||
>
|
||||
<IconRefresh className="h-3.5 w-3.5 mr-1" /> Refresh
|
||||
</Button>
|
||||
<Button
|
||||
variant="destructive"
|
||||
size="sm"
|
||||
className="cursor-pointer text-xs"
|
||||
disabled={!env || isResetting}
|
||||
data-testid="executor-settings-reset"
|
||||
onClick={() => setResetDialogOpen(true)}
|
||||
>
|
||||
<IconTrash className="h-3.5 w-3.5 mr-1" /> Reset environment
|
||||
</Button>
|
||||
</div>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
|
||||
<TaskResetEnvConfirmDialog
|
||||
open={resetDialogOpen}
|
||||
onOpenChange={setResetDialogOpen}
|
||||
hasWorktreePath={Boolean(env?.worktree_path)}
|
||||
isResetting={isResetting}
|
||||
onConfirm={handleReset}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function EnvironmentInfo({
|
||||
env,
|
||||
loading,
|
||||
}: {
|
||||
env: TaskEnvironment | null;
|
||||
loading: boolean;
|
||||
}) {
|
||||
if (loading && !env) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-6 text-muted-foreground">
|
||||
<IconLoader className="h-4 w-4 animate-spin" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!env) {
|
||||
return (
|
||||
<div className="px-3 py-4 text-muted-foreground">
|
||||
<p className="font-medium text-foreground">No environment yet</p>
|
||||
<p className="text-xs mt-1">
|
||||
An environment is created when you start a session on this task.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="p-3 space-y-3">
|
||||
<div>
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="font-medium text-foreground">{formatExecutorType(env.executor_type)}</span>
|
||||
<span className="text-xs text-muted-foreground uppercase tracking-wide">{env.status}</span>
|
||||
</div>
|
||||
</div>
|
||||
<EnvironmentFields env={env} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function EnvironmentFields({ env }: { env: TaskEnvironment }) {
|
||||
const fields = useMemo(() => buildFields(env), [env]);
|
||||
if (fields.length === 0) {
|
||||
return <p className="text-xs text-muted-foreground">No resource details available.</p>;
|
||||
}
|
||||
return (
|
||||
<dl className="space-y-1.5 text-xs">
|
||||
{fields.map((f) => (
|
||||
<Field key={f.label} label={f.label} value={f.value} copy={f.copy} />
|
||||
))}
|
||||
</dl>
|
||||
);
|
||||
}
|
||||
|
||||
function Field({
|
||||
label,
|
||||
value,
|
||||
copy,
|
||||
}: {
|
||||
label: string;
|
||||
value: string;
|
||||
copy?: boolean;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex items-start gap-2">
|
||||
<dt className="text-muted-foreground min-w-[90px]">{label}</dt>
|
||||
<dd className="flex-1 flex items-center gap-1 break-all font-mono">
|
||||
<span className="flex-1">{value}</span>
|
||||
{copy && (
|
||||
<button
|
||||
type="button"
|
||||
className="cursor-pointer text-muted-foreground hover:text-foreground"
|
||||
aria-label={`Copy ${label}`}
|
||||
onClick={() => {
|
||||
void navigator.clipboard.writeText(value).then(() => toast.success(`${label} copied`));
|
||||
}}
|
||||
>
|
||||
<IconCopy className="h-3 w-3" />
|
||||
</button>
|
||||
)}
|
||||
</dd>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
type FieldRow = { label: string; value: string; copy?: boolean };
|
||||
|
||||
function buildFields(env: TaskEnvironment): FieldRow[] {
|
||||
const rows: FieldRow[] = [];
|
||||
|
||||
if (env.worktree_path) {
|
||||
rows.push({ label: "Worktree", value: env.worktree_path, copy: true });
|
||||
}
|
||||
if (env.worktree_branch) {
|
||||
rows.push({ label: "Branch", value: env.worktree_branch, copy: true });
|
||||
}
|
||||
|
||||
if (env.container_id) {
|
||||
rows.push({ label: "Container", value: env.container_id.slice(0, 12), copy: true });
|
||||
rows.push({
|
||||
label: "Shell",
|
||||
value: `docker exec -it ${env.container_id.slice(0, 12)} bash`,
|
||||
copy: true,
|
||||
});
|
||||
}
|
||||
|
||||
if (env.sandbox_id) {
|
||||
rows.push({ label: "Sprite", value: env.sandbox_id, copy: true });
|
||||
}
|
||||
|
||||
if (env.agent_execution_id) {
|
||||
rows.push({ label: "Execution", value: env.agent_execution_id, copy: true });
|
||||
}
|
||||
|
||||
rows.push({ label: "Environment ID", value: env.id, copy: true });
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
function formatExecutorType(type: string): string {
|
||||
switch (type) {
|
||||
case "local_pc":
|
||||
case "worktree":
|
||||
return "Local (worktree)";
|
||||
case "local_docker":
|
||||
return "Local Docker";
|
||||
case "sprites":
|
||||
return "Sprites sandbox";
|
||||
case "remote_docker":
|
||||
return "Remote Docker";
|
||||
default:
|
||||
return type || "Unknown executor";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { IconLoader } from "@tabler/icons-react";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@kandev/ui/alert-dialog";
|
||||
import { Checkbox } from "@kandev/ui/checkbox";
|
||||
|
||||
export type TaskResetEnvConfirmDialogProps = {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
hasWorktreePath: boolean;
|
||||
isResetting?: boolean;
|
||||
onConfirm: (opts: { pushBranch: boolean }) => void;
|
||||
};
|
||||
|
||||
export function TaskResetEnvConfirmDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
hasWorktreePath,
|
||||
isResetting,
|
||||
onConfirm,
|
||||
}: TaskResetEnvConfirmDialogProps) {
|
||||
const [acknowledged, setAcknowledged] = useState(false);
|
||||
const [pushBranch, setPushBranch] = useState(false);
|
||||
|
||||
const handleOpenChange = (next: boolean) => {
|
||||
if (!next) {
|
||||
// reset local state when closing
|
||||
setAcknowledged(false);
|
||||
setPushBranch(false);
|
||||
}
|
||||
onOpenChange(next);
|
||||
};
|
||||
|
||||
return (
|
||||
<AlertDialog open={open} onOpenChange={handleOpenChange}>
|
||||
<AlertDialogContent onClick={(e) => e.stopPropagation()}>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Reset environment?</AlertDialogTitle>
|
||||
<AlertDialogDescription asChild>
|
||||
<div className="space-y-2">
|
||||
<p>
|
||||
This tears down the current container, sandbox, and/or worktree for this task so
|
||||
the next session starts with a fresh environment.
|
||||
</p>
|
||||
<p className="text-destructive">
|
||||
Any uncommitted or unpushed changes in the workspace will be lost.
|
||||
</p>
|
||||
</div>
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
|
||||
<div className="space-y-3 py-1">
|
||||
{hasWorktreePath && (
|
||||
<label className="flex items-start gap-2 text-sm cursor-pointer">
|
||||
<Checkbox
|
||||
checked={pushBranch}
|
||||
onCheckedChange={(v) => setPushBranch(v === true)}
|
||||
disabled={isResetting}
|
||||
/>
|
||||
<span>
|
||||
Push the current branch to its remote before resetting.
|
||||
<span className="block text-xs text-muted-foreground">
|
||||
Helps preserve committed work. Uncommitted changes cannot be pushed.
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
)}
|
||||
|
||||
<label className="flex items-start gap-2 text-sm cursor-pointer">
|
||||
<Checkbox
|
||||
checked={acknowledged}
|
||||
onCheckedChange={(v) => setAcknowledged(v === true)}
|
||||
disabled={isResetting}
|
||||
/>
|
||||
<span>I understand any uncommitted changes will be lost.</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel className="cursor-pointer">Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
disabled={isResetting || !acknowledged}
|
||||
className="cursor-pointer bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
data-testid="reset-env-confirm"
|
||||
onClick={() => {
|
||||
if (isResetting || !acknowledged) return;
|
||||
onConfirm({ pushBranch });
|
||||
}}
|
||||
>
|
||||
{isResetting ? <IconLoader className="mr-2 h-4 w-4 animate-spin" /> : null}
|
||||
Reset environment
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
);
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import { LinearLinkButton } from "@/components/linear/linear-link-button";
|
||||
import { useJiraAvailable } from "@/hooks/domains/jira/use-jira-availability";
|
||||
import { useLinearAvailable } from "@/hooks/domains/linear/use-linear-availability";
|
||||
import { PortForwardButton } from "@/components/task/port-forward-dialog";
|
||||
import { ExecutorSettingsButton } from "@/components/task/executor-settings-button";
|
||||
import { WorkflowStepper, type WorkflowStepperStep } from "@/components/task/workflow-stepper";
|
||||
import { RemoteCloudTooltip } from "@/components/task/remote-cloud-tooltip";
|
||||
import { QuickChatButton } from "@/components/task/quick-chat-button";
|
||||
@@ -344,6 +345,7 @@ function AttentionStatusGroup({
|
||||
<DocumentControls activeSessionId={activeSessionId ?? null} />
|
||||
{!isArchived && (
|
||||
<>
|
||||
<ExecutorSettingsButton taskId={taskId} />
|
||||
<PortForwardButton
|
||||
isRemoteExecutor={isRemoteExecutor}
|
||||
sessionId={activeSessionId}
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
import { test, expect } from "../../fixtures/test-base";
|
||||
import { KanbanPage } from "../../pages/kanban-page";
|
||||
import { SessionPage } from "../../pages/session-page";
|
||||
|
||||
const DONE_STATES = ["COMPLETED", "WAITING_FOR_INPUT"];
|
||||
|
||||
/**
|
||||
* Tests for executor environment reuse across sessions.
|
||||
* Verifies that task environments persist across sessions and that
|
||||
* the API response includes container_id/sandbox_id fields.
|
||||
*
|
||||
* Note: E2E tests run with KANDEV_DOCKER_ENABLED=false and KANDEV_MOCK_AGENT=only,
|
||||
* so Docker container reuse cannot be tested end-to-end here.
|
||||
* Docker reconnect logic is covered by Go unit tests.
|
||||
*/
|
||||
test.describe("Executor reuse", () => {
|
||||
test("task environment API response includes executor_type field", async ({
|
||||
apiClient,
|
||||
seedData,
|
||||
}) => {
|
||||
// Create task with session, wait for completion
|
||||
const task = await apiClient.createTaskWithAgent(
|
||||
seedData.workspaceId,
|
||||
"Env Fields Task",
|
||||
seedData.agentProfileId,
|
||||
{
|
||||
description: "/e2e:simple-message",
|
||||
workflow_id: seedData.workflowId,
|
||||
workflow_step_id: seedData.startStepId,
|
||||
repository_ids: [seedData.repositoryId],
|
||||
},
|
||||
);
|
||||
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const { sessions } = await apiClient.listTaskSessions(task.id);
|
||||
return DONE_STATES.includes(sessions[0]?.state ?? "");
|
||||
},
|
||||
{ timeout: 30_000, message: "Waiting for session to finish" },
|
||||
)
|
||||
.toBe(true);
|
||||
|
||||
// Get environment and verify response shape
|
||||
const env = await apiClient.getTaskEnvironment(task.id);
|
||||
expect(env).not.toBeNull();
|
||||
expect(env!.task_id).toBe(task.id);
|
||||
expect(env!.status).toBe("ready");
|
||||
// executor_type should be present (standalone for mock agent)
|
||||
expect(env!.executor_type).toBeDefined();
|
||||
});
|
||||
|
||||
test("second session reuses same task environment by default", async ({
|
||||
testPage,
|
||||
apiClient,
|
||||
seedData,
|
||||
}) => {
|
||||
test.setTimeout(120_000);
|
||||
|
||||
// 1. Create task with first session
|
||||
const task = await apiClient.createTaskWithAgent(
|
||||
seedData.workspaceId,
|
||||
"Reuse Env Task",
|
||||
seedData.agentProfileId,
|
||||
{
|
||||
description: "/e2e:simple-message",
|
||||
workflow_id: seedData.workflowId,
|
||||
workflow_step_id: seedData.startStepId,
|
||||
repository_ids: [seedData.repositoryId],
|
||||
},
|
||||
);
|
||||
|
||||
// 2. Wait for first session to complete
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const { sessions } = await apiClient.listTaskSessions(task.id);
|
||||
return DONE_STATES.includes(sessions[0]?.state ?? "");
|
||||
},
|
||||
{ timeout: 30_000, message: "Waiting for first session to finish" },
|
||||
)
|
||||
.toBe(true);
|
||||
|
||||
// 3. Capture environment
|
||||
const envBefore = await apiClient.getTaskEnvironment(task.id);
|
||||
expect(envBefore).not.toBeNull();
|
||||
|
||||
// 4. Navigate to task and create second session via dialog
|
||||
const kanban = new KanbanPage(testPage);
|
||||
await kanban.goto();
|
||||
|
||||
const card = kanban.taskCardByTitle("Reuse Env Task");
|
||||
await expect(card).toBeVisible({ timeout: 10_000 });
|
||||
await card.click();
|
||||
await expect(testPage).toHaveURL(/\/t\//, { timeout: 15_000 });
|
||||
|
||||
const session = new SessionPage(testPage);
|
||||
await session.waitForLoad();
|
||||
await expect(session.chat.getByText("simple mock response", { exact: false })).toBeVisible({
|
||||
timeout: 15_000,
|
||||
});
|
||||
|
||||
// 5. Open new session dialog and submit
|
||||
await session.openNewSessionDialog();
|
||||
await expect(session.newSessionDialog()).toBeVisible({ timeout: 5_000 });
|
||||
await session.newSessionPromptInput().fill("/e2e:simple-message");
|
||||
await session.newSessionStartButton().click();
|
||||
await expect(session.newSessionDialog()).not.toBeVisible({ timeout: 10_000 });
|
||||
|
||||
// 6. Wait for second session
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const { sessions } = await apiClient.listTaskSessions(task.id);
|
||||
return sessions.length;
|
||||
},
|
||||
{ timeout: 30_000, message: "Waiting for second session to appear" },
|
||||
)
|
||||
.toBe(2);
|
||||
|
||||
// 7. Verify same environment ID (default reuse behavior)
|
||||
const envAfter = await apiClient.getTaskEnvironment(task.id);
|
||||
expect(envAfter).not.toBeNull();
|
||||
expect(envAfter!.id).toBe(envBefore!.id);
|
||||
|
||||
// 8. Both sessions reference the same environment
|
||||
const { sessions: allSessions } = await apiClient.listTaskSessions(task.id);
|
||||
for (const s of allSessions) {
|
||||
expect(s.task_environment_id).toBe(envBefore!.id);
|
||||
}
|
||||
});
|
||||
|
||||
test("reset environment from executor settings popover removes the environment", async ({
|
||||
testPage,
|
||||
apiClient,
|
||||
seedData,
|
||||
}) => {
|
||||
test.setTimeout(90_000);
|
||||
|
||||
const task = await apiClient.createTaskWithAgent(
|
||||
seedData.workspaceId,
|
||||
"Reset Env Task",
|
||||
seedData.agentProfileId,
|
||||
{
|
||||
description: "/e2e:simple-message",
|
||||
workflow_id: seedData.workflowId,
|
||||
workflow_step_id: seedData.startStepId,
|
||||
repository_ids: [seedData.repositoryId],
|
||||
},
|
||||
);
|
||||
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const { sessions } = await apiClient.listTaskSessions(task.id);
|
||||
return DONE_STATES.includes(sessions[0]?.state ?? "");
|
||||
},
|
||||
{ timeout: 30_000, message: "Waiting for session to finish" },
|
||||
)
|
||||
.toBe(true);
|
||||
|
||||
const envBefore = await apiClient.getTaskEnvironment(task.id);
|
||||
expect(envBefore).not.toBeNull();
|
||||
|
||||
// Navigate to task
|
||||
const kanban = new KanbanPage(testPage);
|
||||
await kanban.goto();
|
||||
|
||||
const card = kanban.taskCardByTitle("Reset Env Task");
|
||||
await expect(card).toBeVisible({ timeout: 10_000 });
|
||||
await card.click();
|
||||
await expect(testPage).toHaveURL(/\/t\//, { timeout: 15_000 });
|
||||
|
||||
const session = new SessionPage(testPage);
|
||||
await session.waitForLoad();
|
||||
|
||||
// Open popover
|
||||
await testPage.getByTestId("executor-settings-button").click();
|
||||
const popover = testPage.getByTestId("executor-settings-popover");
|
||||
await expect(popover).toBeVisible({ timeout: 5_000 });
|
||||
|
||||
// Click Reset → confirmation dialog
|
||||
await testPage.getByTestId("executor-settings-reset").click();
|
||||
const ackCheckbox = testPage.getByRole("checkbox").last();
|
||||
await ackCheckbox.click();
|
||||
await testPage.getByTestId("reset-env-confirm").click();
|
||||
|
||||
// Poll environment until gone
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const env = await apiClient.getTaskEnvironment(task.id);
|
||||
return env;
|
||||
},
|
||||
{ timeout: 15_000, message: "Waiting for environment to be reset" },
|
||||
)
|
||||
.toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,44 @@
|
||||
import { fetchJson, type ApiRequestOptions } from "../client";
|
||||
|
||||
export type TaskEnvironment = {
|
||||
id: string;
|
||||
task_id: string;
|
||||
repository_id: string;
|
||||
executor_type: string;
|
||||
executor_id: string;
|
||||
executor_profile_id: string;
|
||||
agent_execution_id: string;
|
||||
control_port: number;
|
||||
status: string;
|
||||
worktree_id?: string;
|
||||
worktree_path?: string;
|
||||
worktree_branch?: string;
|
||||
workspace_path?: string;
|
||||
container_id?: string;
|
||||
sandbox_id?: string;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
};
|
||||
|
||||
export type ResetTaskEnvironmentPayload = {
|
||||
push_branch?: boolean;
|
||||
};
|
||||
|
||||
export async function fetchTaskEnvironment(taskId: string, options?: ApiRequestOptions) {
|
||||
return fetchJson<TaskEnvironment>(`/api/v1/tasks/${taskId}/environment`, options);
|
||||
}
|
||||
|
||||
export async function resetTaskEnvironment(
|
||||
taskId: string,
|
||||
payload: ResetTaskEnvironmentPayload,
|
||||
options?: ApiRequestOptions,
|
||||
) {
|
||||
return fetchJson<{ success: boolean }>(`/api/v1/tasks/${taskId}/environment/reset`, {
|
||||
...options,
|
||||
init: {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload),
|
||||
...(options?.init ?? {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user