Unify slim/UID-flags fetches via FetchMessageInfoOptions#167
Merged
Conversation
Folds the slim and UID+FLAGS fetch variants from #160 into the existing FetchMessageInfoCommand / fetchMessageInfo(s) surface via a new FetchMessageInfoOptions OptionSet, addressing #163. - Add FetchMessageInfoOptions with .default / .slim / .uidFlagsOnly presets, a newsletterHeaderFields constant, and a suggestedChunkSize derived from per-message payload weight (50 / 500 / 5000). - Parameterize FetchMessageInfoCommand with options + optional headerFields, building [FetchAttribute] dynamically. UID is always implicit. - Extend fetchMessageInfo, fetchMessageInfosBulk, range overloads, and the streaming variant on IMAPServer and IMAPNamedConnection with options / headerFields parameters (all defaulted, existing call sites unchanged). - Streaming variant gains chunkSize: Int? override; default is derived from options.suggestedChunkSize. - Extract IMAPServer+Fetch body-structure helpers into their own file to keep the main file under the SwiftLint file_length threshold. No new command/handler types. MessageInfo stays the result type for all variants (the now-skipped fields remain nil). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR unifies lighter-weight message metadata fetch variants into the existing FetchMessageInfoCommand and fetch APIs using FetchMessageInfoOptions, reducing the need for parallel command families while preserving default behavior.
Changes:
- Adds
FetchMessageInfoOptionspresets for default, slim, and UID/flags-only fetches. - Updates
FetchMessageInfoCommand,IMAPServer, andIMAPNamedConnectionfetch methods to accept options and targeted header fields. - Extracts body-structure helper methods into a separate file and adds option behavior tests.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
.gitignore |
Ignores .claude/ local tooling files. |
Sources/SwiftMail/IMAP/IMAP/Commands/FetchCommands.swift |
Builds fetch attributes dynamically from FetchMessageInfoOptions. |
Sources/SwiftMail/IMAP/IMAPNamedConnection+Fetch.swift |
Adds options/header-fields parameters to named-connection bulk and range fetch APIs. |
Sources/SwiftMail/IMAP/IMAPServer+BodyStructureHelpers.swift |
Moves body-structure helper implementation out of IMAPServer+Fetch.swift. |
Sources/SwiftMail/IMAP/IMAPServer+Fetch.swift |
Adds options/header-fields/chunk-size support to server fetch APIs. |
Sources/SwiftMail/IMAP/Models/FetchMessageInfoOptions.swift |
Defines the new fetch option set, presets, newsletter fields, and chunk-size heuristic. |
Tests/SwiftIMAPTests/FetchMessageInfoOptionsTests.swift |
Covers option presets and chunk-size bucketing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Mirrors the IMAPServer streaming variant so named connections can use the .slim and .uidFlagsOnly streaming paths without dropping back to the actor. Same shape: nonisolated, AsyncThrowingStream, chunk size derived from options.suggestedChunkSize with optional override. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #163. Folds the slim and UID+FLAGS fetch variants from the unmerged #160 into the existing
FetchMessageInfoCommand/fetchMessageInfo(s)surface via a newFetchMessageInfoOptionsOptionSet, rather than adding parallel command and method families.FetchMessageInfoOptionswith.default/.slim/.uidFlagsOnlypresets, anewsletterHeaderFieldsconstant, and asuggestedChunkSizederived from per-message payload weight (50 / 500 / 5000).FetchMessageInfoCommandtakesoptionsand optionalheaderFieldsand builds[FetchAttribute]dynamically. UID is always implicit.fetchMessageInfo,fetchMessageInfosBulk, the range overloads, and the streaming variant gainoptions:/headerFields:parameters on bothIMAPServerandIMAPNamedConnection. All defaulted — existing call sites unchanged.chunkSize: Int?override; default comes fromoptions.suggestedChunkSize.IMAPServer+Fetch.swiftstays under SwiftLint's 400-linefile_length.How #163's open questions are resolved
MessageInfois kept for all variants. Skipped fields staynil. A separate lightweight type would re-fragment what this change is unifying.optionsfor the common case (no API noise), overridable on the streaming variant where chunking actually applies. Replaces the twoprivate let *FetchChunkSizeconstants from Add slim/UID-flags fetches, mailbox delete & rename, RFC822.SIZE, named US zones #160.Example call sites
Test plan
🤖 Generated with Claude Code