fix(server): Stop ends detached Antigravity commands on Linux and macOS #36585
main fromrefs/pull/36585/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
tanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
saphid(GitHub profile, opens in a new tab) changed the title
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
github-actions[bot](GitHub profile, opens in a new tab) added labels📱 Native Change
- apps/server/src/process/NonBlockingSpawner.ts line 29OutdatedResolvedby saphid(GitHub profile, opens in a new tab)@@ -0,0 +9,21 @@9+import * as Path from "effect/Path";10+import * as PlatformError from "effect/PlatformError";11+import * as Redacted from "effect/Redacted";12+import * as ChildProcess from "effect/process/ChildProcess";13+import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";14+import * as CommandLine from "effect/process/CommandLine";15+16+// libuv's _PATH_DEFPATH, searched when the child environment has no PATH.17+const DEFAULT_PATH = "/usr/bin:/bin";18+19+// A check on a hung mount holds a libuv threadpool thread until the mount answers, and the20+// pool's four threads also compress every WebSocket frame. Checks therefore run one at a time21+// per directory and two at a time overall; the rest wait without holding a thread.22+const CHECK_LIMIT = 2;23+const directoryTails = new Map<string, Promise<unknown>>();24+const waiting: Array<() => void> = [];25+let running = 0;26+27+const access = async (path: string, mode: number) => {28+ if (running < CHECK_LIMIT) running++;29+ else await new Promise<void>((resume) => waiting.push(resume));apps/server/src/orchestration-v2/placeholderThreadTitle.ts line 6OutdatedResolvedby saphid(GitHub profile, opens in a new tab)@@ -0,0 +1,6 @@1+// An agent may create a thread with neither a title nor a prompt; its name is then a placeholder2+// that the first message should replace, unlike a title the caller chose.3+export const placeholderThreadTitle = (parentTitle: string, index: number): string =>4+ `${parentTitle} thread ${index + 1}`;5+6+export const isPlaceholderThreadTitle = (title: string): boolean => / thread \d+$/u.test(title);apps/server/src/process/SpawnWorker.ts line 450OutdatedResolvedby saphid(GitHub profile, opens in a new tab)@@ -0,0 +430,21 @@430+ }431+}432+433+class SpawnWorkerPool {434+ readonly workers = new Set<SpawnWorker>();435+ readonly platform: NodeJS.Platform;436+ #nextId = 0;437+438+ constructor(platform: NodeJS.Platform) {439+ this.platform = platform;440+ }441+442+ readonly spawn = (443+ command: string,444+ args: ReadonlyArray<string>,445+ options: NodeChildProcess.SpawnOptions,446+ ) => {447+ const workers = [...this.workers];448+ // A worker inside CreateProcess cannot start another launch until it returns.449+ const worker =450+ workers.find((candidate) => candidate.launching === 0) ??
- packages/provider-acp/src/server/darwinProcessTree.ts line 1OutdatedResolvedby saphid(GitHub profile, opens in a new tab)@@ -0,0 +1 @@1+// @effect-diagnostics nodeBuiltinImport:off
github-actions[bot](GitHub profile, opens in a new tab) removed labels📱 Native Change
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XXL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- @@ -2514,3 +2515,9 @@25142515 ? notePromptProgress()25152516 : Effect.void,25162517 );2518+ const failTurnOnRuntimeTermination = Effect.fn("AcpAdapterV2.failTurnOnRuntimeTermination")(2519+ function* (context: ActiveAcpTurn, runtimeGeneration: number) {2520+ yield* quarantineNativeTransportAtGeneration(runtimeGeneration);2521+ yield* advanceRuntimeCallbackGeneration;2522+ yield* cancelPendingRuntimeRequests();2523+ for (const tool of context.tools.values()) {
Pusheda91656c
- @@ -1094,0 +1125,21 @@1125+ content: { type: "text", text: "Here is the chart." },1126+ });1127+ yield* TestClock.adjust("10 seconds");1128+ yield* send(usage);1129+ yield* TestClock.adjust("3 seconds");1130+ const continued = yield* throughTerminal;1131+ const continuedTerminal = continued.at(-1);1132+ assert.equal(1133+ continuedTerminal?.type === "turn.terminal" && continuedTerminal.status,1134+ "completed",1135+ );1136+ assert.isTrue(1137+ continued.some(1138+ (event) =>1139+ event.type === "turn_item.updated" &&1140+ event.turnItem.type === "assistant_message" &&1141+ event.turnItem.runId ===1142+ RunId.make(`run-antigravity-wake-${commandOutlivesPrompt ? 1 : 2}`),1143+ ),1144+ "the reply belongs to the active run",1145+ );@@ -1109,0 +1499,21 @@1499+ { stopAfterReply: false, terminateAfterReply, negotiatedDeferral },1500+ );1501+ assert.equal(result.itemStatus, "failed");1502+ assert.equal(result.terminalStatus, "failed");1503+ }),1504+ );1505+1506+ it.effect("completes the turn at end_turn while a launched subagent batch runs", () =>1507+ Effect.gen(function* () {1508+ const result = yield* endTurnAfterTool(1509+ {1510+ sessionUpdate: "tool_call",1511+ toolCallId: "batch",1512+ title: "Running start_subagent",1513+ kind: "other",1514+ status: "completed",1515+ rawOutput: "Started two agents.",1516+ },1517+ { stopAfterReply: false },1518+ );1519+ assert.equal(result.terminalStatus, "completed");@@ -2573,6 +2581,20 @@2581+ if (status === "pending" || status === "running" || status === "waiting") {2582+ yield* emitTool(context, tool, context.interrupted ? "interrupted" : "failed");2583+ }2584+ }2585+ yield* finalizeTurn(2586+ context,2587+ "failed",2588+ makeProviderFailure({ class: "transport_error" }),2589+ );2590+ },2591+ );25732592 const handleRuntimeTerminationAtGeneration = (runtimeGeneration: number) =>25742593 runRuntimeCallbackAtGeneration(25752594 runtimeGeneration,25762595 Effect.gen(function* () {25772596 yield* Ref.set(runtimeRestartRequired, true);2578- if (!followsAgentWorkState) return;2597+ if (!followsAgentWorkState) {2598+ const context = yield* Ref.get(activeTurn);2599+ if (context === null || context.finalized) return;2600+ context.runtimeTerminated = true;
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Approvability#
Verdict: Needs Human Approval
Macroscope's review found this PR requires human approval — Stop now terminates Antigravity’s owned background commands and restarts its runtime. The changed default behavior and two new file-level diagnostic suppressions require human review.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).