@@ -5,8 +5,11 @@ import path from "node:path";
55import { afterEach , beforeEach , describe , expect , it , vi } from "vitest" ;
66
77vi . mock ( "../agents/pi-embedded.js" , ( ) => ( {
8+ abortEmbeddedPiRun : vi . fn ( ) . mockReturnValue ( false ) ,
89 runEmbeddedPiAgent : vi . fn ( ) ,
910 queueEmbeddedPiMessage : vi . fn ( ) . mockReturnValue ( false ) ,
11+ resolveEmbeddedSessionLane : ( key : string ) =>
12+ `session:${ key . trim ( ) || "main" } ` ,
1013} ) ) ;
1114vi . mock ( "../agents/model-catalog.js" , ( ) => ( {
1215 loadModelCatalog : vi . fn ( ) ,
@@ -20,6 +23,7 @@ import {
2023 saveSessionStore ,
2124} from "../config/sessions.js" ;
2225import {
26+ extractQueueDirective ,
2327 extractThinkDirective ,
2428 extractVerboseDirective ,
2529 getReplyFromConfig ,
@@ -83,6 +87,13 @@ describe("directive parsing", () => {
8387 expect ( res . thinkLevel ) . toBe ( "high" ) ;
8488 } ) ;
8589
90+ it ( "matches queue directive" , ( ) => {
91+ const res = extractQueueDirective ( "please /queue interrupt now" ) ;
92+ expect ( res . hasDirective ) . toBe ( true ) ;
93+ expect ( res . queueMode ) . toBe ( "interrupt" ) ;
94+ expect ( res . cleaned ) . toBe ( "please now" ) ;
95+ } ) ;
96+
8697 it ( "applies inline think and still runs agent content" , async ( ) => {
8798 await withTempHome ( async ( home ) => {
8899 vi . mocked ( runEmbeddedPiAgent ) . mockResolvedValue ( {
@@ -142,6 +153,33 @@ describe("directive parsing", () => {
142153 } ) ;
143154 } ) ;
144155
156+ it ( "acks queue directive and persists override" , async ( ) => {
157+ await withTempHome ( async ( home ) => {
158+ vi . mocked ( runEmbeddedPiAgent ) . mockReset ( ) ;
159+ const storePath = path . join ( home , "sessions.json" ) ;
160+
161+ const res = await getReplyFromConfig (
162+ { Body : "/queue interrupt" , From : "+1222" , To : "+1222" } ,
163+ { } ,
164+ {
165+ agent : {
166+ model : "anthropic/claude-opus-4-5" ,
167+ workspace : path . join ( home , "clawd" ) ,
168+ } ,
169+ routing : { allowFrom : [ "*" ] } ,
170+ session : { store : storePath } ,
171+ } ,
172+ ) ;
173+
174+ const text = Array . isArray ( res ) ? res [ 0 ] ?. text : res ?. text ;
175+ expect ( text ) . toMatch ( / ^ ⚙ ️ Q u e u e m o d e s e t t o i n t e r r u p t \. / ) ;
176+ const store = loadSessionStore ( storePath ) ;
177+ const entry = Object . values ( store ) [ 0 ] ;
178+ expect ( entry ?. queueMode ) . toBe ( "interrupt" ) ;
179+ expect ( runEmbeddedPiAgent ) . not . toHaveBeenCalled ( ) ;
180+ } ) ;
181+ } ) ;
182+
145183 it ( "updates tool verbose during an in-flight run (toggle on)" , async ( ) => {
146184 await withTempHome ( async ( home ) => {
147185 const storePath = path . join ( home , "sessions.json" ) ;
0 commit comments