fix: enhance comment retrieval logic in getTaskComment function

- Updated the getTaskComment function to first attempt an exact match for comment IDs, followed by a prefix match for improved flexibility in retrieving comments with short IDs.
- This change ensures better handling of comment lookups, enhancing user experience when accessing task comments.
This commit is contained in:
iliya 2026-03-20 13:46:56 +02:00
parent b41cf9fad2
commit 6469b17736

View file

@ -172,7 +172,11 @@ function getTaskComment(context, taskId, commentId) {
}
const task = taskStore.readTask(context.paths, taskId, { includeDeleted: true });
const comments = Array.isArray(task.comments) ? task.comments : [];
const comment = comments.find((c) => c && c.id === normalizedCommentId);
// Exact match first, then prefix match (allows short IDs like first 8 chars)
const comment =
comments.find((c) => c && c.id === normalizedCommentId) ||
comments.find((c) => c && typeof c.id === 'string' && c.id.startsWith(normalizedCommentId));
if (!comment) {
throw new Error(`Comment ${normalizedCommentId} not found on task #${task.displayId || task.id}`);
}