MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / loadChat

Method loadChat

app/src/AI/ChatStore.cpp:160–177  ·  view source on GitHub ↗

* @brief Reads one chat's snapshot, or an empty object when missing/corrupt. */

Source from the content-addressed store, hash-verified

158 * @brief Reads one chat's snapshot, or an empty object when missing/corrupt.
159 */
160QJsonObject AI::ChatStore::loadChat(const QString& id) const
161{
162 QFile f(chatPath(id));
163 if (!f.exists() || !f.open(QIODevice::ReadOnly))
164 return {};
165
166 const auto bytes = f.readAll();
167 f.close();
168
169 QJsonParseError err;
170 const auto doc = QJsonDocument::fromJson(bytes, &err);
171 if (err.error != QJsonParseError::NoError || !doc.isObject()) {
172 qCWarning(serialStudioAI) << "ChatStore: invalid chat file" << id << err.errorString();
173 return {};
174 }
175
176 return doc.object();
177}
178
179/**
180 * @brief Writes a chat's snapshot and refreshes its index metadata.

Callers 1

loadActiveSnapshotMethod · 0.80

Calls 5

fromJsonFunction · 0.85
existsMethod · 0.80
errorStringMethod · 0.80
openMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected