Skip to content

feat: group the inbox into conversations - #326

Merged
Yoshiofthewire merged 7 commits into
mainfrom
feat/conversations
Nov 19, 2026
Merged

Yoshiofthewire merged 7 commits into
mainfrom
feat/conversations

Conversation

@Yoshiofthewire

@Yoshiofthewire Yoshiofthewire commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Part of #324 (part 2: conversation view. Send delay and reply identity are separate PRs.)

In one line: The inbox groups replies into conversations, the same way KyPost on the web does, and a list action on a conversation acts on all of its messages in that folder.

What changed

  • While the user's conversations setting is on (the default), each folder refresh also calls GET /api/inbox/conversations. Rows that belong together collapse into one row, which shows its senders and message count, e.g. "Ana, me (3)". Search results are never grouped.
  • Tapping a conversation expands it in place. Its messages are listed oldest first, your replies in Sent included, and tapping one opens it in the reader. Reader actions still act on that one message.
  • Swipe archive and delete, the accessibility actions and bulk selection (archive, move, junk, delete, snooze, mark read or unread) on a conversation row act on every loaded member in this folder. Your replies in Sent are never touched. A large selection is split into requests of at most MAX_ACTION_IDS messages.
  • A new Settings row, Conversations, writes PUT /api/settings/mail and shows only what the server confirms.
  • Older servers without the route, or a failed fetch, keep the last grouping (or none). Nothing is toasted and /api/inbox and Room are unchanged.

⚠️ Server gap: the setting does not reach the server from a paired device today. KyPost-Server registers GET|PUT /api/settings/mail with withAuth (session cookie only), not withMailAuth (backend/internal/api/server.go lines 727-728 on main). A paired device gets 401 there. Until the server accepts device credentials on that route:

  • the app keeps its last value, which is the default on, so a user who turned conversations off on the web still sees grouping on Android;
  • the Settings row says "Couldn't change this from the app. You can change it in KyPost on the web, under Settings, Mail." It never words that 401 as "re-pair".
    The client already follows the documented contract, so it starts working without an app change once the server switches those two routes to withMailAuth.

Review this

  • InboxActivity.kt actOnRow and the bulk chosen expansion and L1037. This is what turns one swipe into an action on several messages. The membership must stay limited to this folder's rows.
  • groupInboxRows builds members from the whole folder, not just the visible keyword tab, so an action covers the whole conversation.
  • Safe to skip: the EmailAdapter changes (it now takes InboxRow, and DiffUtil keys on (nested, folder, id)).

Checked: the repository's required checks all pass locally (commands below). There are new unit tests and one new instrumentation test.
My mistake, fixed: the first CI emulator run crashed on opening Settings (ContactSyncConsentTest). applyListRowTheme expects every settings row to end with a chevron, and my new row had none. The fix (second commit) adds it. Local checks cannot catch this because they do not open the screen.
Not checked: I did not run the instrumentation tests: the Android emulator segfaults on Major, so GitHub CI's emulator jobs run them. Nothing was tested against a live server; I followed the documented contract and server main.

Decided for you

  • Opening a conversation expands it in the list. There is no separate conversation screen.
  • Nested message rows only open the reader: they do not swipe or select.
  • The setting is read once per inbox foreground and when Settings opens. The last value read is kept in MailSettings (SharedPreferences).

You need to: decide on the server fix for /api/settings/mail device auth (see above). Nothing else.

Detail

By area

  • Relay (RelayMailSource, RelayModels): fetchConversations streams the response. Each sent row is decoded on its own and needs a mailbox and messageId; a bad row drops only itself, and empty groups are dropped. limit is clamped to 1..500. mailSettings GET/PUT builds the PUT body by hand because encodeDefaults is off, so true is always written. A string "false" is refused, not taken as off.
  • MailSource: three new methods, each with a default body, so test fakes are unchanged.
  • Inbox: conversationsByFolder, expandedConversations (cleared on folder switch) and conversationMembers (lead row key to its members). limit is the number of rows cached for the folder.
  • Settings: a list row (settingsConversations) in settings_rows.xml, so both layouts get it.
  • Docs: app/src/main/AGENTS.md (contract, including the server gap), the app/AGENTS.md endpoint list, and CHANGELOG.

Tests

  • InboxConversationsTest (9): placement at the newest shown member; members drawn from the folder, not the tab; one loaded message is a plain row; a message plus your reply is a conversation of 2 that acts on this folder only; expanded order and unique keys; senders oldest first, deduplicated, "me", capped at three.
  • RelayMailSourceTest (+4): request shape and the 500 clamp; reading sent rows into their own folder; a 404 is a failure, not an empty list; settings GET/PUT bodies; a missing field reads as on, a string is refused.
  • EmailRowAccessibilityTest (instrumentation, +1, plus an updated signature): a conversation row speaks "Conversation, 2 messages" and "Expanded", and nested rows have no actions.

Commands (Major, each batch capped with systemd-run -p MemoryMax=6G, --max-workers=2)

  • ./gradlew checkSigningSecretsAreNotInTheTree testPlayDebugUnitTest: BUILD SUCCESSFUL
  • ./gradlew testGithubDebugUnitTest, testFdroidDebugUnitTest: BUILD SUCCESSFUL
  • ./gradlew lintPlayDebug, lintGithubDebug, lintFdroidDebug: BUILD SUCCESSFUL
  • ./gradlew assembleFdroidDebug assemblePlayDebugAndroidTest: BUILD SUCCESSFUL. The first run failed to compile my new instrumentation test; I fixed it and re-ran.
  • A single run of all of the above killed the Gradle daemon under the 6 GB cap, so I ran them in batches.

