()
| 90 | } |
| 91 | |
| 92 | export function useSaveFile() { |
| 93 | const queryClient = useQueryClient() |
| 94 | |
| 95 | return useMutation({ |
| 96 | mutationFn: (input: { workingDir: string; path: string; content: string }) => |
| 97 | apiClient.post<{ success: true }>('/files/write', input), |
| 98 | onSuccess: (_data, variables) => { |
| 99 | const key = queryKeys.files.content(variables.workingDir, variables.path) |
| 100 | const existing = queryClient.getQueryData<FileContentResponse>(key) |
| 101 | queryClient.setQueryData(key, { |
| 102 | content: variables.content, |
| 103 | language: existing?.language || inferLanguage(variables.path), |
| 104 | } satisfies FileContentResponse) |
| 105 | }, |
| 106 | }) |
| 107 | } |
| 108 |
no test coverage detected