@devries-cameron20 / t3code-1 / commits / f0495f7417
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(provider-core): background work notices no longer say every task failed when one did (#32407)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Felix Laga committed Nov 15, 2026 at 14:22 UTC f0495f741757c0103ed6995621111aec231a526b
2 files changed +61 -15
packages/provider-core/src/server/notification.test.ts
+22
@@ -60,6 +60,16 @@ describe("backgroundWorkNotification", () => {
60 outcome: "cancelled",
61 summary: 'Subagent "Agent B" and command "Sleep 60 seconds" were stopped',
62 });
63 + assert.deepInclude(
64 + backgroundWorkNotification([
65 + { kind: "command", label: "npm test", outcome: "completed", exitCode: 0 },
66 + { kind: "command", label: "npm run lint", outcome: "failed", exitCode: 1 },
67 + ]),
68 + {
69 + outcome: "failed",
70 + summary: 'Command "npm test" finished (exit 0) and command "npm run lint" failed (exit 1)',
71 + },
72 + );
73 });
74
75 it("counts work it cannot list", () => {
@@ -73,6 +83,18 @@ describe("backgroundWorkNotification", () => {
83 outcome: "completed",
84 summary: "4 subagents finished",
85 });
86 + assert.deepEqual(
87 + backgroundWorkNotification(
88 + reports.map((report, index) =>
89 + index === 0 ? { ...report, outcome: "failed" as const } : report,
90 + ),
91 + ),
92 + {
93 + source: { kind: "subagent" },
94 + outcome: "failed",
95 + summary: "1 subagent failed and 3 finished",
96 + },
97 + );
98 });
99 });
100
packages/provider-core/src/server/notification.ts
+39 -15
@@ -71,11 +71,26 @@ function exitSuffix(report: BackgroundWorkReport): string {
71 : "";
72 }
73
74 -function namedReport(report: BackgroundWorkReport, capitalize: boolean): string {
74 +function namedReport(report: BackgroundWorkReport, capitalize: boolean, verb?: string): string {
75 const noun = KIND_NOUN[report.kind][0];
76 const label = reportLabel(report.label);
77 const named = `${capitalize ? noun : noun.toLowerCase()}${label === undefined ? "" : ` "${label}"`}`;
78 - return `${named}${exitSuffix(report)}`;
78 + return `${named}${verb === undefined ? "" : ` ${verb}`}${exitSuffix(report)}`;
79 +}
80 +
81 +const OUTCOME_GROUPS = ["failed", "cancelled", "updated", "completed"] as const;
82 +
83 +function groupVerb(group: (typeof OUTCOME_GROUPS)[number], count: number): string {
84 + switch (group) {
85 + case "failed":
86 + return "failed";
87 + case "cancelled":
88 + return count === 1 ? "was stopped" : "were stopped";
89 + case "updated":
90 + return "updated";
91 + case "completed":
92 + return "finished";
93 + }
94 }
95
96 function joinNames(names: ReadonlyArray<string>): string {
@@ -85,7 +100,6 @@ function joinNames(names: ReadonlyArray<string>): string {
100
101 function reportsSummary(
102 reports: readonly [BackgroundWorkReport, ...ReadonlyArray<BackgroundWorkReport>],
88 - outcome: NotificationOutcome,
103 ): string {
104 const [first] = reports;
105 if (reports.length === 1) {
@@ -93,20 +107,30 @@ function reportsSummary(
107 const noun = KIND_NOUN[first.kind][0];
108 return `${noun}${label === undefined ? "" : ` "${label}"`} ${outcomeVerb(first.kind, first.outcome)}${exitSuffix(first)}`;
109 }
96 - const verb =
97 - outcome === "failed"
98 - ? "failed"
99 - : outcome === "cancelled"
100 - ? "were stopped"
101 - : outcome === "updated"
102 - ? "updated"
103 - : "finished";
110 + const groups = OUTCOME_GROUPS.flatMap((group) => {
111 + const count = reports.filter(
112 + (report) => (report.outcome === "unknown" ? "completed" : report.outcome) === group,
113 + ).length;
114 + return count === 0 ? [] : [{ group, count }];
115 + });
116 if (reports.length > 3 || reports.every((report) => reportLabel(report.label) === undefined)) {
117 const kinds = new Set(reports.map((report) => report.kind));
106 - const noun = kinds.size === 1 ? KIND_NOUN[first.kind][1] : "background tasks";
107 - return `${reports.length} ${noun} ${verb}`;
118 + const [noun, nouns] = kinds.size === 1 ? KIND_NOUN[first.kind] : KIND_NOUN.background_task;
119 + return joinNames(
120 + groups.map(
121 + ({ group, count }, index) =>
122 + `${count}${index === 0 ? ` ${count === 1 ? noun.toLowerCase() : nouns}` : ""} ${groupVerb(group, count)}`,
123 + ),
124 + );
125 + }
126 + if (groups.length > 1) {
127 + return joinNames(
128 + reports.map((report, index) =>
129 + namedReport(report, index === 0, outcomeVerb(report.kind, report.outcome)),
130 + ),
131 + );
132 }
109 - return `${joinNames(reports.map((report, index) => namedReport(report, index === 0)))} ${verb}`;
133 + return `${joinNames(reports.map((report, index) => namedReport(report, index === 0)))} ${groupVerb(groups[0]!.group, reports.length)}`;
134 }
135
136 function reportsSource(
@@ -141,7 +165,7 @@ export function backgroundWorkNotification(
165 return {
166 source: reportsSource([first, ...rest]),
167 outcome,
144 - summary: reportsSummary([first, ...rest], outcome),
168 + summary: reportsSummary([first, ...rest]),
169 };
170 }
171