@@ -4541,6 +4541,47 @@ describe("handleSendChat", () => {
45414541 expect ( replacementRequest ) . not . toHaveBeenCalled ( ) ;
45424542 } ) ;
45434543
4544+ it ( "retries an explicitly approved unconfirmed reset with the same run id" , async ( ) => {
4545+ const runId = "unconfirmed-reset-run" ;
4546+ const item = {
4547+ ...createQueuedLocalCommand ( "unconfirmed-reset-retry" , "/reset" ) ,
4548+ sendAttempts : 1 ,
4549+ sendError : "Delivery could not be confirmed after reconnect." ,
4550+ sendRequestStartedAtMs : 10 ,
4551+ sendRunId : runId ,
4552+ sendState : "unconfirmed" as const ,
4553+ } ;
4554+ const host = makeHost ( {
4555+ requestHandlers : {
4556+ "chat.send" : ( params : unknown ) => {
4557+ const payload = requireRecord ( params , "retried reset payload" ) ;
4558+ return { runId : payload . idempotencyKey , status : "ok" } ;
4559+ } ,
4560+ } ,
4561+ chatQueue : [ item ] ,
4562+ confirmConversationReset : vi . fn ( async ( ) => true ) ,
4563+ hello : {
4564+ type : "hello-ok" ,
4565+ protocol : 4 ,
4566+ auth : { role : "operator" , scopes : [ "operator.admin" ] } ,
4567+ features : { methods : [ "chat.send" ] } ,
4568+ } ,
4569+ } ) ;
4570+ admitHostQueueItems ( host ) ;
4571+
4572+ await retryQueuedChatMessage ( host , item . id ) ;
4573+
4574+ expect ( host . confirmConversationReset ) . toHaveBeenCalledOnce ( ) ;
4575+ expect ( host . request ) . toHaveBeenCalledWith (
4576+ "chat.send" ,
4577+ expect . objectContaining ( {
4578+ idempotencyKey : runId ,
4579+ message : "/reset" ,
4580+ } ) ,
4581+ ) ;
4582+ expect ( listStoredChatOutboxes ( host ) ) . toStrictEqual ( [ ] ) ;
4583+ } ) ;
4584+
45444585 it ( "retires a queued local command without applying its late result after a route switch" , async ( ) => {
45454586 const command = createDeferred < Awaited < ReturnType < ExecuteSlashCommand > > > ( ) ;
45464587 executeSlashCommandMock . mockImplementationOnce ( ( ) => command . promise ) ;
0 commit comments