Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions packages/provider-core/src/server/notification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ describe("backgroundWorkNotification", () => {
.summary,
'Monitor "Three ticks" reported new output',
);
assert.equal(
backgroundWorkNotification([
{ kind: "command", label: `${"a".repeat(78)}😀 and more`, outcome: "completed" },
]).summary,
`Command "${"a".repeat(78)}…" finished`,
);
});

it("names every piece of work that ended together, without opening one of them", () => {
Expand Down
11 changes: 8 additions & 3 deletions packages/provider-core/src/server/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ const LABEL_MAX_LENGTH = 80;
export function reportLabel(label: string | undefined): string | undefined {
const firstLine = label?.trim().split("\n")[0]?.trim();
if (firstLine === undefined || firstLine.length === 0) return undefined;
return firstLine.length > LABEL_MAX_LENGTH
? `${firstLine.slice(0, LABEL_MAX_LENGTH - 1)}…`
: firstLine;
if (firstLine.length <= LABEL_MAX_LENGTH) return firstLine;
let end = LABEL_MAX_LENGTH - 1;
const previous = firstLine.charCodeAt(end - 1);
const next = firstLine.charCodeAt(end);
if (previous >= 0xd800 && previous <= 0xdbff && next >= 0xdc00 && next <= 0xdfff) {
end -= 1;
}
return `${firstLine.slice(0, end)}…`;
}

const KIND_NOUN: Record<BackgroundWork["kind"], readonly [string, string]> = {
Expand Down
Loading