Skip to content

feat: hold sends for the Send delay with Cancel - #327

Merged
Yoshiofthewire merged 2 commits into
mainfrom
feat/send-delay
Nov 19, 2026
Merged

Yoshiofthewire merged 2 commits into
mainfrom
feat/send-delay

Conversation

@Yoshiofthewire

Copy link
Copy Markdown
Member

Part of #324 (part 3: send delay. Conversations is #326; reply identity is a separate PR.)

In one line: With a Send delay set on the web, Send now holds the message and shows "Sending in Ns · Cancel sending". Cancel keeps the message open in Compose exactly as written.

What changed

  • Compose reads GET /api/mail/send-delay when it opens. Above 0, a send with no chosen time carries sendDelay: true. If the delay is 0, the server is older (404) or the read fails, Send works exactly as before.
  • When the server answers 202 with delayed and an id, Compose stays open with Send off and a bar reading "Sending in 9s · Cancel sending", which counts down every second. At release, it closes as sent.
  • Cancel sending calls POST /api/scheduled/{id}/cancel. On success the composition stays as it was (recipients, body, attachments, Encrypt and Sign) to edit and send again, with "Sending canceled… A copy is in Drafts." If the server answers 409 (release already started) it says Already sent and closes. Other errors keep the bar, so the user can try again.
  • Client-protected accounts: the server refuses a held message it could not return to Drafts encrypted. A plain send therefore goes through the existing pgpDraft path (scheduled sends already do this), and an encrypted send carries a draftCopy dated now.
  • The hold survives a rotation or the app lock: ComposeSend.held is process-scoped, so the recreated Compose shows the bar again instead of offering Send. A session reset drops it.
  • The delay is set on the web only: PUT /api/mail/send-delay needs a web session. "Undo" appears in none of the new strings.

Review this

  • ComposeActivity.startHeld / cancelHeld: when Compose finishes as sent and when it keeps the draft. Getting this wrong either loses a canceled message or offers Send twice.
  • RelayMailSource.sendOutcome: a 202 counts as a hold only with delayed and an id the cancel path accepts. Anything else is not shown as sent.
  • Safe to skip: the DTO fields and the repository pass-through.

Checked: the repository's required checks all pass locally (commands below). There are new unit tests.
Not checked: I did not run the instrumentation tests. The Android emulator segfaults on Major, so GitHub CI runs them. I have not tapped through the bar on a device, and nothing was tested against a live server.

Decided for you

  • Compose stays open during the hold, rather than closing and showing the bar on another screen. This keeps "restore the draft intact" exact: nothing ever leaves the screen. Back during the hold closes Compose and the message goes at release; it can still be canceled from Scheduled.
  • The countdown uses the delay this device read, timed on its own clock. The server's sendAt is used only when that delay is unknown, because the two clocks can disagree.
  • If a rotation lands during the cancel request itself, the new screen does not see that answer and resumes the countdown. This is marked ponytail: in the code; the upgrade path is to run the cancel in ComposeSend.

You need to: nothing.

Detail

By area

  • Wire: sendDelay on RelayMailRequestDto and RelayClientEncryptedRequestDto (omitted when false); id and delayed on the send response; RelaySendDelayDto. sendDelaySeconds accepts 0..90 only.
  • Sender: ClientEncryptedSender.send adds the draftCopy when held. Deliveries stay dated now. A chosen sendAt is never also delayed.
  • Compose: sendEmail awaits the delay read (normally done long before Send) inside the editor export callback, then routes. renderSendOutcome and renderClientSendOutcome start the hold on heldId.
  • Docs: app/src/main/AGENTS.md (contract), the app/AGENTS.md endpoint list, and CHANGELOG.

Tests

  • RelayMailSourceTest (+5): the request carries sendDelay and the hold is read with its id; without the flag nothing changes and a 200 is an ordinary send with no warning; a 202 without a usable id (missing, ../x, or not delayed) is not read as sent; the encrypted send carries the flag and draftCopy; sendDelaySeconds handles 30, 0, 404→0, -1, 3600 and {}.
  • ClientEncryptedSenderTest (+2): a held send is dated now with the flag and a draft copy; a scheduled send is never also delayed.
  • ComposeSendTest (+1): a hold outlives its screen, only its own clear ends it, and a session reset drops it.

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 instrumentation APK compiles)

Security

  • No change to pairing, pinning or stored credentials. New calls go to the paired server only, through the pinned factory: GET /api/mail/send-delay. The cancel endpoint was already used by Scheduled.
  • A held message from a client-protected account goes with an encrypted copy for Drafts, never plaintext. This is the existing scheduled-send rule.
  • The held id is checked against the same id pattern the cancel path enforces before it is used in a URL.
  • Trade-off introduced: none. Without the setting, nothing changes.

AI involvement

  • Level: Agentic (Claude Code, Claude Opus 5.5). I read the server's server_mail_send.go, pgp_send_client.go and scheduled_send.go for the hold rules, and the web's useCompose cancel flow. No separate adversarial review skill was run.

🤖 Generated with Claude Code

KyPost-Server #668 holds a send for the user's Send delay when asked
with sendDelay. Compose now asks when the delay is above 0, shows
"Sending in Ns · Cancel sending" until release, and a Cancel keeps
the composition intact to edit and send again.

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: 3 🔵🔵🔵⚪⚪

🧪 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

@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-327, 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

Back called leaveHeld() even while the cancel request was out, closing
Compose as sent and dropping the answer, so the user never learned
whether the message went or returned to Drafts. ComposeSend.onBack
now waits instead.

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

Copy link
Copy Markdown
Member Author
  • Back During Cancel: fixed in 0afa035. Back now does nothing while a Cancel is in flight (ComposeSend.onBack returns WAIT), so the cancel result still arrives on the open screen. Test: ComposeSendTest.back_waitsForAnInFlightCancel (fails before, passes after).

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

@Yoshiofthewire
Yoshiofthewire merged commit ca53935 into main Nov 19, 2026
22 of 24 checks passed
@Yoshiofthewire
Yoshiofthewire deleted the feat/send-delay branch November 19, 2026 15:22
Yoshiofthewire added a commit that referenced this pull request Nov 19, 2026
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 added a commit that referenced this pull request Nov 19, 2026
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>
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