* @brief Aborts the in-flight reply and cancels any pending confirmations. */
| 204 | * @brief Aborts the in-flight reply and cancels any pending confirmations. |
| 205 | */ |
| 206 | void AI::Conversation::cancel() |
| 207 | { |
| 208 | m_cancelled = true; |
| 209 | m_streamFlushTimer->stop(); |
| 210 | m_streamDirty = false; |
| 211 | if (m_reply) |
| 212 | m_reply->abort(); |
| 213 | |
| 214 | if (!m_awaitingConfirm.isEmpty()) { |
| 215 | for (auto it = m_awaitingConfirm.constBegin(); it != m_awaitingConfirm.constEnd(); ++it) |
| 216 | updateToolCallCard(it.key(), CallStatus::Denied); |
| 217 | |
| 218 | m_awaitingConfirm.clear(); |
| 219 | setAwaitingConfirmation(false); |
| 220 | } |
| 221 | |
| 222 | m_pendingThinkingBlocks = QJsonArray(); |
| 223 | m_pendingToolUseBlocks = QJsonArray(); |
| 224 | m_pendingToolResultBlocks = QJsonArray(); |
| 225 | m_outstandingToolResults = 0; |
| 226 | |
| 227 | setBusy(false); |
| 228 | } |
| 229 | |
| 230 | /** |
| 231 | * @brief Approves a pending Confirm-tagged tool call by id. |