Skip to content

Chat: edit, delete, moderation and reply with a quote (#95) - #104

Merged
finn6698 merged 1 commit into
mainfrom
feat/chat-edit-delete
Oct 29, 2026
Merged

finn6698 merged 1 commit into
mainfrom
feat/chat-edit-delete

Conversation

@Oceandek

Copy link
Copy Markdown
Collaborator

Closes #95 (spec #91).

What's new

  • Message menu (⋮ on every message in a writable chat): Reply for everyone, Edit on your own messages, Delete on your own, and on every message for Teachers and the Superuser (moderation). Students get 403 on others' messages.
  • Edit: a dialog with the text; the message then shows "(edited)". Only the author can edit, never staff.
  • Delete: after a confirmation, the text and the files are removed (rows and files on the volume); the row stays as "This message was deleted.". A deleted message is never Unread, can't be edited, replied to or deleted again (409/422).
  • Reply with a quote: "Replying to : " above the send box (× to stop); the reply shows the quoted author and first line (or the first file's name) with a red line, and clicking it scrolls to the original. A quote of a deleted message says "This message was deleted.". Replies only within the same chat (422).
  • Live: every change gets a new number from the chat_revision sequence; an open chat now asks for everything changed since the last number it saw, so edits and deletions appear within ~2 s. Changing or deleting a message also renumbers the replies quoting it, so their quotes update too. ADR 0008 updated.
  • Migration 0017: reply_to_id (SET NULL), edited_at, deleted_at, revision (existing messages numbered in order; checked locally by downgrading to 0016 with messages and upgrading). CONTEXT.md: Reply, Deleted message; changelog row.

API

PUT /api/chat/messages/{id} (author), DELETE /api/chat/messages/{id} (author or staff), reply_to_id form field on send. GET .../chat/messages takes since (a revision) instead of after (a message id); messages get revision, edited, deleted, reply_to {id, author_name, first_line, deleted}, can_edit, can_delete.

Also fixed

An open chat moved its "last seen" mark to your own just-sent message, so a message someone else sent a moment earlier could be skipped until the page was reloaded. Now only what a poll fetched moves the mark.

Tests

  • Backend 352 passed; new test_chat_edit_delete.py (edit own + live via since, nobody edits others', delete own incl. files and Unread, staff delete any / Student only own, outsiders and archived chats, reply quote, quote of a deleted message, replies only in the same chat).
  • Frontend 109 passed; new test_chat_edit_delete.py (reply with a quote, edit and delete your own, others' edits and deletions appear live, a Teacher deletes a Student's message and the quote says so).

🤖 Generated with Claude Code

Authors edit ("(edited)") and delete ("This message was deleted.", files
too) their own messages; Teachers and the Superuser delete any. Replies quote
the original and scroll to it. Open chats poll for changes since a revision,
so edits and deletions appear live.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@finn6698
finn6698 merged commit c8f95c0 into main Oct 29, 2026
2 checks passed
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.

Chat: edit, delete, moderation and reply with a quote

2 participants