MCPcopy Create free account
hub / github.com/xerrors/Yuxi / finalizeRunStream

Function finalizeRunStream

web/src/composables/useAgentRunStream.js:171–204  ·  view source on GitHub ↗
(
    threadId,
    runId,
    touchedThreadIds,
    { delay = 200, scroll = false, status = '' } = {}
  )

Source from the content-addressed store, hash-verified

169 }
170
171 const finalizeRunStream = (
172 threadId,
173 runId,
174 touchedThreadIds,
175 { delay = 200, scroll = false, status = '' } = {}
176 ) => {
177 const ts = getThreadState(threadId)
178 if (!ts || ts.activeRunId !== runId) return
179 const isInterrupted =
180 status === RUN_INTERRUPTED_STATUS && hasPendingInterruptInThreads(touchedThreadIds, runId)
181 touchedThreadIds.forEach((id) => streamSmoother?.flushThread(id))
182 ts.isStreaming = false
183 if (isInterrupted) {
184 ts.activeRunId = runId
185 saveActiveRunSnapshot(threadId, runId, ts.runLastSeq)
186 } else {
187 ts.activeRunId = null
188 clearActiveRunSnapshot(threadId)
189 touchedThreadIds.forEach((id) => clearPendingInterruptForRun(id, runId))
190 }
191 ts.lastRetryableJobTry = null
192 ts.replyLoadingVisible = false
193 ts.pendingRequestId = null
194 fetchThreadMessages({ agentId: unref(currentAgentId), threadId, delay }).finally(() => {
195 resetOnGoingConv(threadId)
196 fetchAgentState(unref(currentAgentId), threadId)
197 if (scroll) onScrollToBottom()
198 if (isInterrupted) {
199 notifyInterruptDetected(threadId, runId)
200 } else {
201 notifyTerminalDetected(threadId, runId, touchedThreadIds)
202 }
203 })
204 }
205
206 const preserveInterruptedRun = async (threadId, run, snapshot = null) => {
207 const ts = getThreadState(threadId)

Callers 1

startRunStreamFunction · 0.85

Calls 8

getThreadStateFunction · 0.85
saveActiveRunSnapshotFunction · 0.85
clearActiveRunSnapshotFunction · 0.85
resetOnGoingConvFunction · 0.85
notifyInterruptDetectedFunction · 0.85
notifyTerminalDetectedFunction · 0.85

Tested by

no test coverage detected