* @brief Creates an idle conversation; provider and dispatcher are wired later. */
| 47 | * @brief Creates an idle conversation; provider and dispatcher are wired later. |
| 48 | */ |
| 49 | AI::Conversation::Conversation(QObject* parent) |
| 50 | : QObject(parent) |
| 51 | , m_provider(nullptr) |
| 52 | , m_dispatcher(nullptr) |
| 53 | , m_reply(nullptr) |
| 54 | , m_assistantIndex(-1) |
| 55 | , m_thinkingIsSynthetic(false) |
| 56 | , m_outstandingToolResults(0) |
| 57 | , m_toolCallCount(0) |
| 58 | , m_retryCount(0) |
| 59 | , m_cancelled(false) |
| 60 | , m_summaryForced(false) |
| 61 | , m_busy(false) |
| 62 | , m_lastAwaitingFlag(false) |
| 63 | , m_streamFlushTimer(new QTimer(this)) |
| 64 | , m_streamDirty(false) |
| 65 | , m_autoSaveTimer(new QTimer(this)) |
| 66 | { |
| 67 | m_streamFlushTimer->setInterval(33); |
| 68 | m_streamFlushTimer->setSingleShot(false); |
| 69 | connect(m_streamFlushTimer, &QTimer::timeout, this, &Conversation::flushPendingStreamUpdate); |
| 70 | |
| 71 | m_autoSaveTimer->setInterval(800); |
| 72 | m_autoSaveTimer->setSingleShot(true); |
| 73 | connect(m_autoSaveTimer, &QTimer::timeout, this, [] { |
| 74 | auto& project = DataModel::ProjectModel::instance(); |
| 75 | if (!project.modified()) |
| 76 | return; |
| 77 | |
| 78 | if (project.jsonFilePath().isEmpty()) |
| 79 | return; |
| 80 | |
| 81 | project.setSuppressMessageBoxes(true); |
| 82 | const bool ok = project.saveJsonFile(false); |
| 83 | project.setSuppressMessageBoxes(false); |
| 84 | if (!ok) |
| 85 | qCWarning(serialStudioAI) << "AI auto-save failed"; |
| 86 | else |
| 87 | qCDebug(serialStudioAI) << "AI auto-save:" << project.jsonFilePath(); |
| 88 | }); |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * @brief Aborts any in-flight reply and frees owned resources. |
nothing calls this directly
no test coverage detected