mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-20 16:05:18 +00:00
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>
This commit is contained in:
parent
78cd38d826
commit
ee25a6c6a5
6 changed files with 106 additions and 42 deletions
|
|
@ -205,9 +205,12 @@ const baseTaskSandbox = sandboxActor({
|
|||
create: () => ({
|
||||
template: config.sandboxProviders.e2b.template ?? "sandbox-agent-full-0.3.x",
|
||||
envs: sandboxEnvObject(),
|
||||
// Default E2B timeout is 5 minutes which is too short for task work.
|
||||
// Set to 1 hour. TODO: use betaCreate + autoPause instead so sandboxes
|
||||
// pause (preserving state) rather than being killed on timeout.
|
||||
// TEMPORARY: Default E2B timeout is 5 minutes which is too short.
|
||||
// Set to 1 hour as a stopgap. Remove this once the E2B provider in
|
||||
// sandbox-agent uses betaCreate + autoPause (see
|
||||
// .context/proposal-rivetkit-sandbox-resilience.md). At that point
|
||||
// the provider handles timeout/pause lifecycle and this override is
|
||||
// unnecessary.
|
||||
timeoutMs: 60 * 60 * 1000,
|
||||
}),
|
||||
installAgents: ["claude", "codex"],
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { BRANCH_NAME_PREFIXES } from "./branch-name-prefixes.js";
|
||||
|
||||
export interface ResolveCreateFlowDecisionInput {
|
||||
task: string;
|
||||
explicitTitle?: string;
|
||||
|
|
@ -89,30 +91,42 @@ export function sanitizeBranchName(input: string): string {
|
|||
return trimmed.slice(0, 50).replace(/-+$/g, "");
|
||||
}
|
||||
|
||||
function generateRandomSuffix(length: number): string {
|
||||
const chars = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
let result = "";
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += chars[Math.floor(Math.random() * chars.length)];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function generateBranchName(): string {
|
||||
const prefix = BRANCH_NAME_PREFIXES[Math.floor(Math.random() * BRANCH_NAME_PREFIXES.length)]!;
|
||||
const suffix = generateRandomSuffix(4);
|
||||
return `${prefix}-${suffix}`;
|
||||
}
|
||||
|
||||
export function resolveCreateFlowDecision(input: ResolveCreateFlowDecisionInput): ResolveCreateFlowDecisionResult {
|
||||
const explicitBranch = input.explicitBranchName?.trim();
|
||||
const title = deriveFallbackTitle(input.task, input.explicitTitle);
|
||||
const generatedBase = sanitizeBranchName(title) || "task";
|
||||
|
||||
const branchBase = explicitBranch && explicitBranch.length > 0 ? explicitBranch : generatedBase;
|
||||
|
||||
const existingBranches = new Set(input.localBranches.map((value) => value.trim()).filter((value) => value.length > 0));
|
||||
const existingTaskBranches = new Set(input.taskBranches.map((value) => value.trim()).filter((value) => value.length > 0));
|
||||
const conflicts = (name: string): boolean => existingBranches.has(name) || existingTaskBranches.has(name);
|
||||
|
||||
if (explicitBranch && conflicts(branchBase)) {
|
||||
throw new Error(`Branch '${branchBase}' already exists. Choose a different --name/--branch value.`);
|
||||
if (explicitBranch && explicitBranch.length > 0) {
|
||||
if (conflicts(explicitBranch)) {
|
||||
throw new Error(`Branch '${explicitBranch}' already exists. Choose a different --name/--branch value.`);
|
||||
}
|
||||
return { title, branchName: explicitBranch };
|
||||
}
|
||||
|
||||
if (explicitBranch) {
|
||||
return { title, branchName: branchBase };
|
||||
}
|
||||
|
||||
let candidate = branchBase;
|
||||
let index = 2;
|
||||
while (conflicts(candidate)) {
|
||||
candidate = `${branchBase}-${index}`;
|
||||
index += 1;
|
||||
// Generate a random McMaster-Carr-style branch name, retrying on conflicts
|
||||
let candidate = generateBranchName();
|
||||
let attempts = 0;
|
||||
while (conflicts(candidate) && attempts < 100) {
|
||||
candidate = generateBranchName();
|
||||
attempts += 1;
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue