fix(buddy): address CodeRabbit review findings

- buddy.ts: return type Promise<null> → Promise<React.ReactNode>
  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) <noreply@anthropic.com>
This commit is contained in:
unraid
2026-04-03 17:00:01 +08:00
parent 991119491c
commit 7d4adce1b6
2 changed files with 3 additions and 2 deletions

View File

@@ -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 (
<Text>

View File

@@ -71,7 +71,7 @@ export async function call(
onDone: LocalJSXCommandOnDone,
context: ToolUseContext & LocalJSXCommandContext,
args: string,
): Promise<null> {
): Promise<React.ReactNode> {
const sub = args?.trim().toLowerCase() ?? ''
const setState = context.setAppState