mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-16 04:02:01 +00:00
chore(foundry): migrate to actions (#262)
* feat(foundry): checkpoint actor and workspace refactor
* docs(foundry): add agent handoff context
* wip(foundry): continue actor refactor
* wip(foundry): capture remaining local changes
* Complete Foundry refactor checklist
* Fix Foundry validation fallout
* wip
* wip: convert all actors from workflow to plain run handlers
Workaround for RivetKit bug where c.queue.iter() never yields messages
for actors created via getOrCreate from another actor's context. The
queue accepts messages (visible in inspector) but the iterator hangs.
Sleep/wake fixes it, but actors with active connections never sleep.
Converted organization, github-data, task, and user actors from
run: workflow(...) to plain run: async (c) => { for await ... }.
Also fixes:
- Missing auth tables in org migration (auth_verification etc)
- default_model NOT NULL constraint on org profile upsert
- Nested workflow step in github-data (HistoryDivergedError)
- Removed --force from frontend Dockerfile pnpm install
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Convert all actors from queues/workflows to direct actions, lazy task creation
Major refactor replacing all queue-based workflow communication with direct
RivetKit action calls across all actors. This works around a RivetKit bug
where c.queue.iter() deadlocks for actors created from another actor's context.
Key changes:
- All actors (organization, task, user, audit-log, github-data) converted
from run: workflow(...) to actions-only (no run handler, no queues)
- PR sync creates virtual task entries in org local DB instead of spawning
task actors — prevents OOM from 200+ actors created simultaneously
- Task actors created lazily on first user interaction via getOrCreate,
self-initialize from org's getTaskIndexEntry data
- Removed requireRepoExists cross-actor call (caused 500s), replaced with
local resolveTaskRepoId from org's taskIndex table
- Fixed getOrganizationContext to thread overrides through all sync phases
- Fixed sandbox repo path (/home/user/repo for E2B compatibility)
- Fixed buildSessionDetail to skip transcript fetch for pending sessions
- Added process crash protection (uncaughtException/unhandledRejection)
- Fixed React infinite render loop in mock-layout useEffect dependencies
- Added sandbox listProcesses error handling for expired E2B sandboxes
- Set E2B sandbox timeout to 1 hour (was 5 min default)
- Updated CLAUDE.md with lazy task creation rules, no-silent-catch policy,
React hook dependency safety rules
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Fix E2B sandbox timeout comment, frontend stability, and create-flow improvements
- Add TEMPORARY comment on E2B timeoutMs with pointer to rivetkit sandbox
resilience proposal for when autoPause lands
- Fix React useEffect dependency stability in mock-layout and
organization-dashboard to prevent infinite re-render loops
- Fix terminal-pane ref handling
- Improve create-flow service and tests
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
32f3c6c3bc
commit
f45a467484
139 changed files with 9768 additions and 7204 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import type { AppConfig, TaskRecord } from "@sandbox-agent/foundry-shared";
|
||||
import type { AppConfig, TaskRecord, WorkspaceTaskDetail } from "@sandbox-agent/foundry-shared";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { createBackendClientFromConfig, filterTasks, formatRelativeAge, groupTaskStatus } from "@sandbox-agent/foundry-client";
|
||||
import { CLI_BUILD_ID } from "./build-id.js";
|
||||
|
|
@ -51,14 +51,28 @@ interface DisplayRow {
|
|||
age: string;
|
||||
}
|
||||
|
||||
type TuiTaskRow = TaskRecord & Pick<WorkspaceTaskDetail, "pullRequest"> & { activeSessionId?: string | null };
|
||||
|
||||
interface RenderOptions {
|
||||
width?: number;
|
||||
height?: number;
|
||||
}
|
||||
|
||||
async function listDetailedTasks(client: ReturnType<typeof createBackendClientFromConfig>, organizationId: string): Promise<TaskRecord[]> {
|
||||
async function listDetailedTasks(client: ReturnType<typeof createBackendClientFromConfig>, organizationId: string): Promise<TuiTaskRow[]> {
|
||||
const rows = await client.listTasks(organizationId);
|
||||
return await Promise.all(rows.map(async (row) => await client.getTask(organizationId, row.taskId)));
|
||||
return await Promise.all(
|
||||
rows.map(async (row) => {
|
||||
const [task, detail] = await Promise.all([
|
||||
client.getTask(organizationId, row.repoId, row.taskId),
|
||||
client.getTaskDetail(organizationId, row.repoId, row.taskId).catch(() => null),
|
||||
]);
|
||||
return {
|
||||
...task,
|
||||
pullRequest: detail?.pullRequest ?? null,
|
||||
activeSessionId: detail?.activeSessionId ?? null,
|
||||
};
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
function pad(input: string, width: number): string {
|
||||
|
|
@ -143,29 +157,17 @@ function agentSymbol(status: TaskRecord["status"]): string {
|
|||
return "-";
|
||||
}
|
||||
|
||||
function toDisplayRow(row: TaskRecord): DisplayRow {
|
||||
const conflictPrefix = row.conflictsWithMain === "true" ? "\u26A0 " : "";
|
||||
|
||||
const prLabel = row.prUrl ? `#${row.prUrl.match(/\/pull\/(\d+)/)?.[1] ?? "?"}` : row.prSubmitted ? "sub" : "-";
|
||||
|
||||
const ciLabel = row.ciStatus ?? "-";
|
||||
const reviewLabel = row.reviewStatus
|
||||
? row.reviewStatus === "approved"
|
||||
? "ok"
|
||||
: row.reviewStatus === "changes_requested"
|
||||
? "chg"
|
||||
: row.reviewStatus === "pending"
|
||||
? "..."
|
||||
: row.reviewStatus
|
||||
: "-";
|
||||
function toDisplayRow(row: TuiTaskRow): DisplayRow {
|
||||
const prLabel = row.pullRequest ? `#${row.pullRequest.number}` : "-";
|
||||
const reviewLabel = row.pullRequest ? (row.pullRequest.isDraft ? "draft" : row.pullRequest.state.toLowerCase()) : "-";
|
||||
|
||||
return {
|
||||
name: `${conflictPrefix}${row.title || row.branchName}`,
|
||||
diff: row.diffStat ?? "-",
|
||||
name: row.title || row.branchName || row.taskId,
|
||||
diff: "-",
|
||||
agent: agentSymbol(row.status),
|
||||
pr: prLabel,
|
||||
author: row.prAuthor ?? "-",
|
||||
ci: ciLabel,
|
||||
author: row.pullRequest?.authorLogin ?? "-",
|
||||
ci: "-",
|
||||
review: reviewLabel,
|
||||
age: formatRelativeAge(row.updatedAt),
|
||||
};
|
||||
|
|
@ -186,7 +188,7 @@ function helpLines(width: number): string[] {
|
|||
}
|
||||
|
||||
export function formatRows(
|
||||
rows: TaskRecord[],
|
||||
rows: TuiTaskRow[],
|
||||
selected: number,
|
||||
organizationId: string,
|
||||
status: string,
|
||||
|
|
@ -336,8 +338,8 @@ export async function runTui(config: AppConfig, organizationId: string): Promise
|
|||
renderer.root.add(text);
|
||||
renderer.start();
|
||||
|
||||
let allRows: TaskRecord[] = [];
|
||||
let filteredRows: TaskRecord[] = [];
|
||||
let allRows: TuiTaskRow[] = [];
|
||||
let filteredRows: TuiTaskRow[] = [];
|
||||
let selected = 0;
|
||||
let searchQuery = "";
|
||||
let showHelp = false;
|
||||
|
|
@ -393,7 +395,7 @@ export async function runTui(config: AppConfig, organizationId: string): Promise
|
|||
render();
|
||||
};
|
||||
|
||||
const selectedRow = (): TaskRecord | null => {
|
||||
const selectedRow = (): TuiTaskRow | null => {
|
||||
if (filteredRows.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -522,7 +524,7 @@ export async function runTui(config: AppConfig, organizationId: string): Promise
|
|||
render();
|
||||
void (async () => {
|
||||
try {
|
||||
const result = await client.switchTask(organizationId, row.taskId);
|
||||
const result = await client.switchTask(organizationId, row.repoId, row.taskId);
|
||||
close(`cd ${result.switchTarget}`);
|
||||
} catch (err) {
|
||||
busy = false;
|
||||
|
|
@ -543,7 +545,7 @@ export async function runTui(config: AppConfig, organizationId: string): Promise
|
|||
render();
|
||||
void (async () => {
|
||||
try {
|
||||
const result = await client.attachTask(organizationId, row.taskId);
|
||||
const result = await client.attachTask(organizationId, row.repoId, row.taskId);
|
||||
close(`target=${result.target} session=${result.sessionId ?? "none"}`);
|
||||
} catch (err) {
|
||||
busy = false;
|
||||
|
|
@ -559,7 +561,11 @@ export async function runTui(config: AppConfig, organizationId: string): Promise
|
|||
if (!row) {
|
||||
return;
|
||||
}
|
||||
void runActionWithRefresh(`archiving ${row.taskId}`, async () => client.runAction(organizationId, row.taskId, "archive"), `archived ${row.taskId}`);
|
||||
void runActionWithRefresh(
|
||||
`archiving ${row.taskId}`,
|
||||
async () => client.runAction(organizationId, row.repoId, row.taskId, "archive"),
|
||||
`archived ${row.taskId}`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -568,7 +574,11 @@ export async function runTui(config: AppConfig, organizationId: string): Promise
|
|||
if (!row) {
|
||||
return;
|
||||
}
|
||||
void runActionWithRefresh(`syncing ${row.taskId}`, async () => client.runAction(organizationId, row.taskId, "sync"), `synced ${row.taskId}`);
|
||||
void runActionWithRefresh(
|
||||
`syncing ${row.taskId}`,
|
||||
async () => client.runAction(organizationId, row.repoId, row.taskId, "sync"),
|
||||
`synced ${row.taskId}`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -580,8 +590,8 @@ export async function runTui(config: AppConfig, organizationId: string): Promise
|
|||
void runActionWithRefresh(
|
||||
`merging ${row.taskId}`,
|
||||
async () => {
|
||||
await client.runAction(organizationId, row.taskId, "merge");
|
||||
await client.runAction(organizationId, row.taskId, "archive");
|
||||
await client.runAction(organizationId, row.repoId, row.taskId, "merge");
|
||||
await client.runAction(organizationId, row.repoId, row.taskId, "archive");
|
||||
},
|
||||
`merged+archived ${row.taskId}`,
|
||||
);
|
||||
|
|
@ -590,14 +600,15 @@ export async function runTui(config: AppConfig, organizationId: string): Promise
|
|||
|
||||
if (ctrl && name === "o") {
|
||||
const row = selectedRow();
|
||||
if (!row?.prUrl) {
|
||||
const prUrl = row?.pullRequest?.url ?? null;
|
||||
if (!prUrl) {
|
||||
status = "no PR URL available for this task";
|
||||
render();
|
||||
return;
|
||||
}
|
||||
const openCmd = process.platform === "darwin" ? "open" : "xdg-open";
|
||||
spawnSync(openCmd, [row.prUrl], { stdio: "ignore" });
|
||||
status = `opened ${row.prUrl}`;
|
||||
spawnSync(openCmd, [prUrl], { stdio: "ignore" });
|
||||
status = `opened ${prUrl}`;
|
||||
render();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue