Conversation
a30870a to
879388d
Compare
…, mark-as-read endpoint
Add unread message tracking infrastructure for chat sessions:
- Add last_read_at DATETIME NULL column to datamachine_chat_sessions (dbDelta + ensure migration)
- Add count_unread() helper — counts visible assistant messages with metadata.timestamp > last_read_at
- Add mark_session_read() method — sets last_read_at = NOW() where session_id and user_id match
- Add unread_count to get_user_sessions() return shape
- Add last_read_at to single session GET response (via GetChatSessionAbility)
- Register datamachine/mark-session-read ability
- Add POST /datamachine/v1/chat/sessions/{session_id}/read REST endpoint (uses execute_ability pattern)
Closes #997
879388d to
566ff82
Compare
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
Add backend infrastructure for tracking unread messages per chat session. This enables unread badges on any frontend with cross-device sync.
last_read_at DATETIME NULLcolumn todatamachine_chat_sessionsvia dbDelta +ensure_last_read_at_column()migration safety netcount_unread()helper — counts visible assistant messages withmetadata.timestamp > last_read_atmark_session_read()method — setslast_read_at = NOW()where session_id and user_id matchunread_counttoget_user_sessions()return shapelast_read_atto single session GET responsedatamachine/mark-session-readability (delegates tomark_session_read())POST /datamachine/v1/chat/sessions/{session_id}/readREST endpointCloses #997
Dependency chain: This is step 1 of 3. The chat package (Extra-Chill/chat#16) and frontend-chat plugin (Extra-Chill/data-machine-frontend-chat#4) depend on this.