Skip to content

feat: New multi chat deletion feature - #2208

Merged
Vchen7629 merged 12 commits into
mainfrom
chat-multi-delete-feature
Aug 10, 2026
Merged

feat: New multi chat deletion feature#2208
Vchen7629 merged 12 commits into
mainfrom
chat-multi-delete-feature

Conversation

@Vchen7629

@Vchen7629 Vchen7629 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1465 , This pr adds a new multi-chat deletion feature to openrag. Users can select one, multiple, or all their existing chats by clicking the new select button next to the new chat button (+).

Demo

screen-capture.15.webm

Summary by CodeRabbit

  • New Features

    • Added bulk chat deletion with multi-select, select-all, and selected-chat counts.
    • Added selection-mode controls, loading states, and success or partial-failure notifications.
    • Unauthorized or unsuccessful deletions are reported without blocking other selected chats.
    • Added safeguards for empty selections, duplicate selections, and oversized deletion requests.
    • Automatically starts a fresh conversation when all chats are deleted.
  • Tests

    • Added coverage for selected-chat deletion, deleting all chats, authorization, validation, duplicate selections, and partial failures.

@github-actions github-actions Bot added frontend 🟨 Issues related to the UI/UX backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) tests labels Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Bulk chat deletion now spans frontend selection, the DELETE /sessions API, best-effort service deletion, and automated coverage.

Changes

Bulk chat deletion

Layer / File(s) Summary
Backend deletion contract and routing
src/api/chat.py, src/app/routes/internal.py
Adds the bulk request model, 100-session limit, authenticated endpoint, result responses, and DELETE /sessions.
Best-effort service deletion
src/services/chat_service.py
Deduplicates session IDs, checks ownership, deletes sessions independently, and returns separate deleted and failed lists.
Frontend selection and deletion flow
frontend/hooks/useChatSelection.tsx, frontend/app/api/mutations/useBulkDeleteSessionsMutation.ts, frontend/components/navigation.tsx, frontend/components/bulk-delete-button.tsx, frontend/components/chat-renderer.tsx
Adds selection mode, select-all and per-conversation controls, bulk deletion handling, query invalidation, and a selection overlay.
Bulk deletion validation
tests/unit/api/test_bulk_delete_sessions_endpoint.py, tests/unit/test_chat_service_bulk_delete.py, frontend/tests/pages/Chat.ts, frontend/tests/core/bulk_delete_chats.spec.ts
Tests request validation, ownership filtering, partial results, exception handling, and deletion of selected or all conversations.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Navigation
  participant useBulkDeleteSessionsMutation
  participant bulk_delete_sessions_endpoint
  participant ChatService
  User->>Navigation: Select conversations
  Navigation->>useBulkDeleteSessionsMutation: Submit selected session IDs
  useBulkDeleteSessionsMutation->>bulk_delete_sessions_endpoint: DELETE /sessions
  bulk_delete_sessions_endpoint->>ChatService: Delete authorized sessions
  ChatService-->>bulk_delete_sessions_endpoint: Return deleted and failed IDs
  bulk_delete_sessions_endpoint-->>useBulkDeleteSessionsMutation: Return deletion result
  useBulkDeleteSessionsMutation-->>Navigation: Invalidate conversation queries
  Navigation-->>User: Show result and update conversation list
Loading

Suggested reviewers: mfortman11, lucaseduoli

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: a new multi-chat deletion feature.
Linked Issues check ✅ Passed The PR implements the bulk chat selection and deletion flow requested in issue #1465, including frontend, backend, and tests.
Out of Scope Changes check ✅ Passed All code and test changes support the bulk chat deletion feature described in issue #1465.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chat-multi-delete-feature

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the enhancement 🔵 New feature or request label Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit ce3dc65.

@github-actions github-actions Bot added enhancement 🔵 New feature or request and removed enhancement 🔵 New feature or request labels Aug 5, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
src/app/routes/internal.py (1)

210-215: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Declare a typed response for DELETE /sessions.

bulk_delete_sessions_endpoint returns JSONResponse({"deleted": ..., "failed": ...}), while the route registration omits response_model. Add a BulkDeleteSessionsResponse/alias and register it on app.add_api_route so the success payload shape is part of the API contract and OpenAPI docs.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/app/routes/internal.py` around lines 210 - 215, Define or reuse a typed
BulkDeleteSessionsResponse model/alias matching the deleted and failed fields
returned by bulk_delete_sessions_endpoint, then pass it as response_model in the
app.add_api_route registration for DELETE /sessions so the success payload is
reflected in the API contract and OpenAPI schema.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/components/navigation.tsx`:
- Line 450: Correct the data-testid on the selection-toggle element in the
navigation component from the misspelled value to "chat-select-toggle" so it
matches the selector expected by Chat page tests and enables selection mode.

