Conversation
There was a problem hiding this comment.
Greptile Summary
This PR implements workspace-based context filtering for the copilot feature by scoping the @ mention functionality to only show chats, workflows, and knowledge bases from the current workspace. The changes are made to the user-input.tsx component within the copilot panel.
The implementation adds workspace scoping through several key changes:
- Workspace ID extraction: Uses Next.js
useParamshook to extractworkspaceIdfrom the URL parameters - Chat filtering: Filters chats based on workspace workflows, requiring workflows to be loaded first since chats are associated with workflows rather than directly with workspaces
- Workflow filtering: Directly filters workflows by
workspaceId - Knowledge base filtering: Adds
workspaceIdas a query parameter to the knowledge base API calls
This change integrates well with the existing codebase architecture, as the workflows and knowledge APIs already support workspace-based filtering. The copilot component now follows the same patterns used throughout the application for workspace scoping, ensuring consistent behavior and proper data isolation between workspaces. The implementation maintains the existing user experience while preventing cross-workspace data leakage in the mention suggestions.
Confidence score: 4/5
- This PR addresses a clear security and UX concern with minimal risk of breaking existing functionality
- Score reflects solid implementation following established patterns, though the chat filtering dependency on workflows loading could potentially cause edge cases
- Pay close attention to the chat filtering logic which depends on workflows being loaded before chats can be properly filtered
1 file reviewed, no comments
* Add filter * Scope kb and chats * Lint * Remove comments * Lint
* Add filter * Scope kb and chats * Lint * Remove comments * Lint
Summary
Scope copilot context to workflows/kbs/chats from the workspace
Type of Change
Testing
Manual
Checklist