MCPcopy Create free account
hub / github.com/agent-tower/core / useSaveFile

Function useSaveFile

packages/web/src/hooks/use-files.ts:92–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

90}
91
92export 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

Callers 1

EditorViewFunction · 0.90

Calls 2

postMethod · 0.80
inferLanguageFunction · 0.70

Tested by

no test coverage detected