Download src/hooks/mutation/use-read-conversation-file.ts from SaylorTwift/openhands: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/SaylorTwift/openhands/resolve/main/src/hooks/mutation/use-read-conversation-file.ts
- Command line
-
hf download hf://SaylorTwift/openhands/src/hooks/mutation/use-read-conversation-file.ts
-
curl -L -o use-read-conversation-file.ts https://huggingface.co/SaylorTwift/openhands/resolve/main/src/hooks/mutation/use-read-conversation-file.ts
1.14 kB
| import { useMutation } from "@tanstack/react-query"; | |
| import AgentServerConversationService from "#/api/conversation-service/agent-server-conversation-service.api"; | |
| import { getErrorStatus } from "#/hooks/query/use-settings"; | |
| import { displayErrorToast } from "#/utils/custom-toast-handlers"; | |
| import { retrieveAxiosErrorMessage } from "#/utils/retrieve-axios-error-message"; | |
| interface UseReadConversationFileVariables { | |
| conversationId: string; | |
| filePath?: string; | |
| } | |
| export const useReadConversationFile = () => | |
| useMutation({ | |
| mutationKey: ["read-conversation-file"], | |
| // A 404 (no plan yet) is expected and must stay silent; `onError` below | |
| // re-shows the toast for anything else so real failures still surface. | |
| meta: { disableToast: true }, | |
| mutationFn: async ({ | |
| conversationId, | |
| filePath, | |
| }: UseReadConversationFileVariables): Promise<string> => | |
| AgentServerConversationService.readConversationFile( | |
| conversationId, | |
| filePath, | |
| ), | |
| onError: (error) => { | |
| if (getErrorStatus(error) === 404) return; | |
| displayErrorToast(retrieveAxiosErrorMessage(error)); | |
| }, | |
| }); | |