Repository navigation
COR-264 - Change the IMAP idle disconnect delay at runtime - #119
Merged
dbezverkhnii merged 2 commits intoOct 5, 2026
Merged
Conversation
A host app wants a long idle delay on screen and a short one in the background, but the session copied the delay into a connection only when it created one, and only in whole seconds. A connection now reads the delay from its session when it arms the idle timer, and a change restarts every timer already running, on the session's dispatch queue. The delay is a double, and the Swift session exposes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
bugbot run |
Changing automaticDisconnectDelay walks the connection list on the session's dispatch queue, so it joins operationRunningStateChanged() in the reason acquire and release belong on that queue. The concurrent test drops an assertion that held by construction. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8b68c22. Configure here.
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.

The core wants to close idle IMAP connections quickly in the background and keep them warm on screen, by switching
automaticDisconnectDelaywhen the app changes mode (COR-246). That knob could not be turned at runtime: the session copied it into a connection once, at creation, in whole seconds, and Swift did not expose it.doublein C++ and the C API;MCOIMAPSession.automaticDisconnectDelay: TimeIntervalin Swift.The C++ changed, so the Windows prebuilt needs a rebuild for this revision before a tag.
Tests:
IMAPAutomaticDisconnectDelayTests. A running timer restarts with a shorter delay, sub-second delays are kept, a command in flight is not cut, a leased connection waits for its release, and concurrent changes settle on the last one. Each one was checked to fail without the matching part of the fix.🤖 Generated with Claude Code
Note
Medium Risk
Changes IMAP connection lifecycle timing and cross-thread pool updates; incorrect timer restarts could drop idle sockets early or keep them open longer than intended.
Overview
IMAP idle auto-disconnect delay can now be changed at runtime so apps can tighten disconnects in the background and keep connections warm on screen.
Session-owned delay: Connections no longer store their own copy at creation. When the idle timer is armed, they read
IMAPAsyncSession::automaticDisconnectDelay().setAutomaticDisconnectDelayis thread-safe (lock + hop to the session dispatch queue) and walks the pool torestartAutomaticDisconnecton any connection that already has a timer running.API: Delay type moves from
time_t(whole seconds) todoublethrough C++/C bindings; Swift addsautomaticDisconnectDelay: TimeIntervalonIMAPSession. Per-connectionsetAutomaticDisconnectDelayis removed in favor ofrestartAutomaticDisconnect(dispatch-queue only).Tests:
IMAPAutomaticDisconnectDelayTestscovers shorter delay restarting an armed timer, sub-second values, in-flight commands not being cut, leased connections waiting for release, and concurrent updates settling on the last value.Reviewed by Cursor Bugbot for commit 8b68c22. Bugbot is set up for automated code reviews on this repo. Configure here.