// (c) 2026 TWWIM UG. All rights reserved. (www.twwim.com) import { useState } from 'react'; import { Modal } from '@/components/shared'; import { useTranslation } from '@/i18n/TranslationProvider'; import { useUpdateChunk } from '../hooks/useUpdateChunk'; import type { PlaygroundSource } from '@archer/api-interface'; interface ChunkEditModalProps { tenantId: string; source: PlaygroundSource; onClose: () => void; onSaved: () => void; } /** * Modal for surgical edit of a single Qdrant chunk. Identity (pointId) is * preserved by the backend; only the chunk text (and optionally entry * title) changes. */ export function ChunkEditModal({ tenantId, source, onClose, onSaved }: ChunkEditModalProps) { const { t } = useTranslation(); const [content, setContent] = useState(source.content); const mutation = useUpdateChunk(tenantId); const isDocChunk = !!source.parentId; const identifier = isDocChunk ? `${t('knowledge.playground.docChunkLabel')}: ${source.filename || '—'}${source.chunkIndex !== null ? ` · #${source.chunkIndex + 1}` : ''}` : `${t('knowledge.playground.entryLabel')}: ${source.title || '—'}`; const disabled = mutation.isPending || content.trim().length === 0; const handleSave = () => { mutation.mutate( { pointId: source.pointId, body: { content } }, { onSuccess: () => { onSaved(); onClose(); }, }, ); }; return ( } >