Skip to content

[Feature] : Add Recycle Bin (Trash / Restore Flow)#544

Closed
hrshjswniii wants to merge 6 commits into
param20h:devfrom
hrshjswniii:feature/Recycle-Bin
Closed

[Feature] : Add Recycle Bin (Trash / Restore Flow)#544
hrshjswniii wants to merge 6 commits into
param20h:devfrom
hrshjswniii:feature/Recycle-Bin

Conversation

@hrshjswniii

Copy link
Copy Markdown
Contributor

🔗 Related Issue


Closes #541



📝 What does this PR do?


This PR implements a dedicated Recycle Bin (Trash / Restore) workflow to allow users to view, restore, or permanently purge their soft-deleted documents:

  1. New API Endpoints:
    • GET /api/v1/documents/trash: Lists all soft-deleted documents (is_deleted == True) belonging to the user or their active workspaces.
    • POST /api/v1/documents/{document_id}/restore: Restores a soft-deleted document by resetting is_deleted = False and deleted_at = None.
    • DELETE /api/v1/documents/{document_id}/purge: Immediately and permanently deletes the document's database record, physical uploads, vector chunks, and knowledge graph files.
  2. Background Cleanup Integration:
    • Updated the daily cleanup_old_deleted_documents job to also purge knowledge graph files (delete_graph) of documents in trash for over 30 days.
  3. Frontend UI Components:
    • Added a new TrashModal.tsx displaying trashed documents with options to restore or permanently purge them.
    • Integrated the Recycle Bin entry point inside DocumentSidebar.tsx as a trash button next to the "Documents" header.
  4. Testing:
    • Created unit tests covering the new /trash, /restore, and /purge routes inside tests/test_documents.py.


🗂️ Type of Change


  • 🐛 Bug fix
  • ✨ New feature
  • 🔧 Refactor / code cleanup
  • 📝 Documentation update
  • 🎨 UI / styling change
  • ⚙️ CI / tooling / config change
  • 🧪 Tests


🧪 How was this tested?


  • Tested the affected API endpoints manually
  • Added / updated tests (All 13 backend document tests passed successfully)
  • Ran frontend local typecheck (npx tsc --noEmit completed with no compilation errors)


⚠️ Anything to flag for reviewers?


The new route GET /api/v1/documents/trash has been registered before GET /api/v1/documents/{document_id} in backend/app/routes/documents.py to prevent route matching conflicts where FastAPI would treat /trash as a document ID.



✅ Self-Review Checklist


  • My branch is based on dev, not main
  • I have not added any secrets / API keys
  • I have not modified main branch or any HuggingFace deployment config
  • My code follows the existing style (no unnecessary formatting changes)
  • I have updated relevant docs / comments if needed

@hrshjswniii hrshjswniii requested a review from param20h as a code owner June 9, 2026 19:36
@param20h

Copy link
Copy Markdown
Owner

✅ This PR has been merged directly into dev by maintainer.

@param20h param20h closed this Jun 28, 2026
@param20h param20h added level:intermediate +35 pts mentor:param20h Mentor for this PR gssoc:approved Approved for GSSoC base points (+50 pts) labels Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved Approved for GSSoC base points (+50 pts) level:intermediate +35 pts mentor:param20h Mentor for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] : Recycle Bin (Trash / Restore Flow)

2 participants