-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix(source selection): enable all by default and persist choice #5511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Summary
This PR implements source selection improvements by enabling all sources by default for new users and persisting user preferences in localStorage. The changes include:
- Frontend: Modified
ActionToggle
component to load saved source preferences from localStorage, defaulting to all sources enabled for first-time users, and persisting changes back to localStorage - Backend: Added null check in federated retrieval to properly handle cases where no source types are specified
- UI Cleanup: Removed source chips from chat input bar since sources are now managed within the ActionToggle component
The implementation follows React best practices with proper state management, localStorage integration for persistence, and maintains backward compatibility. The backend change ensures federated connectors are properly skipped when no sources are selected.
Confidence Score: 4/5
- This PR is safe to merge with minor style improvements needed
- The implementation is solid with proper error handling and state management, but has one minor style issue with missing type annotations that should be addressed according to custom instructions
- ActionManagement.tsx needs a minor type annotation fix for the filter function parameter
Important Files Changed
File Analysis
Filename | Score | Overview |
---|---|---|
backend/onyx/federated_connectors/federated_retrieval.py | 5/5 | Added null check for source_types to properly skip federated connectors when none specified |
web/src/app/chat/components/input/ActionManagement.tsx | 4/5 | Added localStorage persistence for source selection preferences and default-enable-all behavior |
web/src/app/chat/components/input/ChatInputBar.tsx | 5/5 | Removed source chips from filter display and passed filterManager to ActionToggle component |
Sequence Diagram
sequenceDiagram
participant User
participant ChatInputBar
participant ActionToggle
participant FilterManager
participant LocalStorage
participant Backend
User->>ChatInputBar: Opens chat interface
ChatInputBar->>ActionToggle: Renders with filterManager prop
ActionToggle->>LocalStorage: Check for saved source preferences
alt First time user (no saved preferences)
ActionToggle->>ActionToggle: Enable all available sources by default
ActionToggle->>FilterManager: setSelectedSources(allSources)
ActionToggle->>LocalStorage: Save default selection
else Existing user (has saved preferences)
LocalStorage->>ActionToggle: Return saved preferences
ActionToggle->>ActionToggle: Validate saved sources against available
ActionToggle->>FilterManager: setSelectedSources(validSavedSources)
end
User->>ActionToggle: Toggles source selection
ActionToggle->>FilterManager: Update selected sources
ActionToggle->>LocalStorage: Persist new selection
User->>ChatInputBar: Submits query
ChatInputBar->>Backend: Send query with selected sources
alt source_types is None
Backend->>Backend: Skip federated connectors
Backend->>ChatInputBar: Return results without federated data
else source_types provided
Backend->>Backend: Filter federated connectors by source_types
Backend->>ChatInputBar: Return results with federated data
end
3 files reviewed, 1 comment
if (savedSources !== null) { | ||
const availableSourceMetadata = getConfiguredSources(availableSources); | ||
const validSavedSources = savedSources.filter( | ||
(savedSource: SourceMetadata) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: explicit type annotation missing for savedSource
parameter
(savedSource: SourceMetadata) => | |
(savedSource: SourceMetadata) => |
Context Used: Context - Use explicit type annotations for variables to enhance code clarity, especially when moving type hints around in the code. (link)
Prompt To Fix With AI
This is a comment left during a code review.
Path: web/src/app/chat/components/input/ActionManagement.tsx
Line: 479:479
Comment:
style: explicit type annotation missing for `savedSource` parameter
```suggestion
(savedSource: SourceMetadata) =>
```
**Context Used:** **Context -** Use explicit type annotations for variables to enhance code clarity, especially when moving type hints around in the code. ([link](https://app.greptile.com/review/custom-context?memory=f234365d-3144-4a85-994f-1e9dd56f6cc2))
How can I resolve this? If you propose a fix, please make it concise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 3 files
e5547fb
to
9ee6504
Compare
Description
[Provide a brief description of the changes in this PR]
How Has This Been Tested?
[Describe the tests you ran to verify your changes]
Additional Options