@@ -17,7 +17,6 @@ import {
1717 type ChatCommandResetOptions ,
1818} from "./chat-commands.ts" ;
1919import { loadChatHistory , type ChatHistoryResult } from "./chat-history.ts" ;
20- import { chatOutboxOwner } from "./chat-outbox-owner.ts" ;
2120import {
2221 consumeChatOutboxRetry ,
2322 retryableGatewayDelayMs ,
@@ -98,8 +97,6 @@ type StoredChatOutboxDrainLane = {
9897type StoredChatOutboxClientState = {
9998 lanes : Map < string , StoredChatOutboxDrainLane > ;
10099} ;
101- const STORED_OUTBOX_CONFIRMATION_GRACE_MS = 5_000 ;
102- const STORED_OUTBOX_RETRY_DEFAULT_MS = 500 ;
103100export const UNCONFIRMED_CHAT_SEND_ERROR =
104101 "Reconnected before delivery was confirmed. Check the conversation — retry only if your message didn't arrive." ;
105102const UNCERTAIN_CLEAR_SUCCESSOR_ERROR =
@@ -152,10 +149,6 @@ function sameQueuedDeliveryVersion(left: ChatQueueItem, right: ChatQueueItem): b
152149 ) ;
153150}
154151
155- function queuedDeliveryVersion ( item : ChatQueueItem ) : string {
156- return `${ item . id } \u0000${ item . sendRunId ?? "" } \u0000${ item . sendAttempts ?? 0 } ` ;
157- }
158-
159152function sessionRunProvesQueuedDelivery (
160153 sessionInfo : ChatHistoryResult [ "sessionInfo" ] ,
161154 item : ChatQueueItem ,
@@ -166,7 +159,6 @@ function sessionRunProvesQueuedDelivery(
166159 sessionInfo ?. lastRunId === item . sendRunId ) ,
167160 ) ;
168161}
169-
170162async function readCurrentStoredChatHistory (
171163 host : ChatHost ,
172164 outbox : StoredChatOutbox ,
@@ -297,24 +289,19 @@ async function reconcileStoredChatOutboxHead(
297289 return "blocked" ;
298290 }
299291 }
300- const outboxOwner = chatOutboxOwner ( host ) ;
301- const clearConfirmationGrace = ( ) => outboxOwner . clearConfirmationGrace ( outbox , item . id ) ;
302292 const historyArgs = [ host , outbox , item , client , connectionEpoch , dependencies ] as const ;
303293 const history = await readCurrentStoredChatHistory ( ...historyArgs ) ;
304294 // Keyed unknown sends reach history only for exact proof; absence stays blocked.
305295 if ( history === "blocked" || history === "continue" || item . sendState === "unconfirmed" ) {
306- clearConfirmationGrace ( ) ;
307296 return history === "continue" ? "continue" : "blocked" ;
308297 }
309298 if ( visibleSessionMatches ( host , outbox . sessionKey , outbox . agentId ) && isChatBusy ( host ) ) {
310- clearConfirmationGrace ( ) ;
311299 return "blocked" ;
312300 }
313301 if ( ( item . sendAttempts ?? 0 ) > 0 ) {
314302 // History and run metadata are non-atomic; verify idle before parking unknown.
315303 const verifiedHistory = await readCurrentStoredChatHistory ( ...historyArgs ) ;
316304 if ( verifiedHistory === "blocked" || verifiedHistory === "continue" ) {
317- clearConfirmationGrace ( ) ;
318305 return verifiedHistory ;
319306 }
320307 const liveSendCurrent = anyChatOutboxPaneMatches ( host , ( pane ) => {
@@ -325,27 +312,9 @@ async function reconcileStoredChatOutboxHead(
325312 ) ;
326313 } ) ;
327314 if ( liveSendCurrent ) {
328- // Start the bound only after idle is verified; a valid run can outlive the send request.
329- const now = Date . now ( ) ;
330- const deadlineMs = outboxOwner . confirmationDeadline (
331- outbox ,
332- item . id ,
333- queuedDeliveryVersion ( item ) ,
334- now ,
335- STORED_OUTBOX_CONFIRMATION_GRACE_MS ,
336- ) ;
337- if ( deadlineMs !== null && now < deadlineMs ) {
338- scheduleStoredChatOutboxRetry (
339- host ,
340- outbox ,
341- Math . min ( STORED_OUTBOX_RETRY_DEFAULT_MS , deadlineMs - now ) ,
342- dependencies ,
343- false ,
344- ) ;
345- return "blocked" ;
346- }
315+ // Elapsed time cannot turn a current-connection send into reconnect uncertainty.
316+ return "blocked" ;
347317 }
348- clearConfirmationGrace ( ) ;
349318 const parked = updateQueuedMessageForSession ( host , outbox . sessionKey , item . id , ( entry ) => ( {
350319 ...entry ,
351320 sendError : UNCONFIRMED_CHAT_SEND_ERROR ,
0 commit comments