-
Couldn't load subscription status.
- Fork 2.1k
fix(Projects): small bugs #5875
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
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
74266e2 to
c54752e
Compare
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
Greptile Summary
This PR addresses several small but important bugs in the Projects feature related to file handling and UI polish. The changes improve the user experience by preventing invalid operations, cleaning up failed uploads properly, and providing clearer visual feedback.
Key improvements:
- Prevents adding files that are currently being uploaded or deleted (prevents race conditions)
- Properly removes failed optimistic file uploads from all UI lists (fixes stuck files in UI)
- Shows accurate file type icons (image vs document) based on file extension
- Improves error messages for file upload failures ("Unsupported file types" vs "Files too large")
- Adds hover-only visibility for Projects section action button in sidebar
- Shows "New Project" button only when no projects exist (cleaner empty state)
- Fixes long filename truncation in modals
Technical approach:
The PR extracts a new removeOptimisticFilesByTempIds helper function in ProjectsContext.tsx to centralize the cleanup logic for failed uploads. This ensures optimistic files are removed consistently from all three locations: recent files list, current message files, and project files. The function is called both when files fail validation (unsupported/too large) and when the upload request fails entirely.
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- All changes are well-contained bug fixes and UI improvements. The extracted
removeOptimisticFilesByTempIdsfunction improves code maintainability by centralizing cleanup logic. The validation added to prevent adding files during upload/delete prevents race conditions. Error messages are clearer and more actionable. The newFileTypeIconcomponent follows good component design practices and is properly integrated across all usage sites. No breaking changes, no risky refactoring, and changes align with the project's coding standards. - No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| web/src/app/chat/components/files/FileTypeIcon.tsx | 5/5 | New component extracting file type icon logic - clean implementation |
| web/src/app/chat/components/projects/ProjectContextPanel.tsx | 5/5 | Added validation to prevent adding files that are being uploaded/deleted, using FileTypeIcon |
| web/src/app/chat/projects/ProjectsContext.tsx | 4/5 | Extracted removeOptimisticFilesByTempIds to cleanup failed uploads, improved error messages |
Sequence Diagram
sequenceDiagram
participant User
participant FilePicker
participant ProjectContextPanel
participant ProjectsContext
participant API
User->>FilePicker: Select file to add
FilePicker->>ProjectContextPanel: onPickRecent(file)
ProjectContextPanel->>ProjectContextPanel: Check file.status
alt File is UPLOADING or DELETING
ProjectContextPanel->>User: Show warning popup
else File is ready
ProjectContextPanel->>ProjectsContext: linkFileToProject(projectId, file)
ProjectsContext->>API: Link file to project
API-->>ProjectsContext: Success
ProjectsContext-->>User: File added
end
User->>FilePicker: Upload new files
FilePicker->>ProjectsContext: beginUpload(files)
ProjectsContext->>ProjectsContext: Create optimistic files
ProjectsContext->>User: Show optimistic UI
ProjectsContext->>API: Upload files
alt Upload succeeds
API-->>ProjectsContext: Return uploaded files
ProjectsContext->>ProjectsContext: Map temp_id to real files
alt Some files unsupported/too large
ProjectsContext->>ProjectsContext: removeOptimisticFilesByTempIds
ProjectsContext->>User: Show warning with details
end
else Upload fails
API-->>ProjectsContext: Error
ProjectsContext->>ProjectsContext: removeOptimisticFilesByTempIds
ProjectsContext->>User: Show error popup
end
8 files reviewed, no comments
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 8 files
Description
This pull request introduces several improvements to file handling and UI components, focusing on better file type representation.
PR links:
https://linear.app/danswer/issue/DAN-2767/button-in-button-should-follow-the-project-standard-of-having-a-white
https://linear.app/danswer/issue/DAN-2901/projects-sidebar-look
https://linear.app/danswer/issue/DAN-2887/add-files-modal-issues
https://linear.app/danswer/issue/DAN-2886/long-file-names-should-do-instead-of-just-truncating
https://linear.app/danswer/issue/DAN-2888/files-dont-delete
How Has This Been Tested?
Tested from UI
Additional Options
Summary by cubic
Fixes multiple small issues in Projects to make file handling safer and the sidebar cleaner. Improves clarity with accurate file icons, better error messages, and more predictable actions.
Bug Fixes
UI Improvements