Use idiomatic react-query for useProposal (#2018)
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> **Refactor: proposal fetching via react-query**
>
> - Replaces Jotai state/effects with `useQuery` in `useProposal`
(`queryKey: ["proposal", chatId]`, `enabled` gating, `refetch` exposed,
error typed as `Error`)
> - Deletes `src/atoms/proposalAtoms.ts`; `proposalResultAtom` removed
> - In `useStreamChat`, stop using `useProposal`; on stream end, call
`queryClient.invalidateQueries({ queryKey: ["proposal", chatId] })`
> - In `ChatInput`, display `proposalError.message` and keep using
`refreshProposal()` from the hook
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
9739b1befe76a7cb491594815d3d92977ad6a1c6. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Refactored proposal fetching to use React Query’s useQuery, removing
Jotai state and simplifying refresh and error handling. Improves
reliability and makes the hook easier to use.
- **Refactors**
- Replaced custom state/effects with useQuery (key: ["proposal",
chatId], enabled only when chatId).
- Removed proposalAtoms and Jotai; hook now returns proposalResult,
isLoading, error, refreshProposal.
- Updated useStreamChat to invalidate the proposal query via QueryClient
(invalidateQueries(["proposal", chatId])).
- ChatInput now displays proposalError.message for clearer errors.
- Added meta: { showErrorToast: true } to surface fetch errors.
<sup>Written for commit 9739b1befe76a7cb491594815d3d92977ad6a1c6.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
正在显示
请
注册
或者
登录
后发表评论