* @brief Deletes a chat; if it was active, falls back to the newest remaining (or a new) chat. */
| 570 | * @brief Deletes a chat; if it was active, falls back to the newest remaining (or a new) chat. |
| 571 | */ |
| 572 | void AI::Assistant::deleteChat(const QString& id) |
| 573 | { |
| 574 | if (!m_chats.contains(id)) |
| 575 | return; |
| 576 | |
| 577 | const bool wasActive = (id == m_activeChatId); |
| 578 | m_chats.removeChat(id); |
| 579 | |
| 580 | if (wasActive) { |
| 581 | const auto rows = m_chats.list(); |
| 582 | m_activeChatId = rows.isEmpty() ? m_chats.createChat() |
| 583 | : rows.first().toMap().value(QStringLiteral("id")).toString(); |
| 584 | m_chats.setLastActiveId(m_activeChatId); |
| 585 | loadActiveSnapshot(); |
| 586 | Q_EMIT activeChatChanged(); |
| 587 | } |
| 588 | |
| 589 | Q_EMIT chatListChanged(); |
| 590 | } |
| 591 | |
| 592 | /** |
| 593 | * @brief Sets a user-chosen title on a chat. |
nothing calls this directly
no test coverage detected