MCPcopy Create free account
hub / github.com/Palm1r/QodeAssist / sendMessage

Method sendMessage

ChatView/ClientInterface.cpp:68–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68void 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(

Callers

nothing calls this directly

Calls 15

appendMethod · 0.80
getContentFilesMethod · 0.80
toUtf8Method · 0.80
sizeMethod · 0.80
addMessageMethod · 0.80
getProviderByNameMethod · 0.80
systemPromptMethod · 0.80
configureMethod · 0.80
alwaysOnBodiesMethod · 0.80
catalogTextMethod · 0.80
findByNameMethod · 0.80

Tested by

no test coverage detected