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:
Nathan Flurry 2026-03-16 15:19:49 -07:00
parent 78cd38d826
commit ee25a6c6a5
6 changed files with 106 additions and 42 deletions

View file

@ -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"],

View file

@ -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 {

View file

@ -1,5 +1,6 @@
import { describe, expect, it } from "vitest";
import { deriveFallbackTitle, resolveCreateFlowDecision, sanitizeBranchName } from "../src/services/create-flow.js";
import { BRANCH_NAME_PREFIXES } from "../src/services/branch-name-prefixes.js";
describe("create flow decision", () => {
it("derives a conventional-style fallback title from task text", () => {
@ -17,15 +18,49 @@ describe("create flow decision", () => {
expect(sanitizeBranchName(" spaces everywhere ")).toBe("spaces-everywhere");
});
it("auto-increments generated branch names for conflicts", () => {
it("generates a McMaster-Carr-style branch name with random suffix", () => {
const resolved = resolveCreateFlowDecision({
task: "Add auth",
localBranches: ["feat-add-auth"],
taskBranches: ["feat-add-auth-2"],
localBranches: [],
taskBranches: [],
});
expect(resolved.title).toBe("feat: Add auth");
expect(resolved.branchName).toBe("feat-add-auth-3");
// Branch name should be "<prefix>-<4-char-suffix>" where prefix is from BRANCH_NAME_PREFIXES
const lastDash = resolved.branchName.lastIndexOf("-");
const prefix = resolved.branchName.slice(0, lastDash);
const suffix = resolved.branchName.slice(lastDash + 1);
expect(BRANCH_NAME_PREFIXES).toContain(prefix);
expect(suffix).toMatch(/^[a-z0-9]{4}$/);
});
it("avoids conflicts by generating a different random name", () => {
// Even with a conflicting branch, it should produce something different
const resolved = resolveCreateFlowDecision({
task: "Add auth",
localBranches: [],
taskBranches: [],
});
// Running again with the first result as a conflict should produce a different name
const resolved2 = resolveCreateFlowDecision({
task: "Add auth",
localBranches: [resolved.branchName],
taskBranches: [],
});
expect(resolved2.branchName).not.toBe(resolved.branchName);
});
it("uses explicit branch name when provided", () => {
const resolved = resolveCreateFlowDecision({
task: "new task",
explicitBranchName: "my-branch",
localBranches: [],
taskBranches: [],
});
expect(resolved.branchName).toBe("my-branch");
});
it("fails when explicit branch already exists", () => {