Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • fix styling inconsistencies for status badges across docs and chunks pages
  • add rename capability for documents context menu
  • added search preview to show matching text instead of hardcoded first 150 chars
  • fix missing table row hover state in light mode

Type of Change

  • Bug fix
  • New feature

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)

@vercel
Copy link

vercel bot commented Jan 5, 2026

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

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 5, 2026 6:28am

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 5, 2026

Greptile Summary

This PR enhances the knowledge base UI with several improvements: fixes styling inconsistencies for status badges by migrating to the standard Badge component, adds document renaming capability through a new modal with proper validation and optimistic updates, implements intelligent search preview that shows matching text context instead of always displaying the first 150 characters, and fixes missing table row hover states in light mode.

Key Changes:

  • Replaced custom badge styling functions with the standard Badge component (variant='green' and variant='gray') for consistent appearance across docs and chunks
  • Added RenameDocumentModal with validation, error handling, and optimistic updates with rollback on failure
  • Enhanced truncateContent() to find and display the first matching search term with surrounding context (30 chars before, 150 total)
  • Improved multi-select context menu behavior: right-clicking unselected items now selects only that item, while right-clicking selected items preserves the selection
  • Fixed table row hover states by updating from bg-[var(--surface-2)] to bg-[var(--surface-3)] dark:bg-[var(--surface-4)] for better light mode visibility
  • Added batch operation support to context menus with dynamic toggle labels (shows "Enable" if any disabled items in selection)

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk, featuring well-structured UI enhancements with proper error handling
  • The changes are well-implemented with proper error handling, optimistic updates with rollback, and consistent patterns. The code follows established conventions for the codebase. Minor concerns include the lack of explicit regex escaping in the search preview logic (though SearchHighlight handles it) and the optimistic update implementation using local state + query cache updates.
  • No files require special attention - all changes follow established patterns and include proper error handling

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/document.tsx Enhanced chunks table with search preview, consistent Badge component usage, and improved multi-select behavior for context menu operations
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/base.tsx Added rename document functionality with modal, improved context menu selection behavior, and consistent styling for table row hover states
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/rename-document-modal/rename-document-modal.tsx New modal component for renaming documents with proper validation, error handling, and optimistic updates
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/document-context-menu/document-context-menu.tsx Added multi-select support and rename action to context menu with proper conditional rendering

Sequence Diagram

sequenceDiagram
    participant User
    participant UI as Document/Base Component
    participant ContextMenu
    participant Modal as RenameDocumentModal
    participant API as /api/knowledge/[id]/documents/[documentId]
    participant QueryClient as React Query Cache

    Note over User,QueryClient: Rename Document Flow
    User->>UI: Right-click document row
    UI->>UI: Update selection if unselected
    UI->>ContextMenu: Open context menu
    User->>ContextMenu: Click "Rename"
    ContextMenu->>Modal: Open RenameDocumentModal
    User->>Modal: Enter new name & submit
    Modal->>UI: Call handleSaveRename()
    UI->>UI: Optimistically update local state
    UI->>QueryClient: Update cached document name
    UI->>API: PUT request with new filename
    alt Success
        API-->>UI: {success: true, data}
        UI->>UI: Keep optimistic update
    else Error
        API-->>UI: Error response
        UI->>UI: Rollback to previous name
        UI->>QueryClient: Restore previous name in cache
        UI->>Modal: Display error message
    end

    Note over User,QueryClient: Search Preview Flow
    User->>UI: Enter search query
    UI->>UI: Filter chunks/documents
    UI->>UI: Call truncateContent(content, 150, searchQuery)
    UI->>UI: Find first matching term in content
    UI->>UI: Extract 150 chars around match
    UI->>UI: Pass to SearchHighlight component
    UI-->>User: Display highlighted preview

    Note over User,QueryClient: Multi-Select Context Menu Flow
    User->>UI: Select multiple items (Shift/Ctrl+Click)
    User->>UI: Right-click on selected item
    UI->>ContextMenu: Open with selectedCount, enabledCount, disabledCount
    ContextMenu->>ContextMenu: Hide single-item actions (Edit, Open, Copy)
    ContextMenu->>ContextMenu: Show batch actions (Enable/Disable, Delete)
    ContextMenu->>ContextMenu: Dynamic toggle label (Enable if any disabled)
    User->>ContextMenu: Click batch action
    ContextMenu->>UI: Call bulk handler
    UI->>API: Multiple update/delete requests
    API-->>UI: Update responses
    UI->>QueryClient: Invalidate/update queries
Loading

@waleedlatif1 waleedlatif1 merged commit ed6b9c0 into staging Jan 5, 2026
11 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/kb branch January 5, 2026 07:47
waleedlatif1 added a commit that referenced this pull request Jan 8, 2026
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.

2 participants