Skip to content

improvement(knowledge): open document tags from row context menu#5510

Merged
waleedlatif1 merged 3 commits into
stagingfrom
kb-doc-tags-menu
Jul 8, 2026
Merged

improvement(knowledge): open document tags from row context menu#5510
waleedlatif1 merged 3 commits into
stagingfrom
kb-doc-tags-menu

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Document row context menu had a "Tags" item that just navigated to the document detail page (per Justin's Slack feedback) — you'd then have to open the breadcrumb dropdown there to actually edit tags
  • "Tags" now opens the existing DocumentTagsModal directly from the list, no navigation
  • Item now shows even when the document has no tags yet, so a first tag can be added from the row (previously hidden until at least one tag existed)

Type of Change

  • Improvement

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

The document row context menu had a Tags entry that only navigated to the document detail page, requiring another click through the breadcrumb dropdown to actually edit tags. It now opens the tag editor directly, and shows even when the document has no tags yet so a first tag can be added.
@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 8, 2026 5:55pm

Request Review

@cursor

cursor Bot commented Jul 8, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
UI-only flow change reusing the existing document tags modal and edit permission checks; no new APIs or auth paths.

Overview
Document row context menu now opens DocumentTagsModal in place on the knowledge base list, instead of routing to the document detail page to edit tags indirectly.

The list view wires modal state (handleViewDocumentTags) and passes onDocumentUpdate so tag edits refresh the row. Tags is only offered when the user canEdit and a single document is selected.

DocumentContextMenu drops the hasTags gate so Tags appears even for documents with no tags yet (enabling first-tag creation from the row). The menu label changes from View tags to Tags.

Reviewed by Cursor Bugbot for commit d5ccfe2. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR improves the document row context menu by opening the existing DocumentTagsModal directly from the list instead of navigating to the document detail page, and removes the prior hasTags guard so the Tags action is always available for single-document selections.

  • base.tsx: Adds showDocumentTagsModal/documentForTagsId state, a handleViewDocumentTags handler, and renders DocumentTagsModal inline; gates onViewTags on userPermissions.canEdit so read-only viewers can't open the modal.
  • document-context-menu.tsx: Drops the hasTags prop, simplifies the edit-section guard, and renames the menu item from "View tags" to "Tags".

Confidence Score: 5/5

Safe to merge — the change is narrowly scoped to opening an existing modal in-place instead of navigating away, with no new API surfaces or data paths introduced.

Both changed files are straightforward: one adds modal state + renders an existing component, the other drops a now-unnecessary prop. The DocumentTagsModal already resets its editing state via handleClose, so switching documents doesn't leave stale form data. Permission gating was added correctly.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/base.tsx Adds DocumentTagsModal inline with proper state management, permission guard, and document data passthrough; handleClose in the modal already resets editing state on close so no stale-state risk when switching documents.
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/document-context-menu/document-context-menu.tsx Removes hasTags prop and its usage, simplifies hasEditSection guard, renames menu item to 'Tags' — clean, mechanical change.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant User
    participant ContextMenu as DocumentContextMenu
    participant KnowledgeBase as KnowledgeBase (base.tsx)
    participant TagsModal as DocumentTagsModal

    User->>ContextMenu: Right-click row → "Tags"
    ContextMenu->>KnowledgeBase: onViewTags()
    KnowledgeBase->>KnowledgeBase: "handleViewDocumentTags(doc)<br/>setDocumentForTagsId(doc.id)<br/>setShowDocumentTagsModal(true)"
    KnowledgeBase->>TagsModal: "render open=true, documentId, documentData"
    TagsModal-->>User: Modal opens with tag list

    User->>TagsModal: Save / close
    TagsModal->>TagsModal: "handleClose(false)<br/>resets editingTagIndex, isCreatingTag, editTagForm"
    TagsModal->>KnowledgeBase: onOpenChange(false)
    KnowledgeBase->>KnowledgeBase: setShowDocumentTagsModal(false)
    TagsModal-->>User: Modal closes
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant User
    participant ContextMenu as DocumentContextMenu
    participant KnowledgeBase as KnowledgeBase (base.tsx)
    participant TagsModal as DocumentTagsModal

    User->>ContextMenu: Right-click row → "Tags"
    ContextMenu->>KnowledgeBase: onViewTags()
    KnowledgeBase->>KnowledgeBase: "handleViewDocumentTags(doc)<br/>setDocumentForTagsId(doc.id)<br/>setShowDocumentTagsModal(true)"
    KnowledgeBase->>TagsModal: "render open=true, documentId, documentData"
    TagsModal-->>User: Modal opens with tag list

    User->>TagsModal: Save / close
    TagsModal->>TagsModal: "handleClose(false)<br/>resets editingTagIndex, isCreatingTag, editTagForm"
    TagsModal->>KnowledgeBase: onOpenChange(false)
    KnowledgeBase->>KnowledgeBase: setShowDocumentTagsModal(false)
    TagsModal-->>User: Modal closes
Loading

Reviews (2): Last reviewed commit: "fix(knowledge): derive tags modal docume..." | Re-trigger Greptile

Comment thread apps/sim/app/workspace/[workspaceId]/knowledge/[id]/base.tsx
Comment thread apps/sim/app/workspace/[workspaceId]/knowledge/[id]/base.tsx
Matches the existing disableRename/disableDelete/disableToggleEnabled pattern; the document detail breadcrumb already hides its Tags entry for non-editors the same way.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

Fixed — added userPermissions.canEdit gate to the Tags menu item (af39dee), matching the existing disableRename/disableDelete/disableToggleEnabled pattern for the other mutable actions.

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.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit d5ccfe2. Configure here.

@waleedlatif1 waleedlatif1 merged commit 099f525 into staging Jul 8, 2026
18 checks passed
@waleedlatif1 waleedlatif1 deleted the kb-doc-tags-menu branch July 8, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant