test("#given a routed prompt just dispatched #when the same child session is prompted again immediately #then promptAsync routing defers instead of enqueueing",async()=>{
// given
constpromptAsync=mock(async()=>({data:"sent"}))
constclient={
session:{
promptAsync,
},
}
constargs={
path:{id:"ses_background_route_hold"},
body:{parts:[{type:"text",text:"continue"}]},
}
// when
constfirst=awaitpromptAsyncInDirectory(
unsafeTestValue(client),
unsafeTestValue(args),
"/workspace/project",
)
constsecond=promptAsyncInDirectory(
unsafeTestValue(client),
unsafeTestValue(args),
"/workspace/project",
)
// then
expect(first).toEqual({data:"sent"})
awaitexpect(second).rejects.toThrow("promptAsync skipped by gate: reserved")
test("#given routed promptAsync reports ambiguous EOF after dispatch #when the background route handles it #then it treats the prompt as accepted",async()=>{
test("#given a background retry prompt just dispatched #when the same child session is prompted again immediately #then retry routing defers instead of enqueueing",async()=>{
// given
constpromptAsync=mock(async()=>undefined)
constclient={
session:{
promptAsync,
},
}
constargs={
path:{id:"ses_background_retry_route_hold"},
body:{parts:[{type:"text",text:"continue"}]},
}
// when
awaitpromptWithRetryInDirectory(
unsafeTestValue(client),
unsafeTestValue(args),
"/workspace/project",
)
constsecond=promptWithRetryInDirectory(
unsafeTestValue(client),
unsafeTestValue(args),
"/workspace/project",
)
// then
awaitexpect(second).rejects.toThrow("promptAsync skipped by gate: reserved")