Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/lib/actions/sandbox/gateway-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ export async function ensureLiveSandboxOrExit(
const lookup = await getReconciledSandboxGatewayState(sandboxName);
if (lookup.state === "present") {
const phase = parseSandboxPhase(lookup.output || "");
if (!allowNonReadyPhase && phase && phase !== "Ready") {
if (!allowNonReadyPhase && phase && phase !== "Ready" && phase !== "Running") {
console.error(` Sandbox '${sandboxName}' is stuck in '${phase}' phase.`);
console.error(
" This usually happens when a process crash inside the sandbox prevented clean startup.",
Expand Down
13 changes: 9 additions & 4 deletions src/lib/state/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,20 @@ export function parseSandboxStatus(output: string, sandboxName: string): string
}

/**
* Check if a sandbox is in Ready state from `openshell sandbox list` output.
* Check if a sandbox is in a live state from `openshell sandbox list` output.
* Strips ANSI codes and exact-matches the sandbox name in the first column.
* Checks all columns for "Ready" (not just column 2) because the column
* layout of `openshell sandbox list` varies across OpenShell versions.
* Checks all columns for "Ready" or "Running" (not just column 2) because
* the column layout of `openshell sandbox list` varies across OpenShell versions.
*
* Both "Ready" and "Running" indicate the sandbox is alive and health
* checks should proceed. On some deployments (e.g. Brev launchables) the
* sandbox stays in "Running" phase which is functionally equivalent to
* "Ready" — the agent is live and the gateway is reachable inside.
*/
export function isSandboxReady(output: string, sandboxName: string): boolean {
const cols = parseSandboxRow(output, sandboxName);
if (!cols) return false;
return cols.includes("Ready") && !cols.includes("NotReady");
return (cols.includes("Ready") || cols.includes("Running")) && !cols.includes("NotReady");
}

/**
Expand Down
10 changes: 10 additions & 0 deletions test/onboard-readiness.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ describe("sandbox readiness parsing", () => {
).toBeTruthy();
});

it("treats Running phase as alive (Brev launchable deployments)", () => {
expect(isSandboxReady("my-assistant Running 2m ago", "my-assistant")).toBeTruthy();
});

it("treats Running phase with ANSI codes as alive", () => {
expect(
isSandboxReady("\x1b[1mmy-assistant\x1b[0m \x1b[33mRunning\x1b[0m 2m ago", "my-assistant"),
).toBeTruthy();
});

it("rejects when output only contains name in a URL or path", () => {
expect(
!isSandboxReady("Connecting to my-assistant.openshell.internal Ready", "my-assistant"),
Expand Down
Loading