[codex] fix autopilot poison summit triggers#149
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🚅 Deployed to the summit-pr-149 environment in Summit 3 services not affected by this PR
|
There was a problem hiding this comment.
Code Review
This pull request enhances the autopilot poison logic within useAutopilotOrchestrator by introducing targetedPoisonKeyRef to prevent duplicate poison applications and updating handleApplyPoison to handle asynchronous results and state resets. The GameDirector context was updated to ensure applyingPotions is reset on failed actions, and a comprehensive test suite for poison triggers was added. Feedback suggests refining the targetId check to handle both null and undefined values to prevent potential issues with executeGameAction.
| const handleApplyPoison = (amount: number, beastId?: number): boolean => { | ||
| const targetId = beastId ?? summit?.beast?.token_id; | ||
| if (!targetId || applyingPotions || amount === 0) return false; | ||
| if (targetId === undefined || applyingPotions || amount === 0) return false; |
There was a problem hiding this comment.
The check targetId === undefined is slightly too restrictive. If summit?.beast?.token_id is null (which can occur depending on the API response or state initialization), targetId will be null. Since null === undefined is false, the function would proceed, potentially passing null to executeGameAction. Using targetId == null is safer as it correctly handles both null and undefined while still allowing 0 if it's a valid ID.
| if (targetId === undefined || applyingPotions || amount === 0) return false; | |
| if (targetId == null || applyingPotions || amount === 0) return false; |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Claude Review - React/Frontend Reviewrun=25297281969 attempt=1 sha=510eeda96f37b3e32909eeae8e9c99eca2106021 scope=client Findings[MEDIUM] client/src/hooks/useAutopilotOrchestrator.ts:314 - Inconsistent owner address normalization in [MEDIUM] client/src/hooks/useAutopilotOrchestrator.ts:107-134 - [LOW] client/src/hooks/useAutopilotOrchestrator.ts:118-131 - Stale-closure ref clearing in [LOW] client/src/hooks/useAutopilotOrchestrator.ts:339-358, 423-452 - Effects depend on the entire [LOW] client/src/hooks/useAutopilotOrchestrator.ts:301, 314 - [INFO] client/src/hooks/useAutopilotOrchestrator.ts:109 - [INFO] client/src/hooks/useAutopilotOrchestrator.test.tsx:1-219 - Tests cover the two main regression scenarios but not the new conservative-poison early Residual Risks / Testing Gaps
SummarySummary: 0 CRITICAL, 0 HIGH, 2 MEDIUM, 3 LOW, 2 INFO |
Codex Review - React/Frontend Review[INFO] client/:1 - Review could not be completed from the available workspace. Summary: 0 CRITICAL, 0 HIGH, 0 MEDIUM, 0 LOW, 1 INFO |
Summary
Root Cause
The autopilot poison effects returned early while
applyingPotionsorattackInProgresswere true, but those blocker states and other poison eligibility inputs were not effect dependencies. If the Summit beast changed while autopilot was busy, or if poison balance arrived after the Summit update, the poison logic could stay idle while the UI showed “Waiting for trigger...”.Validation
pnpm exec vitest run src/hooks/useAutopilotOrchestrator.test.tsxpnpm exec vitest run src/hooks/useAutopilotOrchestrator.test.tsx src/contexts/GameDirector.test.tsxpnpm exec tsc --noEmitpnpm exec eslint . --quietpnpm build