Skip to content

feat(messages): add refreshFolder tool#150

Open
JordanRO2 wants to merge 1 commit into
TKasperczyk:mainfrom
JordanRO2:feat/refresh-folder
Open

feat(messages): add refreshFolder tool#150
JordanRO2 wants to merge 1 commit into
TKasperczyk:mainfrom
JordanRO2:feat/refresh-folder

Conversation

@JordanRO2

Copy link
Copy Markdown
Contributor

What

refreshFolder(folderPath, timeoutMs) — force an IMAP fetch on a folder so the server's current state syncs into Thunderbird's local cache. Handy before searchMessages / getMessage on an account whose offline copy may be stale.

  • Drives the fetch with folder.getNewMessages(null, urlListener) and detects completion via an nsIUrlListener (OnStopRunningUrl).
  • Bounded by a one-shot nsITimer: timeoutMs default 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.
  • Non-IMAP folders short-circuit to { 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. Reuses getAccessibleFolder for the per-account access gate.

Tests

test/validation.test.cjs covers the schema; ALL_TOOLS updated (structural test passes). Full suite green, eslint . 0 errors.

Independent of my other open tool PRs (#145/#148/#149) — branches off main directly.

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.
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