Public Workspace Scope Display Enhancement
Fixed in version: 0.229.014
Issue Description
The Public Workspace scope selector in the chat interface displayed only a generic "Public" label, making it difficult for users to identify which specific public workspaces they were accessing when multiple public workspaces were visible to them.
Root Cause Analysis
The scope selector was using a static label "Public" defined in the HTML template, without any dynamic updates based on the user's visible public workspace selections. While the Group scope already showed the group name dynamically (Group: {{ active_group_name }}), the Public scope lacked similar functionality.
Technical Details
Files Modified
application/single_app/static/js/chat/chat-documents.jsapplication/single_app/config.py(version update)
Code Changes Summary
1. Added Tracking of Visible Public Workspace IDs
let visiblePublicWorkspaceIds = []; // Store IDs of public workspaces visible to the user
2. Enhanced loadPublicDocs Function
Updated the function to store which public workspaces are visible to the user:
const visibleWorkspaceIds = Object.keys(publicDirectorySettings).filter(
id => publicDirectorySettings[id] === true
);
visiblePublicWorkspaceIds = visibleWorkspaceIds; // Store for use in scope label updates
3. Created updateScopeLabels Function
Added a new function to dynamically update the public scope option text:
function updateScopeLabels() {
if (!docScopeSelect) return;
const publicOption = docScopeSelect.querySelector('option[value="public"]');
if (publicOption) {
const visibleWorkspaceNames = visiblePublicWorkspaceIds
.map(id => publicWorkspaceIdToName[id])
.filter(name => name && name !== "Unknown");
let publicLabel = "Public";
if (visibleWorkspaceNames.length === 0) {
publicLabel = "Public";
} else if (visibleWorkspaceNames.length === 1) {
publicLabel = `Public: ${visibleWorkspaceNames[0]}`;
} else if (visibleWorkspaceNames.length <= 3) {
publicLabel = `Public: ${visibleWorkspaceNames.join(", ")}`;
} else {
publicLabel = `Public: ${visibleWorkspaceNames.slice(0, 3).join(", ")}, 3+`;
}
publicOption.textContent = publicLabel;
}
}
4. Integrated Scope Updates
Called the update function after loading documents:
return Promise.all([loadPersonalDocs(), loadGroupDocs(), loadPublicDocs()])
.then(() => {
updateScopeLabels(); // Update scope labels after loading data
populateDocumentSelectScope();
});
Validation
Display Logic Testing
The enhancement provides different display formats based on the number of visible public workspaces:
- No visible workspaces:
"Public" - 1 visible workspace:
"Public: [Workspace Name]" - 2-3 visible workspaces:
"Public: [Name1], [Name2], [Name3]" - More than 3 workspaces:
"Public: [Name1], [Name2], [Name3], 3+"
Before/After Comparison
Before:
- Public scope always showed:
"Public" - Users couldn't tell which public workspaces were active
After:
- Public scope shows specific workspace names:
"Public: Research Team, Marketing Docs" - Users can easily identify which public workspaces they're accessing
- Consistent with Group scope naming pattern
User Experience Improvements
Enhanced Clarity
- Users can immediately see which public workspaces they have access to
- Reduces confusion when working with multiple public workspaces
- Provides consistent naming patterns across all scope types
Better Workspace Management
- Clear indication of active public workspace selections
- Easy identification of workspace context for document searches
- Improved navigation between different workspace scopes
Visual Consistency
- Matches the existing Group scope display pattern (
Group: [Group Name]) - Maintains UI consistency across different workspace types
- Professional, clean display format
Impact Analysis
User Impact
- Positive: Improved workspace identification and navigation
- Neutral: No breaking changes to existing functionality
- Performance: Minimal overhead from label updates
System Impact
- No database schema changes required
- No API changes needed
- Client-side enhancement only
- Backward compatible
Related Enhancements
This fix complements other workspace-related features:
- Group workspace scope display (
Group: {{ active_group_name }}) - Public workspace management interface
- Workspace document filtering and search
- Personal workspace organization
Testing Approach
Manual Testing Scenarios
- User with no visible public workspaces
- User with one visible public workspace
- User with 2-3 visible public workspaces
- User with more than 3 visible public workspaces
- User switching between different workspace scopes
- User changing public workspace visibility settings
Regression Testing
- Verified existing Group and Personal scope displays remain unchanged
- Confirmed document filtering continues to work correctly
- Validated scope selection functionality is preserved
Implementation Notes
Design Decisions
- Used comma-separated names for multiple workspaces for readability
- Limited display to 3 workspace names plus count indicator to prevent UI overflow
- Maintained "Public:" prefix for consistency with Group scope pattern
- Updated labels dynamically after document loading to ensure data accuracy
Future Considerations
- Could be extended to show workspace descriptions if needed
- Pattern could be applied to other dynamic scope types if added
- Label truncation logic could be enhanced for very long workspace names