Security

  • No change to pairing, pinning, credentials or storage of mail. The only new stored value is one boolean (conversations) in plain SharedPreferences.
  • New outbound calls go to the paired server only, through the existing pinned call factory and device headers: GET /api/inbox/conversations and GET|PUT /api/settings/mail.
  • Mail is never archived, moved or deleted without a user action. A conversation action is still one explicit swipe or menu tap, and its scope is shown in the row (count).
  • Trade-off introduced: one swipe can now act on several messages. The row says how many.
  • Fails closed: an unreadable setting or grouping falls back to the plain list.

AI involvement

  • Level: Agentic (Claude Code, Claude Opus 5.5). I read the server contract and the web client's conversations.ts, implemented the change, and ran the checks above. No separate adversarial review skill was run, so the reviewer bot's pass is the hostile review.

🤖 Generated with Claude Code

Yoshiofthewire and others added 2 commits November 19, 2026 08:21
KyPost-Server #667 groups replies server-side behind a per-user
switch, so every client shows the same conversations. The inbox now
folds its rows with GET /api/inbox/conversations while the switch is
on, list actions cover the whole conversation in that folder, and
Settings can flip the switch.

Part of #324

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
applyListRowTheme reads the row's last child as the chevron, so
Settings crashed on open (ContactSyncConsentTest on the emulator).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Yoshiofthewire

Yoshiofthewire commented Nov 19, 2026 •

Copy link
Copy Markdown
Member Author

Security review - cleared

Detail withheld: this repository is public, and posting an unfixed finding here would be public disclosure. The full report was posted to the hand-off board at https://myslop.urlxl.us/f/pr-reviewer-busnes-app-kypost-for-android-326, where it is readable by the operator and expires seven days after the last post.


gpt-6.1-sol using security-audit on behalf of Yoshi

@Yoshiofthewire

Yoshiofthewire commented Nov 19, 2026 •

Copy link
Copy Markdown
Member Author

Autonomous review - 1/1 personas cleared

  • security: cleared

Merging remains a human decision; this bot never approves.


gpt-6.1-sol using security-audit on behalf of Yoshi

@Yoshiofthewire

Yoshiofthewire commented Nov 19, 2026 •

Copy link
Copy Markdown
Member Author

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪

🧪 PR contains tests

🔒 No security concerns identified

⚡ No major issues detected


Advisory only: this comment never gates the pull request.
claude-sonnet-5-5 using pr-agent on behalf of Yoshi

A refresh that brings a newer reply gives the conversation a new lead
row. The selection still held the old lead id, so the new row showed
unselected and a bulk action found no members for the old id and acted
on that one message only. followLeads moves a selected member id to
its conversation's current lead each time the rows are rebuilt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Yoshiofthewire

Copy link
Copy Markdown
Member Author
  • Selection Breaks When Lead Changes: fixed in 08fabef. followLeads moves a selected member id to its conversation's current lead whenever the rows are rebuilt, so the row stays selected and bulk actions cover every member. Test: InboxConversationsTest.aSelectedConversation_followsItsNewLead (fails before, passes after).
  • Refresh Blocked By Extra Request: not addressed in this pass (out of scope for this round).

claude-opus-5-5 using pull-request on behalf of Yoshi

Yoshiofthewire and others added 3 commits November 19, 2026 10:34
Both features kept: MailSource and MailRepository gain the
conversations calls and sendDelaySeconds side by side, the window and
Send delay constants both stay, and the docs list the conversations
and settings routes with /api/mail/send-delay and /api/scheduled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The inbox kept the server's conversation groupings by folder alone.
They now live in a ConversationCache owned by one account in one
session: a different account or a new session generation starts it
empty, and an answer from a session that has ended is dropped.

Tests: InboxConversationsTest conversationCache_* (unit), and
InboxConversationAccountTest (instrumentation) switching accounts in
the same Activity with repeated message ids.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A refresh, the 90 s poll included, waited for /api/inbox/conversations
before painting the mail it had already fetched, so a slow or hanging
route held the new mail and the pull spinner back. paintThenGroup now
paints first, then fetches the grouping and redraws when it lands.

Test: InboxConversationsTest.aRefreshPaintsTheMailBeforeAskingForItsGrouping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Yoshiofthewire

Copy link
Copy Markdown
Member Author
  • Clear conversation data when the paired account changes: fixed in 7c449e8. Conversation groupings live in a ConversationCache owned by one account and session generation; a change to either empties it, and an answer from an ended session is dropped. Tests: InboxConversationsTest.conversationCache_* (fail before, pass after) and instrumentation InboxConversationAccountTest (compiled here, runs in CI).
  • Refresh Blocked By Extra Request: fixed in 1aa0ca4. The refresh paints the fetched mail and stops the spinner first, then asks for the grouping and redraws when it lands (paintThenGroup). Test: InboxConversationsTest.aRefreshPaintsTheMailBeforeAskingForItsGrouping (fails before, passes after).
  • Merged origin/main (feat: hold sends for the Send delay with Cancel #327) in af6d54c, keeping both features.

claude-opus-5-5 using pull-request on behalf of Yoshi

Conflicts were side-by-side additions; both kept:
- CHANGELOG.md: conversations entry, then the reply From entry.
- app/AGENTS.md: relay endpoint list gains /api/inbox/conversations,
  /api/settings/mail and /api/mailboxes.
- MailRepository/MailSource/RelayMailSource: conversation fetch and
  mail-settings calls next to ownAddresses() and replyFrom().
- RelayModels: conversation and mail-settings DTOs next to the
  mailboxes DTOs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Yoshiofthewire
Yoshiofthewire merged commit 01f304b into main Nov 19, 2026
15 checks passed
@Yoshiofthewire
Yoshiofthewire deleted the feat/conversations branch November 19, 2026 16:07
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.

1 participant