Skip to content

Conversation

@Subash-Mohan
Copy link
Contributor

@Subash-Mohan Subash-Mohan commented Oct 23, 2025

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

  • [Optional] Override Linear Check

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

    • Prevent adding files that are uploading or deleting (DAN-2887, DAN-2888).
    • Remove failed optimistic uploads across recent, message, and project lists to avoid stuck files (DAN-2888).
    • Clear popups: “Unsupported file types” and “Files too large” (DAN-2887).
    • Long file names now truncate correctly in the Add Files modal (DAN-2886).
  • UI Improvements

    • Show image/document icons based on file extension via FileTypeIcon (DAN-2887).
    • Sidebar actions appear on hover; show “New Project” only when there are no projects (DAN-2901).
    • Consistent icon button styling in file lists (DAN-2767).

@Subash-Mohan Subash-Mohan requested a review from a team as a code owner October 23, 2025 12:49
@vercel
Copy link

vercel bot commented Oct 23, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
internal-search Ready Ready Preview Comment Oct 23, 2025 0:53am

Copy link
Contributor

@greptile-apps greptile-apps bot left a 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 removeOptimisticFilesByTempIds function 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 new FileTypeIcon component 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
Loading

8 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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

@raunakab raunakab self-requested a review October 27, 2025 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants