From 6c85baf55c53f18e90b93e169102123ccc811049 Mon Sep 17 00:00:00 2001 From: betegon Date: Fri, 7 Aug 2026 13:08:52 +0200 Subject: [PATCH] fix(init): improve task panel readability --- packages/cli/src/lib/init/ui/ink-app.tsx | 93 +++++++++++-------- .../lib/init/ui/ink-app.snapshot.test.tsx | 36 ++++++- 2 files changed, 87 insertions(+), 42 deletions(-) diff --git a/packages/cli/src/lib/init/ui/ink-app.tsx b/packages/cli/src/lib/init/ui/ink-app.tsx index cadf330fe..e7ba5b94e 100644 --- a/packages/cli/src/lib/init/ui/ink-app.tsx +++ b/packages/cli/src/lib/init/ui/ink-app.tsx @@ -78,8 +78,10 @@ import type { /** Sentry blurple — primary brand accent. */ const ACCENT = "#7553FF"; -const MUTED = "gray"; -const MUTED_DIM = "#555555"; +/** De-emphasized text that still clears dark terminal backgrounds. */ +const MUTED = "#898294"; +/** Lowest-contrast treatment for borders, counters, and supporting details. */ +const MUTED_DIM = "#68616F"; /** Sentry purple — spinners, in-progress states. */ const PRIMARY = "#8B6AC8"; @@ -87,6 +89,7 @@ const COLOR_INFO = "#9C84D4"; const COLOR_WARN = "#FDB81B"; const COLOR_ERROR = "#fe4144"; const COLOR_SUCCESS = "#83da90"; +const ACTIVE_TASK_PULSE_INTERVAL_MS = 600; const ICON_BY_SEVERITY: Record = { @@ -105,6 +108,7 @@ const ICONS = { squareFilled: "\u25FC", squareOpen: "\u25FB", triangleRight: "\u25B6", + triangleRightOutline: "\u25B7", triangleSmallRight: "\u25B8", bullet: "\u2022", } as const; @@ -544,8 +548,6 @@ function ActionList({ {choices.map((choice, index) => { const isCursor = index === highlighted; - // biome-ignore lint/nursery/noLeakedRender: variable assignment, not JSX expression - const labelColor = isCursor ? undefined : MUTED; if (centered) { return ( ({ {isCursor ? `${ICONS.triangleSmallRight} ` : " "} - - {choice.label} - - {choice.hint ? ( - {choice.hint} - ) : null} + {choice.label} + {choice.hint ? {choice.hint} : null} ); } @@ -573,10 +571,8 @@ function ActionList({ {isCursor ? ICONS.triangleSmallRight : " "} - - {choice.label} - - {choice.hint ? {choice.hint} : null} + {choice.label} + {choice.hint ? {choice.hint} : null} ); })} @@ -851,7 +847,7 @@ function ProgressPanel({ steps }: { steps: StepEntry[] }): React.ReactNode { const totalCount = steps.length; const headerRight = totalCount > 0 ? `${completedCount}/${totalCount}` : ""; - const badgeColor = completedCount === totalCount ? COLOR_SUCCESS : MUTED_DIM; + const badgeColor = completedCount === totalCount ? COLOR_SUCCESS : MUTED; return ( - + {ICONS.diamondOpen} Tasks {headerRight ? {headerRight} : null} @@ -873,7 +869,7 @@ function ProgressPanel({ steps }: { steps: StepEntry[] }): React.ReactNode { - Analyzing project... + Analyzing project... ) : null} {steps.map((entry) => ( @@ -884,61 +880,81 @@ function ProgressPanel({ steps }: { steps: StepEntry[] }): React.ReactNode { } function ProgressRow({ entry }: { entry: StepEntry }): React.ReactNode { - const { glyph, glyphColor, labelColor, dimLabel } = progressStyle(entry); + const { boldLabel, glyph, glyphColor, labelColor } = progressStyle(entry); return ( - {glyph} + {entry.status === "in_progress" ? ( + + ) : ( + {glyph} + )} - + {entry.label} ); } +function ActiveTaskGlyph(): React.ReactNode { + const [isFilled, setIsFilled] = useState(true); + + useEffect(() => { + const timer = setInterval(() => { + setIsFilled((current) => !current); + }, ACTIVE_TASK_PULSE_INTERVAL_MS); + return () => clearInterval(timer); + }, []); + + return isFilled ? ( + {ICONS.triangleRight} + ) : ( + {ICONS.triangleRightOutline} + ); +} + function progressStyle(entry: StepEntry): { + boldLabel: boolean; glyph: string; glyphColor: string; labelColor?: string; - dimLabel: boolean; } { if (entry.status === "in_progress") { return { + boldLabel: true, glyph: ICONS.triangleRight, glyphColor: PRIMARY, - dimLabel: false, }; } if (entry.status === "completed") { return { + boldLabel: false, glyph: ICONS.squareFilled, glyphColor: COLOR_SUCCESS, labelColor: MUTED, - dimLabel: false, }; } if (entry.status === "failed") { return { + boldLabel: true, glyph: "\u2716", glyphColor: COLOR_ERROR, labelColor: COLOR_ERROR, - dimLabel: false, }; } if (entry.status === "skipped") { return { + boldLabel: false, glyph: "\u25CC", glyphColor: MUTED_DIM, - labelColor: MUTED_DIM, - dimLabel: true, + labelColor: MUTED, }; } return { + boldLabel: false, glyph: ICONS.squareOpen, - glyphColor: MUTED_DIM, - labelColor: MUTED, - dimLabel: true, + glyphColor: MUTED, }; } @@ -1394,18 +1410,15 @@ function SelectPromptOptionRow({ isCursor: boolean; option: SelectPromptOptionData; }): React.ReactNode { - const labelColor = isCursor ? undefined : MUTED; if (centered) { return ( {isCursor ? `${ICONS.triangleSmallRight} ` : " "} - - {option.label} - + {option.label} {option.hint !== undefined && option.hint !== "" ? ( - {option.hint} + {option.hint} ) : null} ); @@ -1415,11 +1428,9 @@ function SelectPromptOptionRow({ {isCursor ? ICONS.triangleSmallRight : " "} - - {option.label} - + {option.label} {option.hint !== undefined && option.hint !== "" ? ( - {option.hint} + {option.hint} ) : null} ); @@ -1662,7 +1673,7 @@ function MultiSelectPromptOptionRow({ option: MultiSelectPromptOptionData; }): React.ReactNode { const marker = isSelected ? ICONS.squareFilled : ICONS.squareOpen; - const markerColor = isSelected ? COLOR_SUCCESS : MUTED_DIM; + const markerColor = isSelected ? COLOR_SUCCESS : MUTED; if (centered) { return ( @@ -1672,7 +1683,7 @@ function MultiSelectPromptOptionRow({ {marker} {option.label} {option.hint !== undefined && option.hint !== "" ? ( - {option.hint} + {option.hint} ) : null} ); @@ -1685,7 +1696,7 @@ function MultiSelectPromptOptionRow({ {marker} {option.label} {option.hint !== undefined && option.hint !== "" ? ( - {option.hint} + {option.hint} ) : null} ); diff --git a/packages/cli/test/lib/init/ui/ink-app.snapshot.test.tsx b/packages/cli/test/lib/init/ui/ink-app.snapshot.test.tsx index 916277630..8fe699620 100644 --- a/packages/cli/test/lib/init/ui/ink-app.snapshot.test.tsx +++ b/packages/cli/test/lib/init/ui/ink-app.snapshot.test.tsx @@ -13,7 +13,7 @@ import { Readable, Writable } from "node:stream"; import { setTimeout as sleep } from "node:timers/promises"; import { render } from "ink"; import { createElement } from "react"; -import { describe, expect, test } from "vitest"; +import { describe, expect, test, vi } from "vitest"; import { bannerLinesWidth, FULL_BANNER_LINES, @@ -129,6 +129,27 @@ async function renderApp( return out; } +async function renderActiveTaskFrameAfter(elapsedMs: number): Promise { + const out = new CaptureStream(120, 40); + const stdin = makeStdin(); + const store = new WizardStore(); + store.setStepStatus("detect-platform", "in_progress"); + const instance = render(createElement(App, { store }), { + stdout: out as unknown as NodeJS.WriteStream, + stderr: out as unknown as NodeJS.WriteStream, + stdin: stdin as unknown as NodeJS.ReadStream, + patchConsole: false, + exitOnCtrlC: false, + }); + + try { + await vi.advanceTimersByTimeAsync(elapsedMs); + } finally { + instance.unmount(); + } + return stripAnsi(out.allOutput()); +} + function hasForcedWhiteForeground(output: string): boolean { return ( output.includes(`${ANSI_ESCAPE_PREFIX}37m`) || @@ -232,6 +253,19 @@ describe("Ink App snapshot", () => { expect(frame.indexOf("Tasks")).toBeLessThan(frame.indexOf("Did you know?")); }); + test("pulses the active task arrow without changing its width", async () => { + vi.useFakeTimers(); + try { + const initialFrame = await renderActiveTaskFrameAfter(1); + expect(initialFrame).toContain("▶ Detecting platform"); + + const pulsedFrame = await renderActiveTaskFrameAfter(601); + expect(pulsedFrame).toContain("▷ Detecting platform"); + } finally { + vi.useRealTimers(); + } + }); + test("renders single-column layout at narrow width", async () => { const store = new WizardStore(); store.appendLog("info", "Narrow terminal");