fix(next): adjusts CLI output for next when the result is a subtask. previously incorrect suggested creating subtasks for the subtask.
This commit is contained in:
@@ -860,8 +860,11 @@ async function displayNextTask(tasksPath) {
|
||||
);
|
||||
}
|
||||
|
||||
// Show subtasks if they exist
|
||||
if (nextTask.subtasks && nextTask.subtasks.length > 0) {
|
||||
// Determine if the nextTask is a subtask
|
||||
const isSubtask = !!nextTask.parentId;
|
||||
|
||||
// Show subtasks if they exist (only for parent tasks)
|
||||
if (!isSubtask && nextTask.subtasks && nextTask.subtasks.length > 0) {
|
||||
console.log(
|
||||
boxen(chalk.white.bold('Subtasks'), {
|
||||
padding: { top: 0, bottom: 0, left: 1, right: 1 },
|
||||
@@ -966,8 +969,10 @@ async function displayNextTask(tasksPath) {
|
||||
});
|
||||
|
||||
console.log(subtaskTable.toString());
|
||||
} else {
|
||||
// Suggest expanding if no subtasks
|
||||
}
|
||||
|
||||
// Suggest expanding if no subtasks (only for parent tasks without subtasks)
|
||||
if (!isSubtask && (!nextTask.subtasks || nextTask.subtasks.length === 0)) {
|
||||
console.log(
|
||||
boxen(
|
||||
chalk.yellow('No subtasks found. Consider breaking down this task:') +
|
||||
@@ -986,22 +991,30 @@ async function displayNextTask(tasksPath) {
|
||||
}
|
||||
|
||||
// Show action suggestions
|
||||
let suggestedActionsContent = chalk.white.bold('Suggested Actions:') + '\n';
|
||||
if (isSubtask) {
|
||||
// Suggested actions for a subtask
|
||||
suggestedActionsContent +=
|
||||
`${chalk.cyan('1.')} Mark as in-progress: ${chalk.yellow(`task-master set-status --id=${nextTask.id} --status=in-progress`)}\n` +
|
||||
`${chalk.cyan('2.')} Mark as done when completed: ${chalk.yellow(`task-master set-status --id=${nextTask.id} --status=done`)}\n` +
|
||||
`${chalk.cyan('3.')} View parent task: ${chalk.yellow(`task-master show --id=${nextTask.parentId}`)}`;
|
||||
} else {
|
||||
// Suggested actions for a parent task
|
||||
suggestedActionsContent +=
|
||||
`${chalk.cyan('1.')} Mark as in-progress: ${chalk.yellow(`task-master set-status --id=${nextTask.id} --status=in-progress`)}\n` +
|
||||
`${chalk.cyan('2.')} Mark as done when completed: ${chalk.yellow(`task-master set-status --id=${nextTask.id} --status=done`)}\n` +
|
||||
(nextTask.subtasks && nextTask.subtasks.length > 0
|
||||
? `${chalk.cyan('3.')} Update subtask status: ${chalk.yellow(`task-master set-status --id=${nextTask.id}.1 --status=done`)}` // Example: first subtask
|
||||
: `${chalk.cyan('3.')} Break down into subtasks: ${chalk.yellow(`task-master expand --id=${nextTask.id}`)}`);
|
||||
}
|
||||
|
||||
console.log(
|
||||
boxen(
|
||||
chalk.white.bold('Suggested Actions:') +
|
||||
'\n' +
|
||||
`${chalk.cyan('1.')} Mark as in-progress: ${chalk.yellow(`task-master set-status --id=${nextTask.id} --status=in-progress`)}\n` +
|
||||
`${chalk.cyan('2.')} Mark as done when completed: ${chalk.yellow(`task-master set-status --id=${nextTask.id} --status=done`)}\n` +
|
||||
(nextTask.subtasks && nextTask.subtasks.length > 0
|
||||
? `${chalk.cyan('3.')} Update subtask status: ${chalk.yellow(`task-master set-status --id=${nextTask.id}.1 --status=done`)}`
|
||||
: `${chalk.cyan('3.')} Break down into subtasks: ${chalk.yellow(`task-master expand --id=${nextTask.id}`)}`),
|
||||
{
|
||||
padding: { top: 0, bottom: 0, left: 1, right: 1 },
|
||||
borderColor: 'green',
|
||||
borderStyle: 'round',
|
||||
margin: { top: 1 }
|
||||
}
|
||||
)
|
||||
boxen(suggestedActionsContent, {
|
||||
padding: { top: 0, bottom: 0, left: 1, right: 1 },
|
||||
borderColor: 'green',
|
||||
borderStyle: 'round',
|
||||
margin: { top: 1 }
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user