feat(messages): add refreshFolder tool#150
Open
JordanRO2 wants to merge 1 commit into
Open
Conversation
Force an IMAP fetch on a folder so server-side state syncs into
Thunderbird's local cache (useful before searchMessages/getMessage on an
account that may be stale). Drives the fetch via folder.getNewMessages with
an nsIUrlListener for completion; bounded by a one-shot nsITimer timeout
(timeoutMs default 15000, hard-capped at 25000 to stay under the bridge's
30s request timeout and return a structured { error } instead of a hard
fail). Resolve-once guard cancels the timer on completion.
Returns { success, folderPath, totalBefore, totalAfter, newMessages } on a
completed fetch, { success, skipped } for non-IMAP folders, or a structured
{ error } on timeout/fetch-failure/access-denied. Reuses getAccessibleFolder
for the per-account access gate.
Tests + ALL_TOOLS updated; full suite green, lint 0 errors.
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.
What
refreshFolder(folderPath, timeoutMs)— force an IMAP fetch on a folder so the server's current state syncs into Thunderbird's local cache. Handy beforesearchMessages/getMessageon an account whose offline copy may be stale.folder.getNewMessages(null, urlListener)and detects completion via annsIUrlListener(OnStopRunningUrl).nsITimer:timeoutMsdefault 15000, hard-capped at 25000 to stay under the stdio bridge's 30s request timeout — so a slow server yields a structured{ error: "refreshFolder timed out…" }instead of the bridge hard-failing. A resolve-once guard cancels the timer on completion.{ success: true, skipped: "not an IMAP folder" }.Returns
{ success, folderPath, totalBefore, totalAfter, newMessages }on a completed fetch, or a structured{ error, folderPath }on timeout / fetch-failure / access-denied. ReusesgetAccessibleFolderfor the per-account access gate.Tests
test/validation.test.cjscovers the schema;ALL_TOOLSupdated (structural test passes). Full suite green,eslint .0 errors.Independent of my other open tool PRs (#145/#148/#149) — branches off
maindirectly.