File tree Expand file tree Collapse file tree
apps/server/src/orchestration-v2
testkit/fixtures/grok_monitor Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ export function cancelledTurnItemWork(
5151 }
5252 case "command_execution" :
5353 return {
54- kind : "shell" ,
54+ kind : item . monitor === true ? "monitor" : "shell" ,
5555 label : compactLabel ( item . input ) ?? compactLabel ( item . title ) ?? "background command" ,
5656 id : item . id ,
5757 } ;
Original file line number Diff line number Diff line change 11import { assert } from "@effect/vitest" ;
22import type { ProviderReplayTranscript } from "@t3tools/contracts" ;
3+ import { derivePendingBackgroundWork } from "@t3tools/shared/orchestrationV2PendingBackgroundWork" ;
34
45import type { OrchestratorV2ScenarioResult } from "../../OrchestratorScenario.ts" ;
6+ import { cancelledTurnItemWork } from "../../../RestartBackgroundNote.ts" ;
57import {
68 assertBaseProjection ,
79 assertSemanticProjectionIntegrity ,
@@ -54,6 +56,20 @@ export function assertGrokMonitorOutput(
5456 assert . equal ( monitorUpdates [ tickUpdate ] ?. status , "running" , `${ tick } must show running` ) ;
5557 }
5658
59+ // A persistent monitor keeps running after its run ends. Background work and
60+ // the restart note must then name it a monitor, as they do for Claude's Monitor.
61+ const runningMonitor = monitorUpdates . find ( ( update ) => update . status === "running" ) ;
62+ assert . isDefined ( runningMonitor ) ;
63+ assert . deepEqual (
64+ derivePendingBackgroundWork ( {
65+ latestRun : rootRun ,
66+ providerThreads : [ ] ,
67+ turnItems : [ runningMonitor ] ,
68+ } ) . map ( ( task ) => task . kind ) ,
69+ [ "monitor" ] ,
70+ ) ;
71+ assert . equal ( cancelledTurnItemWork ( runningMonitor ) ?. kind , "monitor" ) ;
72+
5773 const monitorCompletedAt = result . domainEvents . findIndex (
5874 ( event ) =>
5975 event . type === "turn-item.updated" &&
Original file line number Diff line number Diff line change @@ -1477,6 +1477,8 @@ export const OrchestrationV2TurnItem = Schema.Union([
14771477 outputOmitted : Schema . optional ( Schema . Boolean ) ,
14781478 outputIndicatesFailure : Schema . optional ( Schema . Boolean ) ,
14791479 exitCode : Schema . optional ( Schema . Int ) ,
1480+ /** Set when the command is a monitor, so background work lists it as a monitor. */
1481+ monitor : Schema . optional ( Schema . Boolean ) ,
14801482 } ) ,
14811483 Schema . Struct ( {
14821484 ...OrchestrationV2TurnItemBaseFields ,
@@ -2244,6 +2246,8 @@ export const OrchestrationV2TurnItemJson = Schema.Union([
22442246 outputOmitted : Schema . optional ( Schema . Boolean ) ,
22452247 outputIndicatesFailure : Schema . optional ( Schema . Boolean ) ,
22462248 exitCode : Schema . optional ( Schema . Int ) ,
2249+ /** Set when the command is a monitor, so background work lists it as a monitor. */
2250+ monitor : Schema . optional ( Schema . Boolean ) ,
22472251 } ) ,
22482252 Schema . Struct ( {
22492253 ...OrchestrationV2TurnItemJsonBaseFields ,
Original file line number Diff line number Diff line change @@ -3916,6 +3916,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
39163916 ? { }
39173917 : { output : textFromUnknown ( rawOutput ) } ) ,
39183918 ...( exitCode === undefined ? { } : { exitCode } ) ,
3919+ ...( inputVariant === "monitor" ? { monitor : true } : { } ) ,
39193920 } ;
39203921 } else {
39213922 turnItem = {
Original file line number Diff line number Diff line change @@ -132,6 +132,7 @@ type PendingBackgroundWorkTurnItem = {
132132 readonly nativeId : string | null ;
133133 } | null ;
134134 readonly input ?: unknown ;
135+ readonly monitor ?: boolean | undefined ;
135136 readonly prompt ?: string | undefined ;
136137 readonly childThreadId ?: ThreadId | null ;
137138} ;
@@ -190,7 +191,7 @@ function pendingTaskFromTurnItem(
190191 ...( item . childThreadId == null ? { } : { childThreadId : item . childThreadId } ) ,
191192 } ;
192193 case "command_execution" :
193- return { ...named , kind : "command" } ;
194+ return { ...named , kind : item . monitor === true ? "monitor" : "command" } ;
194195 default :
195196 return { ...named , kind : "background_task" } ;
196197 }
You can’t perform that action at this time.
0 commit comments