Skip to content

Commit 9c37339

Browse files
committed
fix: use renderTextTable in formatLogTable/formatTraceTable plain mode
Address BugBot review: formatLogTable and formatTraceTable were still using mdRow + mdTableHeader (pipe-delimited markdown) in plain mode instead of renderTextTable with box-drawing borders. Now consistent with formatTable.
1 parent 2bd8b38 commit 9c37339

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

src/lib/formatters/log.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
mdTableHeader,
1717
renderInlineMarkdown,
1818
renderMarkdown,
19-
stripColorTags,
19+
stripMarkdownInline,
2020
} from "./markdown.js";
2121
import {
2222
renderTextTable,
@@ -174,13 +174,17 @@ export function formatLogsHeader(): string {
174174
* @returns Rendered terminal string with Unicode-bordered table
175175
*/
176176
export function formatLogTable(logs: LogLike[], includeTrace = true): string {
177+
const headers = [...LOG_TABLE_COLS];
178+
177179
if (isPlainOutput()) {
178-
const rows = logs
179-
.map((log) => mdRow(buildLogRowCells(log, false, includeTrace)).trimEnd())
180-
.join("\n");
181-
return `${stripColorTags(mdTableHeader(LOG_TABLE_COLS))}\n${rows}\n`;
180+
const rows = logs.map((log) =>
181+
buildLogRowCells(log, false, includeTrace).map((c) =>
182+
stripMarkdownInline(c)
183+
)
184+
);
185+
return renderTextTable(headers, rows);
182186
}
183-
const headers = [...LOG_TABLE_COLS];
187+
184188
const rows = logs.map((log) =>
185189
buildLogRowCells(log, false, includeTrace).map((c) =>
186190
renderInlineMarkdown(c)

src/lib/formatters/trace.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
mdTableHeader,
2121
renderInlineMarkdown,
2222
renderMarkdown,
23-
stripColorTags,
23+
stripMarkdownInline,
2424
} from "./markdown.js";
2525
import { type Column, formatTable } from "./table.js";
2626
import { renderTextTable } from "./text-table.js";
@@ -119,15 +119,17 @@ export function formatTracesHeader(): string {
119119
* @returns Rendered terminal string with Unicode-bordered table
120120
*/
121121
export function formatTraceTable(items: TransactionListItem[]): string {
122-
if (isPlainOutput()) {
123-
const rows = items
124-
.map((item) => mdRow(buildTraceRowCells(item)).trimEnd())
125-
.join("\n");
126-
return `${stripColorTags(mdTableHeader(TRACE_TABLE_COLS))}\n${rows}\n`;
127-
}
128122
const headers = TRACE_TABLE_COLS.map((c) =>
129123
c.endsWith(":") ? c.slice(0, -1) : c
130124
);
125+
126+
if (isPlainOutput()) {
127+
const rows = items.map((item) =>
128+
buildTraceRowCells(item).map((c) => stripMarkdownInline(c))
129+
);
130+
return renderTextTable(headers, rows);
131+
}
132+
131133
const rows = items.map((item) =>
132134
buildTraceRowCells(item).map((c) => renderInlineMarkdown(c))
133135
);

0 commit comments

Comments
 (0)