Skip to content

Commit d5ccfe2

Browse files
committed
fix(knowledge): derive tags modal document data from live list cache
The modal was fed a frozen document snapshot taken at right-click time. After a save, the mutation only invalidates the single-document and KB-detail queries (not the documents list query), so the modal's own sync effect rebuilt tags from the stale snapshot and could revert or drop the just-saved value. Track only the document id and look it up from the same documents array updateDocument() patches, so the modal always sees current data.
1 parent af39dee commit d5ccfe2

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/knowledge/[id]

apps/sim/app/workspace/[workspaceId]/knowledge/[id]/base.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ export function KnowledgeBase({
344344
const [showRenameModal, setShowRenameModal] = useState(false)
345345
const [documentToRename, setDocumentToRename] = useState<DocumentData | null>(null)
346346
const [showDocumentTagsModal, setShowDocumentTagsModal] = useState(false)
347-
const [documentForTags, setDocumentForTags] = useState<DocumentData | null>(null)
347+
const [documentForTagsId, setDocumentForTagsId] = useState<string | null>(null)
348348
const showAddConnectorModal = addConnectorType != null
349349
const updateAddConnectorParam = useCallback(
350350
(value: string | null) => {
@@ -538,7 +538,7 @@ export function KnowledgeBase({
538538
* Opens the document tags modal
539539
*/
540540
const handleViewDocumentTags = (doc: DocumentData) => {
541-
setDocumentForTags(doc)
541+
setDocumentForTagsId(doc.id)
542542
setShowDocumentTagsModal(true)
543543
}
544544

@@ -1356,14 +1356,14 @@ export function KnowledgeBase({
13561356
/>
13571357
)}
13581358

1359-
{documentForTags && (
1359+
{documentForTagsId && (
13601360
<DocumentTagsModal
13611361
open={showDocumentTagsModal}
13621362
onOpenChange={setShowDocumentTagsModal}
13631363
knowledgeBaseId={id}
1364-
documentId={documentForTags.id}
1365-
documentData={documentForTags}
1366-
onDocumentUpdate={(updates) => updateDocument(documentForTags.id, updates)}
1364+
documentId={documentForTagsId}
1365+
documentData={documents.find((doc) => doc.id === documentForTagsId) ?? null}
1366+
onDocumentUpdate={(updates) => updateDocument(documentForTagsId, updates)}
13671367
/>
13681368
)}
13691369

0 commit comments

Comments
 (0)