Skip to content

feat: add message deletion from a session thread (#287)#395

Open
anandsundaramoorthysa wants to merge 1 commit into
imDarshanGK:mainfrom
anandsundaramoorthysa:feat/287-delete-message
Open

feat: add message deletion from a session thread (#287)#395
anandsundaramoorthysa wants to merge 1 commit into
imDarshanGK:mainfrom
anandsundaramoorthysa:feat/287-delete-message

Conversation

@anandsundaramoorthysa

Copy link
Copy Markdown

Description

Adds the ability to delete a single message from a session thread. Previously the app could only "clear all messages" in a session — there was no way to remove one message.

Closes #287

Changes

Backend

  • db_service.delete_message(session_id, message_id) — session-scoped delete (a message can only be removed from its own thread) that also decrements the session's message_count (clamped at 0).
  • get_messages_full now returns each message's id, so the client can target a specific message (it previously omitted the id).
  • New route: DELETE /api/sessions/{session_id}/messages/{message_id}404 when the message doesn't exist in that session.
  • Tests: test_delete_single_message and test_delete_message_not_found.

Frontend

  • api.deleteMessage(sessionId, messageId).
  • Use the real message id from the backend instead of the array index (so deletes target the correct row).
  • ChatWindow: a delete control on every message (user and assistant) with a lightweight inline "Delete? Yes / No" confirm (no window.confirm, consistent with the project's move away from native dialogs), and optimistic removal for instant feedback.

Verification

  • Full pytest suite passes — 73 tests (including the 2 new ones).
  • Live end-to-end check: seeded a session with 3 messages, deleted one from the UI → it was removed from the thread and from the database, and the sidebar message count stayed in sync (3 → 2). The remaining messages and other sessions were untouched.

Notes

  • The delete is scoped by session_id, so a crafted request can't delete another session's message.
  • Optimistic UI removal means freshly-streamed (not-yet-persisted) messages are also removed cleanly from the view.

Adds the ability to delete a single message from a chat thread (previously
only "clear all messages" existed).

Backend:
- db_service.delete_message(session_id, message_id): session-scoped delete
  that also decrements the session's message_count (clamped at 0)
- get_messages_full now returns each message's id so the client can target
  a specific message
- DELETE /api/sessions/{session_id}/messages/{message_id} route (404 when
  the message doesn't exist in the session)
- Tests: test_delete_single_message and test_delete_message_not_found

Frontend:
- api.deleteMessage(sessionId, messageId)
- Use the real message id from the backend (instead of the array index)
- ChatWindow: a delete control on each message with a lightweight inline
  "Delete? Yes/No" confirm (no window.confirm), with optimistic removal

Verified: full pytest suite passes (73 tests) and a live end-to-end check
(delete a message in the UI -> removed from the thread and the DB, with the
sidebar count kept in sync).
@vercel

vercel Bot commented Jun 13, 2026

Copy link
Copy Markdown

@anandsundaramoorthysa is attempting to deploy a commit to the Darshan's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Add message deletion from a session thread

1 participant