Skip to content

feat: reply from the address mail was sent to - #328

Merged
Yoshiofthewire merged 4 commits into
mainfrom
feat/reply-identity
Nov 19, 2026
Merged

Yoshiofthewire merged 4 commits into
mainfrom
feat/reply-identity

Conversation

@Yoshiofthewire

@Yoshiofthewire Yoshiofthewire commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Part of #324 (part 4: reply identity. Conversations is #326, send delay is #327. The optional masked-address management screen is not in this PR.)

In one line: Reply and Reply all now send from the address the message was delivered to (a you+tag@ or masked address). When the server cannot tell which one, the user must pick a From before the reply can be sent or saved. It never falls back to the main address.

What changed

  • Reply asks the server fresh: GET /api/mail/body for deliveredTo (the receipt's addresses, Bcc included) and GET /api/mailboxes for the primary mailbox's addresses (masked ones included). It then applies the web client's rule (replyFromAddress in frontend/src/pages/read/compose.ts):
    • the To/Cc address that names a delivered one keeps its plus tag;
    • otherwise, the delivered own address;
    • otherwise, nothing.
      Mail with no receipt (external IMAP) uses your own To/Cc address, or the account default as before.
  • Compose has a From row, shown for replies with their own From or one that must be chosen. Tap it to pick from the mailbox's addresses, plus the reply's tagged address.
  • If the server cannot tell, or either request fails, From reads Choose an address. Send, Save draft and the web handoff stop with "Choose which of your addresses this comes from." and open the picker.
  • The From and its "must choose" state survive the app lock and rotation (CachedDraft). Edit draft reopens with the draft's own From, or asks if it has none.
  • The chosen From goes as from on /api/mail/send, and as the From of client-encrypted deliveries and encrypted drafts. The server still checks that the address belongs to the account.

Review this

  • replyFromAddress and MailRepository.replyFrom. Every "the server can't tell" path must come out null, never "". The one exception is the deliberate no-receipt case.
  • ComposeActivity.fromChosen and its callers (send, Save draft, web handoff). This is the gate that keeps the primary address out.
  • Safe to skip: the layout row and strings.

Checked: the repository's required checks all pass locally (commands below). There are new unit tests and one new instrumentation test.
Not checked: I did not run the instrumentation tests. The Android emulator segfaults on Major, so GitHub CI runs them. Nothing was tested against a live server with masked addresses.

Decided for you

  • Reply waits for two small requests before Compose opens, as the web does. Offline, the reply opens with From to choose, and the picker cannot load addresses until the connection is back.
  • Plain server drafts (/api/mail/draft, server-held key) have no from field on the server, so they reopen as the primary address. Save draft is therefore refused there unless From is blank or the primary address: "Drafts can't keep this From address. Send it now, or switch From to your main address to save it." The security reviewer found this gap and the second commit closes it. Storing the From with plain drafts needs a server change. Encrypted drafts carry their From.
  • Choices are the primary mailbox's addresses only (no send-as aliases and no other mailboxes), because this app sends from the primary mailbox.

You need to: nothing.

Detail

By area

  • Relay: deliveredTo on RelayMessageBodyDto and MailMessageBody (null when absent). ownAddresses reads the primary mailbox from /api/mailboxes; a 404 or an empty list means none.
  • Repository: replyFrom. Without a receipt, an unknown address list falls back to the default, because nothing there can be masked. With a receipt it gives null.
  • Address rule: plusBase and replyFromAddress in AddressText.kt.
  • Compose: EXTRA_FROM and EXTRA_FROM_REQUIRED are read only from in-app launches (ComposePrefill), so another app cannot choose the From. Added state composeFrom/fromRequired/ownAddresses, the From row and the picker.
  • Reader: Reply, Reply all and Edit draft pass From.
  • Docs: app/src/main/AGENTS.md (contract), the app/AGENTS.md endpoint list, and CHANGELOG.

Tests

  • AddressTextTest (+5): plusBase; keeps the tag the sender used; masked delivered as Bcc; null when no delivered address is yours, never the primary; with no receipt, your header address or the default.
  • MailRepositoryTest (+1): delivered gives the tagged From; a failed body fetch gives null; unknown addresses with a receipt give null; no receipt gives "".
  • RelayMailSourceTest (+2): deliveredTo read, blank entries dropped, absent read as null; the primary mailbox's addresses, none without native mail, 404 gives none, 503 is a failure.
  • PlainDraftFromTest (3): blank or primary is kept; a masked or tagged From is refused; unknown addresses refuse.
  • ComposeDraftCacheTest (+1): a restored draft still owes its From.
  • ComposeIntentParserTest (instrumentation, +1): From and its requirement come from in-app launches only.

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

  • ./gradlew checkSigningSecretsAreNotInTheTree testPlayDebugUnitTest: BUILD SUCCESSFUL
  • ./gradlew testGithubDebugUnitTest, testFdroidDebugUnitTest: BUILD SUCCESSFUL. The first attempt lost its Gradle daemon to the memory cap while another build ran; the re-run passed.
  • ./gradlew lintPlayDebug, lintGithubDebug, lintFdroidDebug: BUILD SUCCESSFUL
  • ./gradlew assembleFdroidDebug assemblePlayDebugAndroidTest: BUILD SUCCESSFUL

Security

  • Privacy gain: a reply to a masked or plus address no longer exposes the primary address.
  • Fails closed: any unknown result asks the user. Nothing substitutes the primary.
  • No new stored secret. New calls go to the paired server only, through the pinned factory: GET /api/mailboxes, and one extra GET /api/mail/body per reply.
  • External intents cannot set From.
  • Trade-off introduced: none.

AI involvement

  • Level: Agentic (Claude Code, Claude Opus 5.5). The address rule is ported from the web client and tested with the same cases. No separate adversarial review skill was run.

🤖 Generated with Claude Code

KyPost-Server #665 reports where native mail was delivered, so a
reply to a plus or masked address must not reveal the primary. Reply
now defaults its From to that address, and when the server cannot
tell, Compose makes the user choose before it sends or saves.

Part of #324

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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

⚡ Recommended focus areas for review

Reply Delay, Double Open

The Reply click handler now awaits replyFrom() before opening Compose. That is a fresh body fetch plus a /api/mailboxes request, both on the network and with no loading state. Previously Reply opened Compose without a network wait. On a slow connection the button appears to do nothing, and a second tap launches another coroutine that opens a second Compose screen. Nothing in the diff guards against re-entry (an in-flight flag, or disabling the button). Reply-all has the same exposure.


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

@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-328, 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 and others added 2 commits November 19, 2026 08:47
/api/mail/draft stores no From, so a server-held-key draft saved with
a masked or tagged From reopened as the primary address. Save draft is
now refused there unless From is blank or the primary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With an empty address list (a relay without native mailboxes) a
required From blocked Send, Save draft and the handoff, and the picker
had nothing to offer. fromPickPending now lets the account default
stand, and the picker clears the requirement instead of a bare toast.

plainDraftKeepsFrom kept refusing on that empty list too; it now keeps
the From. An unloaded list is loaded before Save draft decides, rather
than refused, so a masked From is still never saved as the primary.

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

Copy link
Copy Markdown
Member Author
  • Save draft wrongly refused: fixed in 09343c6. plainDraftKeepsFrom now keeps the From when the address list is empty. When the list is not loaded yet (null), Save draft loads it and then decides, instead of refusing; if the load fails, the user sees the reason. An unknown list is still not accepted blindly, because a masked From would silently be saved as the primary. Test: PlainDraftFromTest.noAddresses_keepTheFrom (fails before, passes after).
  • Unrecoverable required From: fixed in 09343c6. With an empty address list, fromPickPending lets the account default stand, and the picker clears the requirement instead of showing a toast and nothing else. A failed load still blocks, and the next tap retries, so a reply to a masked address never falls back to the primary. Test: PlainDraftFromTest.aRequiredFrom_waitsForAPick_onlyWhileThereIsOneToMake (fails before, passes after).

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

Both features kept: Compose sends carry the chosen From and the
sendDelay flag, MailSource and MailRepository gain ownAddresses and
sendDelaySeconds side by side, and the docs list /api/mailboxes with
/api/mail/send-delay and /api/scheduled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Yoshiofthewire
Yoshiofthewire merged commit b2a2379 into main Nov 19, 2026
18 of 19 checks passed
@Yoshiofthewire
Yoshiofthewire deleted the feat/reply-identity branch November 19, 2026 15:49
Yoshiofthewire added a commit that referenced this pull request Nov 19, 2026
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>
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