| 197 | } |
| 198 | |
| 199 | QString TodoTool::completeTodos(const QString &sessionId, const QList<int> &todoIds) |
| 200 | { |
| 201 | QMutexLocker locker(&m_mutex); |
| 202 | |
| 203 | if (!m_sessionTodos.contains(sessionId)) { |
| 204 | throw LLMQore::ToolRuntimeError(tr("Error: No todos found in this session")); |
| 205 | } |
| 206 | |
| 207 | auto &todos = m_sessionTodos[sessionId]; |
| 208 | int completedCount = 0; |
| 209 | int alreadyCompletedCount = 0; |
| 210 | QStringList notFound; |
| 211 | |
| 212 | for (const int todoId : todoIds) { |
| 213 | if (!todos.contains(todoId)) { |
| 214 | notFound.append(QString("#%1").arg(todoId)); |
| 215 | continue; |
| 216 | } |
| 217 | |
| 218 | TodoItem &item = todos[todoId]; |
| 219 | if (item.completed) { |
| 220 | alreadyCompletedCount++; |
| 221 | } else { |
| 222 | item.completed = true; |
| 223 | completedCount++; |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | QStringList messages; |
| 228 | if (completedCount > 0) { |
| 229 | messages.append((completedCount == 1) ? tr("✓ Marked 1 task as completed") |
| 230 | : tr("✓ Marked %1 tasks as completed") |
| 231 | .arg(completedCount)); |
| 232 | } |
| 233 | |
| 234 | if (alreadyCompletedCount > 0) { |
| 235 | messages.append(tr("⚠ %1 already completed").arg(alreadyCompletedCount)); |
| 236 | } |
| 237 | |
| 238 | if (!notFound.isEmpty()) { |
| 239 | messages.append(tr("❌ Not found: %1").arg(notFound.join(", "))); |
| 240 | } |
| 241 | |
| 242 | const QString summary = messages.join(", "); |
| 243 | return QString("%1\n\n%2").arg(summary, listRemainingTodosLocked(sessionId)); |
| 244 | } |
| 245 | |
| 246 | QString TodoTool::listTodos(const QString &sessionId) const |
| 247 | { |
nothing calls this directly
no test coverage detected