-
Notifications
You must be signed in to change notification settings - Fork 4
Refactor Mailbox Schema #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
pheller
commented
Sep 8, 2025
- cache list of message ids in session on client entry to mailbox (when mailbox page 1 is retrieved)
- client message indexes are offsets into this cached list
- if client leaves and comes back to mailbox, client requests page 1 again, refreshing the cache
b0c30ce to
67935c8
Compare
- cache list of message ids in session on client entry to mailbox (when mailbox page 1 is retrieved) - client message indexes are offsets into this cached list - if client leaves and comes back to mailbox, client requests page 1 again, refreshing the cache
67935c8 to
de273ce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the mailbox schema to address session-based message indexing. The key change is moving from database-stored sequential indexes to session-cached message IDs, allowing client message indexes to be offsets into a cached list that refreshes when entering the mailbox.
- Replaces composite primary key (to_id, index) with auto-incrementing id field in messages
- Implements session-based message ID caching that loads on mailbox page 1 requests
- Updates message operations to use client indices as offsets into the cached message ID list
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/server/lib/prodigy/server/session.ex | Adds messaging field to session struct for caching message IDs |
| apps/server/lib/prodigy/server/service/messaging.ex | Core refactor implementing session-based indexing and message ID caching |
| apps/core/lib/prodigy/core/data/message.ex | Removes composite primary key and index field from Message schema |
| apps/core/priv/repo/migrations/20250907183440_fix_message_ids.exs | Database migration to replace composite key with auto-incrementing id |
| apps/server/test/prodigy/server/service/messaging_test.exs | Updates tests to reflect new client indexing behavior and verify correct message operations |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
apps/core/priv/repo/migrations/20250907183440_fix_message_ids.exs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
apps/server/lib/prodigy/server/service/messaging.ex:1
- The pattern match
_ ->catches all non-{:ok, payload} responses including errors, but always returns{:ok, session}. This could mask actual errors. Consider explicitly handling:okresponses and error cases separately.
# Copyright 2022, Phillip Heller
apps/server/lib/prodigy/server/service/messaging.ex:344
- The unhandled case returns
{:ok, <<0>>}but should return{session, {:ok, <<0>>}}to match the expected tuple format used throughout the function.
Logger.warn(
"unhandled messaging request: #{inspect(request, base: :hex, limit: :infinity)}"
)
{:ok, <<0>>}
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.