Conversation
| } | ||
| } | ||
|
|
||
| async flushServerNotifications(sessionId: string): Promise<void> { |
There was a problem hiding this comment.
I'm not sure why do we need a queue and then why we need to flush it instead of handling events?
There was a problem hiding this comment.
Because sendPrompt() must not return until all earlier events have been handled.
|
|
||
| type SessionHandlerState = { | ||
| handler: SessionHandler; | ||
| pending: Promise<void>; |
There was a problem hiding this comment.
Can you clarify why do we need state management to handle notifications instead of calling "handler" when event arrives?
There was a problem hiding this comment.
We need the per-session pending promise because notification handling is async: handleNotification() awaits createUpdateEvent() and session.update(), and file-change events may read files to reconstruct ACP diffs. The stored promise chain preserves event order and lets awaitSessionIdle() wait for all pending ACP updates before prompt completion.
| }, FILE_HEADERS_ONLY); | ||
| } | ||
|
|
||
| function createDiffContentFromParsedPatch( |
There was a problem hiding this comment.
Why we manually create patch lines? Don't we have it already in change?
There was a problem hiding this comment.
To convert the diff to ACP format and return as ACP "diff" content block. It needs oldText/newText
Summary
Why
This makes edit tool calls understandable in the UI and avoids races where a completion update can arrive before the corresponding tool call exists.
Testing
npm test