(
threadId,
runId,
touchedThreadIds,
{ delay = 200, scroll = false, status = '' } = {}
)
| 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) |
no test coverage detected