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:
parent
b41cf9fad2
commit
6469b17736
1 changed files with 5 additions and 1 deletions
|
|
@ -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}`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue