| 426 | } |
| 427 | |
| 428 | bool ChatRootView::deferSendForAutoCompress( |
| 429 | const QString &message, |
| 430 | const QStringList &attachments, |
| 431 | const QStringList &linkedFiles, |
| 432 | bool useToolsArg, |
| 433 | bool useThinkingArg) |
| 434 | { |
| 435 | auto &settings = Settings::chatAssistantSettings(); |
| 436 | if (!settings.autoCompress()) |
| 437 | return false; |
| 438 | |
| 439 | const int threshold = settings.autoCompressThreshold(); |
| 440 | const int inputTokens = m_tokenCounter->inputTokens(); |
| 441 | if (inputTokens < threshold) |
| 442 | return false; |
| 443 | |
| 444 | if (m_recentFilePath.isEmpty()) { |
| 445 | QString filePath = getAutosaveFilePath(message, attachments); |
| 446 | if (filePath.isEmpty()) |
| 447 | return false; |
| 448 | setRecentFilePath(filePath); |
| 449 | LOG_MESSAGE(QString("Set chat file path for new chat (auto-compress): %1").arg(filePath)); |
| 450 | } |
| 451 | |
| 452 | if (m_chatCompressor->isCompressing() || m_pendingSend.active) |
| 453 | return false; |
| 454 | |
| 455 | LOG_MESSAGE(QString("Auto-compress preempt: estimated next=%1 ≥ threshold=%2; deferring send") |
| 456 | .arg(inputTokens) |
| 457 | .arg(threshold)); |
| 458 | |
| 459 | m_pendingSend = {message, attachments, linkedFiles, useToolsArg, useThinkingArg, true}; |
| 460 | compressCurrentChat(); |
| 461 | return true; |
| 462 | } |
| 463 | |
| 464 | void ChatRootView::dispatchSend( |
| 465 | const QString &message, |
nothing calls this directly
no test coverage detected