Skip to content

Commit 09dfd52

Browse files
committed
fix(formatters): restore bold+underline for alias indicators in short ID column
Replace markdown **bold** syntax with chalk boldUnderline() for alias highlighting in formatShortId and formatShortIdWithAlias. The markdown approach only produced bold text; the original used bold+underline via chalk to make alias indicators visually distinct. ANSI codes survive the table rendering pipeline and display correctly in TTY mode.
1 parent 2b1f0ba commit 09dfd52

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

src/lib/formatters/human.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import type {
2525
Writer,
2626
} from "../../types/index.js";
2727
import { withSerializeSpan } from "../telemetry.js";
28-
import { type FixabilityTier, muted } from "./colors.js";
28+
import { boldUnderline, type FixabilityTier, muted } from "./colors.js";
2929
import {
3030
colorTag,
3131
escapeMarkdownCell,
@@ -323,20 +323,20 @@ function formatShortIdWithAlias(
323323
if (part?.startsWith(aliasUpper)) {
324324
const result = projectParts.map((p, idx) => {
325325
if (idx === i) {
326-
return `**${p.slice(0, aliasLen)}**${p.slice(aliasLen)}`;
326+
return `${boldUnderline(p.slice(0, aliasLen))}${p.slice(aliasLen)}`;
327327
}
328328
return p;
329329
});
330-
return `${result.join("-")}-**${issueSuffix}**`;
330+
return `${result.join("-")}-${boldUnderline(issueSuffix)}`;
331331
}
332332
}
333333
}
334334

335335
const projectPortion = projectParts.join("-");
336336
if (projectPortion.startsWith(aliasUpper)) {
337-
const highlighted = `**${projectPortion.slice(0, aliasLen)}**`;
337+
const highlighted = boldUnderline(projectPortion.slice(0, aliasLen));
338338
const rest = projectPortion.slice(aliasLen);
339-
return `${highlighted}${rest}-**${issueSuffix}**`;
339+
return `${highlighted}${rest}-${boldUnderline(issueSuffix)}`;
340340
}
341341

342342
return null;
@@ -373,7 +373,7 @@ export function formatShortId(
373373
const prefix = `${projectSlug.toUpperCase()}-`;
374374
if (upperShortId.startsWith(prefix)) {
375375
const suffix = shortId.slice(prefix.length);
376-
return `${prefix}**${suffix.toUpperCase()}**`;
376+
return `${prefix}${boldUnderline(suffix.toUpperCase())}`;
377377
}
378378
}
379379

test/lib/formatters/human.property.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ function stripAnsi(str: string): string {
3030
return str.replace(/\x1b\[[0-9;]*m/g, "");
3131
}
3232

33-
/** Strip both ANSI escape codes and markdown bold markers. */
33+
/** Strip ANSI escape codes for content testing. */
3434
function stripFormatting(s: string): string {
35-
return stripAnsi(s).replace(/\*\*/g, "");
35+
return stripAnsi(s);
3636
}
3737

3838
// Arbitraries

test/lib/formatters/human.test.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
import { describe, expect, test } from "bun:test";
10+
import chalk from "chalk";
1011
import {
1112
formatShortId,
1213
formatUserIdentity,
@@ -21,10 +22,10 @@ function stripAnsi(str: string): string {
2122
return str.replace(/\x1b\[[0-9;]*m/g, "");
2223
}
2324

24-
/** Strip both ANSI escape codes and markdown bold markers. */
25+
/** Strip ANSI escape codes for content testing. */
2526
function stripFormatting(s: string): string {
2627
// biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI codes use control chars
27-
return s.replace(/\x1b\[[0-9;]*m/g, "").replace(/\*\*/g, "");
28+
return s.replace(/\x1b\[[0-9;]*m/g, "");
2829
}
2930

3031
describe("formatShortId edge cases", () => {
@@ -53,8 +54,10 @@ describe("formatShortId formatting", () => {
5354
test("single project mode applies formatting to suffix", () => {
5455
const result = formatShortId("CRAFT-G", { projectSlug: "craft" });
5556
expect(stripFormatting(result)).toBe("CRAFT-G");
56-
// Suffix should be wrapped in markdown bold
57-
expect(result).toContain("**G**");
57+
// Suffix should be bold+underlined when color is active
58+
if (chalk.level > 0) {
59+
expect(result).not.toBe(stripFormatting(result));
60+
}
5861
});
5962

6063
test("multi-project mode applies formatting to suffix", () => {
@@ -64,15 +67,16 @@ describe("formatShortId formatting", () => {
6467
isMultiProject: true,
6568
});
6669
expect(stripFormatting(result)).toBe("SPOTLIGHT-ELECTRON-4Y");
67-
// Alias char and suffix should be bold
68-
expect(result).toContain("**E**");
69-
expect(result).toContain("**4Y**");
70+
// Alias char and suffix should be bold+underlined when color is active
71+
if (chalk.level > 0) {
72+
expect(result).not.toBe(stripFormatting(result));
73+
}
7074
});
7175

7276
test("no formatting when no options provided", () => {
7377
const result = formatShortId("CRAFT-G");
7478
expect(result).toBe("CRAFT-G");
75-
expect(result).not.toContain("**");
79+
expect(result).toBe(stripFormatting(result));
7680
});
7781
});
7882

0 commit comments

Comments
 (0)