8000 Email: open folders with a space in the name, and don't show a cancelled load as a failure by Thomaspeel6 · Pull Request #6 · joexk1/JoeBro · GitHub
[go: up one dir, main page]

Skip to content

Email: open folders with a space in the name, and don't show a cancelled load as a failure - #6

Closed
Thomaspeel6 wants to merge 2 commits into
joexk1:mainfrom
Thomaspeel6:fix/email-folders-and-cancelled
Closed

Thomaspeel6 wants to merge 2 commits into
joexk1:mainfrom
Thomaspeel6:fix/email-folders-and-cancelled

Conversation

@Thomaspeel6
@Thomaspeel6 Thomaspeel6 commented Nov 13, 2026 •
Copy link
Copy Markdown

Two small email fixes found while connecting a Gmail account. One commit each.

1. Folders with a space in the name fail to open

What: Selecting any Gmail folder other than Inbox ("[Gmail]/Sent Mail", "[Gmail]/All Mail"), or any user folder with a space in its name, shows:

EXAMINE command error: BAD [b'Could not parse command']

Why: imaplib sends mailbox names verbatim, so a name with a space reaches the server as two arguments.

Fix: A small imap_mailbox() helper sends the name as an IMAP quoted string, used in the four places a folder is selected (jb_email.py).

2. A cancelled load is shown as "Couldn't load — cancelled"

What: Switching tabs or folders while the inbox is still loading leaves the Email tab on "Couldn't load — cancelled", even though the mailbox works.

Why: The load runs in a .task keyed on folder and filter, so SwiftUI cancels it, and the catch reports the cancellation as a failure.

Fix: Ignore a cancelled load; the next one replaces it (EmailPanel.swift).

Tested

  • New test_email_folders.py (2 tests, local fake IMAP server): an unquoted name with a space is rejected, the quoted one opens. Full backend suite passes (85 tests) on the macOS system Python.
  • Against a real Gmail account: before the fix only Inbox loaded; after it, Sent Mail, All Mail and user folders with spaces all return mail through /api/email/list.
  • Built in Xcode 26.5 on macOS 26.2. I checked the folder fix through the backend API rather than by clicking through the Email tab, and the cancelled-load fix by reading the code path, not by reproducing the race on screen.

Part of the email setup proposal in #8.

imaplib sends mailbox names verbatim, so a name containing a space reached the
server as two arguments. Every Gmail system folder except INBOX ("[Gmail]/Sent
Mail", "[Gmail]/All Mail") and any user folder with a space failed with
"EXAMINE command error: BAD Could not parse command".

Names are now sent as IMAP quoted strings wherever a folder is selected.
The inbox load runs in a .task keyed on folder and filter, so it is cancelled
when the tab is switched away or the folder changes. The catch block showed
that as "Couldn't load — cancelled", even over a working mailbox. A cancelled
load is now ignored; the next load replaces it.
@Thomaspeel6
Copy link
Copy Markdown
Author

Folded into #7 so all the email changes are in one place. The two commits here are in that branch unchanged.

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

0