|
| 1 | +import { note as clackNote } from "@clack/prompts"; |
1 | 2 | // Terminal Core tests cover table behavior. |
2 | 3 | import { afterEach, describe, expect, it, vi } from "vitest"; |
3 | 4 | import { visibleWidth } from "./ansi.js"; |
4 | | -import { resolveNoteColumns, wrapNoteMessage } from "./note.js"; |
| 5 | +import { resolveNoteColumns, resolveNoteOutputColumns, wrapNoteMessage } from "./note.js"; |
5 | 6 | import { renderTable } from "./table.js"; |
6 | 7 | |
7 | 8 | function mockProcessPlatform(platform: NodeJS.Platform): void { |
@@ -348,6 +349,33 @@ describe("wrapNoteMessage", () => {
|
348 | 349 | expect(resolveNoteColumns(120)).toBe(120); |
349 | 350 | }); |
350 | 351 | |
| 352 | +it("widens note output columns so clack does not re-wrap copy-sensitive lines", () => { |
| 353 | +const wrapped = wrapNoteMessage( |
| 354 | +[ |
| 355 | +"- Found 1 session lock file.", |
| 356 | +"- ~/.openclaw/agents/main/sessions/9c2acae5-841f-4aea-936b-fdb513b60202.jsonl.lock pid=86519 (alive) age=2m47s stale=no", |
| 357 | +].join("\n"), |
| 358 | +{ columns: 80 }, |
| 359 | +); |
| 360 | +const writes: string[] = []; |
| 361 | +const output = { |
| 362 | +columns: resolveNoteOutputColumns(wrapped, 80), |
| 363 | +write(chunk: string) { |
| 364 | +writes.push(chunk); |
| 365 | +return true; |
| 366 | +}, |
| 367 | +} as unknown as NodeJS.WriteStream; |
| 368 | + |
| 369 | +clackNote(wrapped, "Session locks", { output, format: (line) => line }); |
| 370 | + |
| 371 | +const rendered = writes.join(""); |
| 372 | +expect(rendered).toContain(".jsonl.lock"); |
| 373 | +expect(rendered).not.toContain(".js\n"); |
| 374 | +expect(rendered).toContain( |
| 375 | +"- ~/.openclaw/agents/main/sessions/9c2acae5-841f-4aea-936b-fdb513b60202.jsonl.lock", |
| 376 | +); |
| 377 | +}); |
| 378 | + |
351 | 379 | it("coerces nullish and non-string note messages before wrapping", () => { |
352 | 380 | expect(wrapNoteMessage(undefined, { maxWidth: 20, columns: 80 })).toBe(""); |
353 | 381 | expect(wrapNoteMessage(null, { maxWidth: 20, columns: 80 })).toBe(""); |
|