1932
});
1933
}
1935
>
// Plan section 3.8. The sequencer scope holds across BOTH materialize
1936
>
// and `session.send` so two concurrent first-message calls on the
1937
>
// same session collapse into one materialize plus two ordered
1938
>
// sends. A `disposeSession` racing a first send reaches its own
1939
>
// dispose-sequencer eventually but the in-flight materialize
1940
>
// completes first.
1941
>
return this._sessionSequencer.queue(context.sessionId, async () => {
1942
>
const existing = this._getChatContext(chat).target;
1943
>
let session: ClaudeAgentSession;
1944
>
if (existing?.isPipelineReady) {
1945
session = existing;
1947
session = await this._materializeProvisional(context.sessionId, workingDirectory);
1948
} else {