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 apps/server/src/orchestration-v2/RestartBackgroundNote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function cancelledTurnItemWork(
}
case "command_execution":
return {
kind: "shell",
kind: item.monitor === true ? "monitor" : "shell",
label: compactLabel(item.input) ?? compactLabel(item.title) ?? "background command",
id: item.id,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { assert } from "@effect/vitest";
import type { ProviderReplayTranscript } from "@t3tools/contracts";
import { derivePendingBackgroundWork } from "@t3tools/shared/orchestrationV2PendingBackgroundWork";

import type { OrchestratorV2ScenarioResult } from "../../OrchestratorScenario.ts";
import { cancelledTurnItemWork } from "../../../RestartBackgroundNote.ts";
import {
assertBaseProjection,
assertSemanticProjectionIntegrity,
Expand Down Expand Up @@ -54,6 +56,20 @@ export function assertGrokMonitorOutput(
assert.equal(monitorUpdates[tickUpdate]?.status, "running", `${tick} must show running`);
}

// A persistent monitor keeps running after its run ends. Background work and
// the restart note must then name it a monitor, as they do for Claude's Monitor.
const runningMonitor = monitorUpdates.find((update) => update.status === "running");
assert.isDefined(runningMonitor);
assert.deepEqual(
derivePendingBackgroundWork({
latestRun: rootRun,
providerThreads: [],
turnItems: [runningMonitor],
}).map((task) => task.kind),
["monitor"],
);
assert.equal(cancelledTurnItemWork(runningMonitor)?.kind, "monitor");

const monitorCompletedAt = result.domainEvents.findIndex(
(event) =>
event.type === "turn-item.updated" &&
Expand Down
4 changes: 4 additions & 0 deletions packages/contracts/src/orchestrationV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,8 @@ export const OrchestrationV2TurnItem = Schema.Union([
outputOmitted: Schema.optional(Schema.Boolean),
outputIndicatesFailure: Schema.optional(Schema.Boolean),
exitCode: Schema.optional(Schema.Int),
/** Set when the command is a monitor, so background work lists it as a monitor. */
monitor: Schema.optional(Schema.Boolean),
}),
Schema.Struct({
...OrchestrationV2TurnItemBaseFields,
Expand Down Expand Up @@ -2244,6 +2246,8 @@ export const OrchestrationV2TurnItemJson = Schema.Union([
outputOmitted: Schema.optional(Schema.Boolean),
outputIndicatesFailure: Schema.optional(Schema.Boolean),
exitCode: Schema.optional(Schema.Int),
/** Set when the command is a monitor, so background work lists it as a monitor. */
monitor: Schema.optional(Schema.Boolean),
}),
Schema.Struct({
...OrchestrationV2TurnItemJsonBaseFields,
Expand Down
1 change: 1 addition & 0 deletions packages/provider-acp/src/server/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3916,6 +3916,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
? {}
: { output: textFromUnknown(rawOutput) }),
...(exitCode === undefined ? {} : { exitCode }),
...(inputVariant === "monitor" ? { monitor: true } : {}),
Comment thread
coderabbitai[bot] marked this conversation as resolved.
};
} else {
turnItem = {
Expand Down
3 changes: 2 additions & 1 deletion packages/shared/src/orchestrationV2PendingBackgroundWork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ type PendingBackgroundWorkTurnItem = {
readonly nativeId: string | null;
} | null;
readonly input?: unknown;
readonly monitor?: boolean | undefined;
readonly prompt?: string | undefined;
readonly childThreadId?: ThreadId | null;
};
Expand Down Expand Up @@ -190,7 +191,7 @@ function pendingTaskFromTurnItem(
...(item.childThreadId == null ? {} : { childThreadId: item.childThreadId }),
};
case "command_execution":
return { ...named, kind: "command" };
return { ...named, kind: item.monitor === true ? "monitor" : "command" };
default:
return { ...named, kind: "background_task" };
}
Expand Down
Loading