From deaf4a6ff442a36775de9d500d4fcec5b63522f4 Mon Sep 17 00:00:00 2001 From: Shrey Paharia Date: Wed, 23 Apr 2025 21:11:49 +0530 Subject: [PATCH] fix: added handling for show cli --- scripts/modules/ui.js | 12 ++++++++++++ scripts/modules/utils.js | 16 +++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/scripts/modules/ui.js b/scripts/modules/ui.js index 98a151dc..1525094a 100644 --- a/scripts/modules/ui.js +++ b/scripts/modules/ui.js @@ -1004,6 +1004,12 @@ async function displayTaskById(tasksPath, taskId, complexityReportPath = null) { chalk.cyan.bold('Status:'), getStatusWithColor(task.status || 'pending', true) ], + [ + chalk.cyan.bold('Complexity:'), + task.complexityScore + ? getComplexityWithColor(task.complexityScore) + : chalk.gray('N/A') + ], [ chalk.cyan.bold('Description:'), task.description || 'No description provided.' @@ -1177,6 +1183,12 @@ async function displayTaskById(tasksPath, taskId, complexityReportPath = null) { complexityReport ) // Pass complexityReport ], + [ + chalk.cyan.bold('Complexity:'), + task.complexityScore + ? getComplexityWithColor(task.complexityScore) + : chalk.gray('N/A') + ], [chalk.cyan.bold('Description:'), task.description] ); diff --git a/scripts/modules/utils.js b/scripts/modules/utils.js index 71317993..1098572d 100644 --- a/scripts/modules/utils.js +++ b/scripts/modules/utils.js @@ -281,14 +281,16 @@ function findTaskById(tasks, taskId, complexityReport = null) { if (taskResult && complexityReport) { if (complexityReport && complexityReport.complexityAnalysis) { // For a main task, look for a direct match - if (!taskResult.isSubtask) { - const taskAnalysis = complexityReport.complexityAnalysis.find( - (analysis) => analysis.taskId === taskResult.id - ); + const taskId = taskResult.isSubtask + ? taskResult.parentTask.id + : taskResult.id; - if (taskAnalysis) { - taskResult.complexityScore = taskAnalysis.complexityScore; - } + const taskAnalysis = complexityReport.complexityAnalysis.find( + (analysis) => analysis.taskId === taskId + ); + + if (taskAnalysis) { + taskResult.complexityScore = taskAnalysis.complexityScore; } } }