From e762943f7bfa795a842bc878fb7958611f4dfecb Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Mon, 26 Oct 2026 11:13:30 +0100 Subject: [PATCH] fix: let a plugin move a single message that is not in the open list --- lib/__tests__/plugin-host-mail-move.test.ts | 12 ++++++++++++ stores/email-store.ts | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/__tests__/plugin-host-mail-move.test.ts b/lib/__tests__/plugin-host-mail-move.test.ts index 894832c03..98e28daf5 100644 --- a/lib/__tests__/plugin-host-mail-move.test.ts +++ b/lib/__tests__/plugin-host-mail-move.test.ts @@ -81,6 +81,18 @@ describe('api.email.move and archive', () => { expect(moveEmail).not.toHaveBeenCalled(); }); + // An auto-filer moves new mail while the user looks at another folder. + it('moves a single message that is not in the open list', async () => { + const batchMoveEmails = vi.fn(async () => {}); + const moveEmail = vi.fn(async () => {}); + useAuthStore.setState({ client: { batchMoveEmails, moveEmail } as unknown as IJMAPClient }); + useEmailStore.setState({ moveEmailsToMailbox: storeMove, emails: [] } as never); + + await call(WRITER, 'email.move', ['m9'], 'arch'); + + expect([...batchMoveEmails.mock.calls, ...moveEmail.mock.calls]).toEqual([[['m9'], 'arch', undefined]]); + }); + it('says when there is no Archive folder', async () => { useEmailStore.setState({ mailboxes: [inbox] }); await expect(call(WRITER, 'email.archive', ['m1'])).rejects.toThrow(/no Archive folder/); diff --git a/stores/email-store.ts b/stores/email-store.ts index 29341924a..2c58fc34d 100644 --- a/stores/email-store.ts +++ b/stores/email-store.ts @@ -4214,7 +4214,9 @@ export const useEmailStore = create((set, get) => ({ } return true; } - if (emailIds.length === 1) { + // moveToMailbox acts on a listed row only; an id from elsewhere (a + // plugin moving new mail) takes the batch path, or it was dropped. + if (emailIds.length === 1 && get().emails.some(e => e.id === emailIds[0])) { return await get().moveToMailbox(client, emailIds[0], destinationMailboxId); }