@@ -627,6 +627,12 @@ const make = Effect.gen(function* () {
627627 } ) ;
628628 } ) ;
629629
630+ /**
631+ * Start or reuse the provider session for a thread.
632+ * Rejects or defers replacement when live background work would lose the
633+ * current permission callback or Claude child tasks; reports whether the
634+ * requested model selection was applied to the live process.
635+ */
630636 const ensureSessionForThread = Effect . fn ( "ensureSessionForThread" ) ( function * (
631637 threadId : ThreadId ,
632638 createdAt : string ,
@@ -711,6 +717,7 @@ const make = Effect.gen(function* () {
711717 providerRuntimeMode : activeSession ?. runtimeMode ,
712718 sessionRuntimeMode : activeThreadSession ?. runtimeMode ,
713719 } ) ;
720+ /** Fail the turn instead of swapping runtime mode onto a still-live session. */
714721 const rejectRuntimeModeReplacementWhileLive = Effect . fnUntraced ( function * ( ) {
715722 yield * Effect . logWarning (
716723 "provider command reactor rejecting runtime-mode replacement while background work is live" ,
@@ -950,6 +957,10 @@ const make = Effect.gen(function* () {
950957 return { threadId : startedSession . threadId , appliedRequestedSelection : true } ;
951958 } ) ;
952959
960+ /**
961+ * Ensure a live session, then build the provider sendTurn request.
962+ * Caches the turn's model selection only when ensureSession applied it.
963+ */
953964 const buildSendTurnRequestForThread = Effect . fnUntraced ( function * ( input : {
954965 readonly threadId : ThreadId ;
955966 readonly messageText : string ;
0 commit comments