[codex] fix autopilot poison triggers#148
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
🚅 Deployed to the summit-pr-148 environment in Summit 3 services not affected by this PR
|
|
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 |
There was a problem hiding this comment.
Code Review
This pull request implements "Smart Poison" functionality within the autopilot orchestrator, enabling the system to project poison damage over time and delay attacks until the target reaches a minimum health threshold (1 HP and 0 extra lives). Key changes include the addition of damage projection utilities, updated state management in the orchestrator hook to handle poison wait states, and comprehensive test coverage. Feedback was provided regarding an inefficiency in the poison check timer, which currently polls every second; it is recommended to use the actual projected duration to reduce unnecessary orchestrator re-evaluations.
| const scheduleSmartPoisonCheck = (secondsUntilReady: number) => { | ||
| clearSmartPoisonTimer(); | ||
|
|
||
| const delayMs = Math.max(250, Math.min(Math.ceil(secondsUntilReady), 1) * 1000); |
There was a problem hiding this comment.
The current implementation caps the delay at 1 second (Math.min(..., 1) * 1000), which results in a polling loop that re-triggers the entire orchestrator logic every second while waiting for poison. Given the complexity of this hook (numerous useMemo and useEffect blocks), this is inefficient.
It is recommended to wait for the actual projected duration. React state updates (e.g., from new blocks) will naturally trigger re-evaluations if the summit state changes, and the existing cleanup logic will handle timer cancellation if the wait is no longer valid. If a per-second UI countdown is required in the log, it should ideally be handled by a more lightweight mechanism than re-triggering the full orchestrator.
| const delayMs = Math.max(250, Math.min(Math.ceil(secondsUntilReady), 1) * 1000); | |
| const delayMs = Math.max(250, Math.ceil(secondsUntilReady) * 1000); |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Claude Review - React/Frontend Reviewrun=25296585853 attempt=1 sha=7ab89609173965c337e1d12053a2ff8de8aaf584 scope=client [MEDIUM] client/src/hooks/useAutopilotOrchestrator.ts:132 - [LOW] client/src/hooks/useAutopilotOrchestrator.ts:258, 268 - [LOW] client/src/hooks/useAutopilotOrchestrator.ts:139-156 - [LOW] client/src/hooks/useAutopilotOrchestrator.ts:178-208 - [INFO] client/src/hooks/useAutopilotOrchestrator.ts:331-336 - Token-id reset effect runs on initial mount. [INFO] client/src/hooks/useAutopilotOrchestrator.test.tsx:128-137 - Test bypasses the real [INFO] client/src/hooks/useAutopilotOrchestrator.ts:540-543 - Attack payload still uses raw Summary: 0 CRITICAL, 0 HIGH, 1 MEDIUM, 3 LOW, 3 INFO |
Codex Review - React/Frontend Review[INFO] client/:1 - Review blocked: the local command runner failed before Summary: 0 CRITICAL, 0 HIGH, 0 MEDIUM, 0 LOW, 1 INFO |
Summary
Root Cause
Autopilot poison effects only depended on a small subset of the state they used, so a beast could become eligible while the effect stayed idle and the UI still showed “Waiting for trigger...”. There was also no failure cleanup for potion actions, and poison could be followed by attack logic in the same evaluation pass.
Validation
pnpm exec tsc --noEmitpnpm exec eslint src/hooks/useAutopilotOrchestrator.ts src/hooks/useAutopilotOrchestrator.test.tsx src/contexts/GameDirector.tsx src/utils/beasts.ts src/utils/beasts.test.ts --quietpnpm exec vitest run src/hooks/useAutopilotOrchestrator.test.tsx src/utils/beasts.test.ts src/contexts/GameDirector.test.tsxpnpm build