fix(buddy): address second round CodeRabbit findings

- buddy.ts:105: remove unsafe (context as any).messages cast.
  ToolUseContext already declares messages: Message[] at Tool.ts:250,
  so context.messages is properly typed. Other commands (feedback,
  copy, export) access it the same way without cast.

- companionReact.ts:154: wrap resp.json() in try/catch for defensive
  JSON parsing. Malformed 200 responses now return null instead of
  propagating to the outer catch.

Rate-limit timing (set before API call) kept as-is — matches official
ZUK pattern: prevents retry-storm on transient failures.

src/ path alias suggestions dismissed — project uses relative paths.
Auto-unmute on /buddy view kept — matches official behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
unraid
2026-04-03 17:16:16 +08:00
parent 7d4adce1b6
commit e74d1f0836
2 changed files with 7 additions and 3 deletions

View File

@@ -151,6 +151,10 @@ async function callBuddyReactAPI(
if (!resp.ok) return null
const data = (await resp.json()) as { reaction?: string }
return data.reaction?.trim() || null
try {
const data = (await resp.json()) as { reaction?: string }
return data.reaction?.trim() || null
} catch {
return null
}
}

View File

@@ -102,7 +102,7 @@ export async function call(
setState?.(prev => ({ ...prev, companionPetAt: Date.now() }))
// Trigger a post-pet reaction
triggerCompanionReaction((context as any).messages ?? [], reaction =>
triggerCompanionReaction(context.messages ?? [], reaction =>
setState?.(prev =>
prev.companionReaction === reaction
? prev