Skip to content

feat: add unread messages backend#998

Merged
chubes4 merged 1 commit intomainfrom
feat/unread-messages
Mar 30, 2026
Merged

feat: add unread messages backend#998
chubes4 merged 1 commit intomainfrom
feat/unread-messages

Conversation

@chubes4
Copy link
Copy Markdown
Member

@chubes4 chubes4 commented Mar 30, 2026

Summary

Add backend infrastructure for tracking unread messages per chat session. This enables unread badges on any frontend with cross-device sync.

  • Add last_read_at DATETIME NULL column to datamachine_chat_sessions via dbDelta + ensure_last_read_at_column() migration safety net
  • 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
  • Register datamachine/mark-session-read ability (delegates to mark_session_read())
  • Add POST /datamachine/v1/chat/sessions/{session_id}/read REST endpoint

Closes #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.

…, 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
@chubes4 chubes4 force-pushed the feat/unread-messages branch from 879388d to 566ff82 Compare March 30, 2026 16:06
@chubes4 chubes4 merged commit c1e2ad8 into main Mar 30, 2026
1 check failed
@chubes4 chubes4 deleted the feat/unread-messages branch March 30, 2026 16:06
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.

feat: Unread messages — last_read_at on sessions, unread_count in list, mark-as-read endpoint

1 participant