WORKSPACE_SCOPE_PROMPTS_FIX
Version: 0.229.058
Issue Description
The workspace scope selector in the chat interface was only affecting document filtering but not prompt filtering. When users selected different scopes (All, Personal, Group, Public), the prompts dropdown would continue to show all prompts regardless of the selected scope, creating an inconsistent user experience.
Root Cause Analysis
The prompt loading and filtering logic in chat-prompts.js was not integrated with the workspace scope selector (doc-scope-select). The prompts were loaded using separate functions (loadUserPrompts() and loadGroupPrompts()) but were combined without considering the current scope selection, unlike the document filtering system which properly responded to scope changes.
Technical Details
Files Modified
static/js/chat/chat-global.js- Added
publicPrompts = []variable to store public prompts
- Added
static/js/chat/chat-prompts.js- Added import for
docScopeSelectfrom chat-documents.js - Implemented
loadPublicPrompts()function to fetch public prompts from/api/public_prompts - Created
populatePromptSelectScope()function with scope-aware filtering logic - Added
loadAllPrompts()function to load all prompt types - Updated
initializePromptInteractions()to:- Use
loadAllPrompts()when prompts button is clicked - Add event listener for scope changes to repopulate prompts
- Use
- Maintained backward compatibility by keeping original
populatePromptSelect()
- Added import for
config.py- Updated VERSION from "0.229.041" to "0.229.042"
Code Changes Summary
Scope Filtering Logic
- All: Shows Personal + Group + Public prompts
- Personal: Shows only Personal prompts
- Group: Shows only Group prompts
- Public: Shows only Public prompts
Event Handling
- Scope selector changes automatically trigger prompt list updates
- Prompts are only repopulated when the prompt selection container is visible
- Previous prompt selection is preserved when possible during scope changes
Testing Approach
- Created comprehensive functional test (
test_workspace_scope_prompts_fix.py) - Verified all required functions and event listeners are implemented
- Confirmed proper API endpoint usage
- Validated scope filtering conditions and labels
- Tested backward compatibility
Impact Analysis
- User Experience: Consistent behavior between document and prompt filtering
- Performance: Minimal impact - prompts are only reloaded when scope changes while prompt selector is active
- Compatibility: Backward compatible - existing functionality preserved
- Maintainability: Follows existing patterns from document scope filtering
Validation
Test Results
✅ All workspace scope prompts functionality tests passed
✅ All required API endpoints exist for public prompts
✅ Version properly updated to 0.229.042
User Experience Improvements
- Workspace scope selection now consistently affects both documents and prompts
- Users can focus on prompts from specific workspaces (personal, group, or public)
- Reduced cognitive load by showing only relevant prompts based on current scope
- Improved workflow efficiency for users working within specific workspace contexts