feat: parallel-safe tool execution via wallet mutex#211
Conversation
Prevents concurrent tool executions from causing React render loops by serializing wallet-touching operations (network switching, signing, broadcasting) through a simple promise-chain mutex. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (12)
Disabled knowledge base sources:
📝 WalkthroughWalkthroughIntroduces a wallet mutex mechanism ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
withWalletLockasync mutex (~5 lines) that serializes wallet operations (network switching, signing, broadcasting) to prevent concurrent tool executions from causing React "Maximum update depth exceeded" errorsDetails
When the LLM triggers multiple tool calls simultaneously (e.g., two sends), both UI components try to manipulate wallet state at the same time, causing a render loop. The mutex queues wallet operations so they execute sequentially while all tool cards still appear in the UI at once.
New files:
apps/agentic-chat/src/lib/walletMutex.ts— promise-chain mutexapps/agentic-chat/src/lib/walletMutex.test.ts— unit testsModified files (10):
SendUI.tsx,SwitchNetworkUI.tsx,VaultDepositUI.tsx,VaultWithdrawUI.tsxuseSwapExecution.tsx,useLimitOrderExecution.tsx,useConditionalOrderExecution.tsxuseCancelConditionalOrderExecution.tsx,useCancelLimitOrderExecution.tsx,useVaultWithdrawAllExecution.tsRead-only tools (balance queries, price lookups, tx history) are unaffected.
Test plan
bun test src/lib/walletMutex.test.ts— 3/3 pass🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests