Skip to content

Commit e74d1f0

Browse files
unraidclaude
andcommitted
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>
1 parent 7d4adce commit e74d1f0

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/buddy/companionReact.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ async function callBuddyReactAPI(
151151

152152
if (!resp.ok) return null
153153

154-
const data = (await resp.json()) as { reaction?: string }
155-
return data.reaction?.trim() || null
154+
try {
155+
const data = (await resp.json()) as { reaction?: string }
156+
return data.reaction?.trim() || null
157+
} catch {
158+
return null
159+
}
156160
}

src/commands/buddy/buddy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export async function call(
102102
setState?.(prev => ({ ...prev, companionPetAt: Date.now() }))
103103

104104
// Trigger a post-pet reaction
105-
triggerCompanionReaction((context as any).messages ?? [], reaction =>
105+
triggerCompanionReaction(context.messages ?? [], reaction =>
106106
setState?.(prev =>
107107
prev.companionReaction === reaction
108108
? prev

0 commit comments

Comments
 (0)