From 7d4adce1b68eee23c0addec8d4fe11af861e230d Mon Sep 17 00:00:00 2001 From: unraid Date: Fri, 3 Apr 2026 17:00:01 +0800 Subject: [PATCH] fix(buddy): address CodeRabbit review findings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - buddy.ts: return type Promise → Promise to match LocalJSXCommandCall interface (CompanionCard path returns ReactElement, not null). - CompanionCard.tsx: clamp stat value to 0..100 before .repeat() to prevent negative count runtime error on out-of-range values. Import path alias suggestions (src/ vs ../) dismissed — project convention uses relative paths (verified against color.ts, help.ts). Co-Authored-By: Claude Opus 4.6 (1M context) --- src/buddy/CompanionCard.tsx | 3 ++- src/commands/buddy/buddy.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/buddy/CompanionCard.tsx b/src/buddy/CompanionCard.tsx index 2d7d316fe..f9264acf3 100644 --- a/src/buddy/CompanionCard.tsx +++ b/src/buddy/CompanionCard.tsx @@ -12,7 +12,8 @@ const CARD_WIDTH = 40; const CARD_PADDING_X = 2; function StatBar({ name, value }: { name: string; value: number }) { - const filled = Math.round(value / 10); + const clamped = Math.max(0, Math.min(100, value)); + const filled = Math.round(clamped / 10); const bar = '\u2588'.repeat(filled) + '\u2591'.repeat(10 - filled); return ( diff --git a/src/commands/buddy/buddy.ts b/src/commands/buddy/buddy.ts index 1ae2c205f..e28826ef1 100644 --- a/src/commands/buddy/buddy.ts +++ b/src/commands/buddy/buddy.ts @@ -71,7 +71,7 @@ export async function call( onDone: LocalJSXCommandOnDone, context: ToolUseContext & LocalJSXCommandContext, args: string, -): Promise { +): Promise { const sub = args?.trim().toLowerCase() ?? '' const setState = context.setAppState