Skip to content

fix(email): route bin/trash action through IMAP delete instead of labels - #430

Open
santhiprakash wants to merge 1 commit into
oblien:mainfrom
santhiprakash:fix/email-bin-imap-move-429
Open

fix(email): route bin/trash action through IMAP delete instead of labels#430
santhiprakash wants to merge 1 commit into
oblien:mainfrom
santhiprakash:fix/email-bin-imap-move-429

Conversation

@santhiprakash

@santhiprakash santhiprakash commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

The webmail trash/bin action was only applying a Gmail-style TRASH label through mail.modifyLabels. On real-mailbox IMAP servers like Dovecot this leaves the message in INBOX with a visible TRASH tag instead of moving it to the Trash mailbox.

Motivation

Issue #429 reports two things. This PR addresses the deleted-email/TRASH-label bug. The server already has the correct deleteThreads path (messageMove(..., 'Trash') or messageDelete when already in Trash), but the client was not calling it from the bin flow.

Related issue

Addresses the deleted/TRASH-label bug described in #429. The auto-refresh feature request in the same issue is a separate piece of work and is not addressed here.

Changes

  • apps/email/client/lib/thread-actions.ts: moveThreadsTo case 'bin' now calls trpcClient.mail.bulkDelete.mutate({ ids, folder }), which routes to deleteThreads on the server.
  • apps/email/client/hooks/use-optimistic-actions.ts: optimisticDeleteThreads now passes folder: currentFolder to bulkDeleteThread so the IMAP driver looks in the correct source mailbox.
  • apps/email/client/components/context/thread-context.tsx: the bin "Delete permanently" action now passes folder: currentFolder to deleteThread so it targets the Trash mailbox instead of defaulting to INBOX.

Verification

  • CI Typecheck and Test checks are green on this PR.
  • bun run --cwd apps/email/client lint could not be run because the workspace's eslint.config.ts imports a missing @zero/eslint-config package.
  • bun run test at the root has pre-existing environment-specific timeouts in apps/cli and packages/db unrelated to this change; the CI Test check passed.
  • bunx prettier --check on the three changed files shows many pre-existing formatting issues outside this diff, so I left the files in their existing local style and changed only the functional lines to keep the diff scoped.
  • The apps/email/client workspace does not have a test script, so the behavior was verified by reading the trpc.mail.bulkDelete / trpc.mail.delete route definitions and the deleteThreads driver implementation.

Screenshots

Not applicable — behavior change is in the IMAP driver call, not the UI chrome.

Checklist

  • One change per PR — one bug, or one agreed feature, with nothing unrelated bundled in
  • The diff is scoped — no reformatting or lint fixes on lines I wasn't otherwise changing
  • A test fails without this change and passes with it (or I explained above why there isn't one)
  • bun run test, bun run --cwd <workspace> lint, and bun format all pass locally
  • I understand every line of this diff and can explain it in review

The trash icon and "Move to Bin" flow was calling mail.modifyLabels,
which only adds/removes IMAP keywords. On real-mailbox servers like
Dovecot, this leaves the message in INBOX with a visible TRASH tag
instead of moving it to Trash.

Use the existing trpc.mail.bulkDelete path (deleteThreads) which does
messageMove(..., 'Trash') when the source is not Trash and permanently
deletes when it is. Pass the source folder along in the two delete
entry points so the IMAP driver looks in the right mailbox.

Fixes oblien#429
@santhiprakash
santhiprakash force-pushed the fix/email-bin-imap-move-429 branch from c8f0c52 to e5e095b Compare August 5, 2026 02:36
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