| 66 | } |
| 67 | |
| 68 | void ClientInterface::sendMessage( |
| 69 | const QString &message, |
| 70 | const QList<QString> &attachments, |
| 71 | const QList<QString> &linkedFiles, |
| 72 | bool useTools, |
| 73 | bool useThinking) |
| 74 | { |
| 75 | if (message.trimmed().isEmpty() && attachments.isEmpty()) { |
| 76 | LOG_MESSAGE("Ignoring empty chat message"); |
| 77 | return; |
| 78 | } |
| 79 | |
| 80 | cancelRequest(); |
| 81 | m_accumulatedResponses.clear(); |
| 82 | |
| 83 | Context::ChangesManager::instance().archiveAllNonArchivedEdits(); |
| 84 | |
| 85 | QList<QString> imageFiles; |
| 86 | QList<QString> textFiles; |
| 87 | |
| 88 | for (const QString &filePath : attachments) { |
| 89 | if (isImageFile(filePath)) { |
| 90 | imageFiles.append(filePath); |
| 91 | } else { |
| 92 | textFiles.append(filePath); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | QList<Context::ContentFile> storedAttachments; |
| 97 | if (!textFiles.isEmpty() && !m_chatFilePath.isEmpty()) { |
| 98 | auto attachFiles = m_contextManager->getContentFiles(textFiles); |
| 99 | for (const auto &file : attachFiles) { |
| 100 | QString storedPath; |
| 101 | if (ChatSerializer::saveContentToStorage( |
| 102 | m_chatFilePath, file.filename, file.content.toUtf8().toBase64(), storedPath)) { |
| 103 | Context::ContentFile storedFile; |
| 104 | storedFile.filename = file.filename; |
| 105 | storedFile.content = storedPath; |
| 106 | storedAttachments.append(storedFile); |
| 107 | LOG_MESSAGE(QString("Stored text file %1 as %2").arg(file.filename, storedPath)); |
| 108 | } |
| 109 | } |
| 110 | } else if (!textFiles.isEmpty()) { |
| 111 | LOG_MESSAGE(QString("Warning: Chat file path not set, cannot save %1 text file(s)") |
| 112 | .arg(textFiles.size())); |
| 113 | } |
| 114 | |
| 115 | QList<ChatModel::ImageAttachment> imageAttachments; |
| 116 | if (!imageFiles.isEmpty() && !m_chatFilePath.isEmpty()) { |
| 117 | for (const QString &imagePath : imageFiles) { |
| 118 | QString base64Data = encodeImageToBase64(imagePath); |
| 119 | if (base64Data.isEmpty()) { |
| 120 | continue; |
| 121 | } |
| 122 | |
| 123 | QString storedPath; |
| 124 | QFileInfo fileInfo(imagePath); |
| 125 | if (ChatSerializer::saveContentToStorage( |
nothing calls this directly
no test coverage detected