Merged
Conversation
Add full message edit capability with append-only version history.
DB: new message_edits table, edited_at + edit_version columns on messages,
FTS5 update trigger (DELETE+INSERT) to keep search index in sync.
CRUD: msg_edit validates author/system-only permission, no-op guard, content
filter, FTS5 sync, SSE msg.edit event. msg_edit_history returns all versions
ordered by version ASC. _row_to_message updated for new fields.
MCP: msg_edit + msg_edit_history tools. edited_by deduced via
get_connection_agent. handle_msg_get now includes edited_at/edit_version.
REST: PUT /api/messages/{id} (trust-the-caller, no auth until SEC-JWT-01) +
GET /api/messages/{id}/history. GET messages response now includes edited_at
and edit_version on every message.
Web UI: edit button (pencil, hover-reveal) on every bubble, inline editing
(textarea + Save/Cancel), edited indicator (dotted underline, clickable),
history modal listing all previous versions, SSE msg.edit handler for
real-time in-place bubble update.
Tests: 16 unit (in-memory), 6 integration (REST), 16 Vitest (jsdom). All pass.
…auth Backend: crud.msg_edit now raises PermissionError when msg.role == 'system'. System events/prompts can never be edited regardless of edited_by. UI: appendBubble conditionally renders edit button only when !isSystem. Tests: add test_msg_edit_system_role_cannot_be_edited (pytest) + 'system message row has no edit button' (vitest). Fix integration test _create_thread_and_message: add X-Agent-Token header (POST /api/threads and POST /api/messages) and use msg.author display name as edited_by.
AcbMsgEditCancel was called after a successful save, which restored the original bubble content from dataset.originalContent, overwriting the freshly rendered new text. Fix: instead of calling cancel, inline the cleanup (remove msg-editing class, re-enable edit button, clear dataset) so the new content rendered by AcbMessageRenderer is preserved. Test: add assertion that bubble.textContent === 'new text' after save.
e45e9b6 to
cf69034
Compare
…eption tests
- Add _runtime_diag_payload() to src/main.py (missing after rebase from origin/main)
- Import DB_PATH from config (required by _runtime_diag_payload)
- Update /api/threads/{id}/agents endpoint to return structured 404/503 with diagnostics
(was lost during conflict resolution, fixes test_thread_agents_not_found_includes_runtime_diagnostics)
- Replace pytest.raises() with explicit try/except in async unit tests for custom exceptions
(pytest.raises() has inconsistent behavior with pytest-asyncio 1.3.0 on Linux for custom exceptions)
… clauses Avoids class identity mismatch caused by Python's editable install (pip install -e .) loading src.db.crud as two distinct module objects on Linux when the package is installed. Using except crud.MessageEditNoChangeError / crud.MessageNotFoundError guarantees both the raise and the except reference the exact same class object. Also removes the now-unused direct imports of MessageEditNoChangeError / MessageNotFoundError.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
Backend
Frontend
Tests
Test plan