// (c) 2026 TWWIM UG. All rights reserved. (www.twwim.com) import { useMutation, useQueryClient } from '@tanstack/react-query'; import { queryKeys } from '@/lib/query-keys'; import { knowledgeApi } from '@/infrastructure/http/api/knowledge'; import type { PlaygroundUpdateChunkRequest, PlaygroundUpdateChunkResponse, } from '@archer/api-interface'; interface UpdateChunkVariables { pointId: string; body: PlaygroundUpdateChunkRequest; } /** * Single-responsibility mutation hook for the Playground surgical chunk * edit. On success invalidates the entry list + the document list cache so * subsequent reads reflect the edited chunk. */ export function useUpdateChunk(tenantId: string) { const queryClient = useQueryClient(); return useMutation({ mutationFn: ({ pointId, body }) => knowledgeApi.updateChunk(tenantId, pointId, body), onSuccess: () => { queryClient.invalidateQueries({ queryKey: queryKeys.knowledge.lists() }); queryClient.invalidateQueries({ queryKey: queryKeys.knowledge.documentLists(tenantId) }); }, }); }