Skip to content

fix(core): tui summary should handle in progress tasks properly #30905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ export function getTuiTerminalSummaryLifeCycle({
let totalSuccessfulTasks = 0;
let totalFailedTasks = 0;
let totalCompletedTasks = 0;
let totalStoppedTasks = 0;
let timeTakenText: string;

const failedTasks = new Set<string>();
const inProgressTasks = new Set<string>();
const stoppedTasks = new Set<string>();

const tasksToTerminalOutputs: Record<
string,
{ terminalOutput: string; taskStatus: TaskStatus }
Expand All @@ -65,7 +66,8 @@ export function getTuiTerminalSummaryLifeCycle({

lifeCycle.setTaskStatus = (taskId, taskStatus) => {
if (taskStatus === NativeTaskStatus.Stopped) {
totalStoppedTasks++;
stoppedTasks.add(taskId);
inProgressTasks.delete(taskId);
}
};

Expand Down Expand Up @@ -118,7 +120,7 @@ export function getTuiTerminalSummaryLifeCycle({

const printRunOneSummary = () => {
let lines: string[] = [];
const failure = totalSuccessfulTasks + totalStoppedTasks !== totalTasks;
const failure = totalSuccessfulTasks + stoppedTasks.size !== totalTasks;

// Prints task outputs in the order they were completed
// above the summary, since run-one should print all task results.
Expand Down Expand Up @@ -165,15 +167,15 @@ export function getTuiTerminalSummaryLifeCycle({
);
}
lines = [output.colors.green(lines.join(EOL))];
} else if (totalCompletedTasks + totalStoppedTasks === totalTasks) {
} else if (totalCompletedTasks + stoppedTasks.size === totalTasks) {
let text = `Ran target ${output.bold(
targets[0]
)} for project ${output.bold(initiatingProject)}`;
if (tasks.length > 1) {
text += ` and ${output.bold(tasks.length - 1)} task(s) they depend on`;
}

const taskOverridesLines = [];
const taskOverridesLines: string[] = [];
if (Object.keys(overrides).length > 0) {
taskOverridesLines.push('');
taskOverridesLines.push(
Expand All @@ -189,23 +191,25 @@ export function getTuiTerminalSummaryLifeCycle({
const viewLogs = viewLogsFooterRows(totalFailedTasks);

lines = [
output.colors.red([
output.applyNxPrefix(
'red',
output.colors.red(text) + output.dim(` (${timeTakenText})`)
),
...taskOverridesLines,
'',
`${LEFT_PAD}${output.colors.red(
figures.cross
)}${SPACER}${totalFailedTasks}${`/${totalCompletedTasks}`} failed`,
`${LEFT_PAD}${output.dim(
figures.tick
)}${SPACER}${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output.dim(
`[${totalCachedTasks} read from cache]`
)}`,
...viewLogs,
]),
output.colors.red(
[
output.applyNxPrefix(
'red',
output.colors.red(text) + output.dim(` (${timeTakenText})`)
),
...taskOverridesLines,
'',
`${LEFT_PAD}${output.colors.red(
figures.cross
)}${SPACER}${totalFailedTasks}${`/${totalCompletedTasks}`} failed`,
`${LEFT_PAD}${output.dim(
figures.tick
)}${SPACER}${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output.dim(
`[${totalCachedTasks} read from cache]`
)}`,
...viewLogs,
].join(EOL)
),
];
} else {
lines = [
Expand All @@ -231,7 +235,7 @@ export function getTuiTerminalSummaryLifeCycle({
console.log('');

const lines: string[] = [];
const failure = totalSuccessfulTasks + totalStoppedTasks !== totalTasks;
const failure = totalSuccessfulTasks + stoppedTasks.size !== totalTasks;

for (const taskId of taskIdsInOrderOfCompletion) {
const { terminalOutput, taskStatus } = tasksToTerminalOutputs[taskId];
Expand All @@ -253,7 +257,7 @@ export function getTuiTerminalSummaryLifeCycle({

lines.push(...output.getVerticalSeparatorLines(failure ? 'red' : 'green'));

if (totalSuccessfulTasks + totalStoppedTasks === totalTasks) {
if (totalSuccessfulTasks + stoppedTasks.size === totalTasks) {
const successSummaryRows = [];
const text = `Successfully ran ${formatTargetsAndProjects(
projectNames,
Expand Down Expand Up @@ -294,7 +298,7 @@ export function getTuiTerminalSummaryLifeCycle({
const text = `${
inProgressTasks.size ? 'Cancelled while running' : 'Ran'
} ${formatTargetsAndProjects(projectNames, targets, tasks)}`;
const taskOverridesRows = [];
const taskOverridesRows: string[] = [];
if (Object.keys(overrides).length > 0) {
taskOverridesRows.push('');
taskOverridesRows.push(
Expand All @@ -312,7 +316,7 @@ export function getTuiTerminalSummaryLifeCycle({
0,
numFailedToPrint
);
const failureSummaryRows = [
const failureSummaryRows: string[] = [
output.applyNxPrefix(
'red',
output.colors.red(text) + output.dim.white(` (${timeTakenText})`)
Expand Down
Loading