In `@src/api/chat.py`:
- Around line 55-56: Update BulkDeleteBody validation for session_ids to reject
duplicate IDs with a 400 response, or deduplicate the IDs before ownership
filtering and delete_sessions processing. Ensure each session is deleted at most
once.
- Around line 241-266: The bulk-delete business logic currently resides in the
route handler. Move ownership filtering and deletion result aggregation from the
handler into ChatService or another service resolved through the dependency path
defined in src/dependencies.py, removing the direct session_ownership_service
import. Keep the handler limited to validating/parsing the request, invoking the
injected service, and mapping its result to the HTTP response.

In `@tests/unit/api/test_bulk_delete_sessions_endpoint.py`:
- Around line 38-41: Remove the unused type: ignore comments from the test setup
and response parsing around the user argument, json.loads(resp.body), and the
corresponding line near the later test case. Leave the test behavior unchanged
and ensure no unnecessary suppression remains.

---

Nitpick comments:
In `@src/app/routes/internal.py`:
- Around line 210-215: Define or reuse a typed BulkDeleteSessionsResponse
model/alias matching the deleted and failed fields returned by
bulk_delete_sessions_endpoint, then pass it as response_model in the
app.add_api_route registration for DELETE /sessions so the success payload is
reflected in the API contract and OpenAPI schema.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1ea05181-d408-49ef-98e4-d509c75ff5b6

📥 Commits

Reviewing files that changed from the base of the PR and between 36a187d and 6f63bd2.

📒 Files selected for processing (12)
  • frontend/app/api/mutations/useBulkDeleteSessionsMutation.ts
  • frontend/components/bulk-delete-button.tsx
  • frontend/components/chat-renderer.tsx
  • frontend/components/navigation.tsx
  • frontend/hooks/useChatSelection.tsx
  • frontend/tests/core/bulk_delete_chats.spec.ts
  • frontend/tests/pages/Chat.ts
  • src/api/chat.py
  • src/app/routes/internal.py
  • src/services/chat_service.py
  • tests/unit/api/test_bulk_delete_sessions_endpoint.py
  • tests/unit/test_chat_service_bulk_delete.py

Comment thread frontend/components/navigation.tsx Outdated
Comment thread src/api/chat.py
Comment thread src/api/chat.py Outdated
Comment thread tests/unit/api/test_bulk_delete_sessions_endpoint.py Outdated
@github-actions github-actions Bot added enhancement 🔵 New feature or request and removed enhancement 🔵 New feature or request labels Aug 5, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
frontend/components/navigation.tsx (2)

166-177: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Route the empty-list fallback through handleNewConversation().

If bulk deletion removes the current conversation and no conversations remain, Lines 175-176 call startNewConversation() directly. The centralized handleNewConversation() path preserves onNewConversation, refreshConversations, and the newConversation event. The bulk path skips these updates, so parent state or listeners can remain stale after deleting all chats.

Proposed fix
         } else {
           setCurrentConversationId(null);
-          startNewConversation();
+          handleNewConversation();
         }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/components/navigation.tsx` around lines 166 - 177, Update the
empty-list branch in the bulk deletion logic to call handleNewConversation()
instead of startNewConversation(), while preserving the currentConversationId
reset. Keep the remaining-conversation path unchanged so the centralized
new-conversation flow updates parent state, refreshes conversations, and emits
the expected event.

581-606: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Do not nest the checkbox inside the conversation button.

<button> is invalid ancestor markup for the nested interactive checkbox descendant. Move the checkbox and conversation title/actions out as sibling controls, or replace the wrapper with a non-interactive container. Test keyboard navigation and screen-reader behavior after the change.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/components/navigation.tsx` around lines 581 - 606, The conversation
checkbox is nested inside the clickable conversation button, creating invalid
interactive markup and inaccessible keyboard behavior. Update the conversation
item around the selection checkbox and `loadConversation` handler so the
checkbox and conversation title/actions are sibling controls, or use a
non-interactive container while preserving their current selection and loading
behavior; verify keyboard navigation and screen-reader semantics.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@frontend/components/navigation.tsx`:
- Around line 166-177: Update the empty-list branch in the bulk deletion logic
to call handleNewConversation() instead of startNewConversation(), while
preserving the currentConversationId reset. Keep the remaining-conversation path
unchanged so the centralized new-conversation flow updates parent state,
refreshes conversations, and emits the expected event.
- Around line 581-606: The conversation checkbox is nested inside the clickable
conversation button, creating invalid interactive markup and inaccessible
keyboard behavior. Update the conversation item around the selection checkbox
and `loadConversation` handler so the checkbox and conversation title/actions
are sibling controls, or use a non-interactive container while preserving their
current selection and loading behavior; verify keyboard navigation and
screen-reader semantics.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: cfc1a07f-1122-4b8e-b2b9-272df6c77325

📥 Commits

Reviewing files that changed from the base of the PR and between 6f63bd2 and d020f28.

📒 Files selected for processing (2)
  • frontend/components/navigation.tsx
  • frontend/hooks/useChatSelection.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/hooks/useChatSelection.tsx

@github-actions github-actions Bot added enhancement 🔵 New feature or request and removed enhancement 🔵 New feature or request labels Aug 5, 2026
@github-actions github-actions Bot removed the enhancement 🔵 New feature or request label Aug 5, 2026
@github-actions github-actions Bot added enhancement 🔵 New feature or request and removed enhancement 🔵 New feature or request labels Aug 5, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/unit/test_chat_service_bulk_delete.py (1)

69-77: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a test for continuation after an exception.

The test at Line 75 passes one session ID. It verifies failure conversion, but it does not verify that a later session is still processed. Add a second owned ID and assert both result lists and both deletion calls. This validates the best-effort loop in src/services/chat_service.py, Lines 940-968.

Proposed test extension
-    _patch_owner(monkeypatch, {"x": "alice"})
-    svc.delete_session = AsyncMock(side_effect=RuntimeError("boom"))
+    _patch_owner(monkeypatch, {"x": "alice", "y": "alice"})
+    svc.delete_session = AsyncMock(
+        side_effect=[RuntimeError("boom"), {"success": True, "error": None}]
+    )

-    result = await svc.delete_sessions("alice", ["x"])
+    result = await svc.delete_sessions("alice", ["x", "y"])

-    assert result == {"deleted": [], "failed": ["x"]}
+    assert result == {"deleted": ["y"], "failed": ["x"]}
+    assert svc.delete_session.await_count == 2
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/test_chat_service_bulk_delete.py` around lines 69 - 77, Extend
test_bulk_delete_never_raises_on_error with a second owned session ID, configure
the mock to fail for the first deletion while allowing the second to complete,
and assert the result contains the first ID in failed and the second in deleted.
Also verify delete_session was called for both IDs, confirming delete_sessions
continues processing after an exception.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/unit/test_chat_service_bulk_delete.py`:
- Around line 69-77: Extend test_bulk_delete_never_raises_on_error with a second
owned session ID, configure the mock to fail for the first deletion while
allowing the second to complete, and assert the result contains the first ID in
failed and the second in deleted. Also verify delete_session was called for both
IDs, confirming delete_sessions continues processing after an exception.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fede0c21-2e6f-4e63-a3e6-096f568a3685

📥 Commits

Reviewing files that changed from the base of the PR and between d020f28 and f1b944c.

📒 Files selected for processing (6)
  • frontend/components/navigation.tsx
  • frontend/hooks/useChatSelection.tsx
  • src/api/chat.py
  • src/services/chat_service.py
  • tests/unit/api/test_bulk_delete_sessions_endpoint.py
  • tests/unit/test_chat_service_bulk_delete.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/services/chat_service.py
  • frontend/hooks/useChatSelection.tsx
  • src/api/chat.py
  • frontend/components/navigation.tsx

@VisveshJ VisveshJ self-assigned this Aug 5, 2026
@VisveshJ
VisveshJ self-requested a review August 5, 2026 17:16

@VisveshJ VisveshJ left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good feature! was able to delete multiple chats and preserve some that id like to keep

@github-actions github-actions Bot added lgtm enhancement 🔵 New feature or request and removed enhancement 🔵 New feature or request labels Aug 5, 2026
@github-actions github-actions Bot added enhancement 🔵 New feature or request and removed enhancement 🔵 New feature or request labels Aug 5, 2026
@Vchen7629
Vchen7629 force-pushed the chat-multi-delete-feature branch from 648571a to ce3dc65 Compare August 6, 2026 00:45
@github-actions github-actions Bot added enhancement 🔵 New feature or request and removed enhancement 🔵 New feature or request labels Aug 6, 2026
@Vchen7629
Vchen7629 merged commit 7c8d5f5 into main Aug 10, 2026
36 checks passed
@github-actions
github-actions Bot deleted the chat-multi-delete-feature branch August 10, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) enhancement 🔵 New feature or request frontend 🟨 Issues related to the UI/UX lgtm tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Delete of multiple chats

2 participants