Skip to content

Fix email search #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

cduguet
Copy link

@cduguet cduguet commented Apr 14, 2025

vibe coded a solution that works.

  1. Removed list Operation:

    • The dedicated list operation for emails has been removed across index.ts, tools.ts, and utils/mail.ts.
    • Searching with an empty searchTerm ("") now effectively lists recent emails within the specified scope (account/mailbox/date).
  2. Enhanced Search Filtering:

    • Added new optional parameters to the search operation:
      • account: Filter by a specific email account.
      • mailbox: Filter by a specific mailbox (can be combined with account or used across all accounts).
      • fromDate: Filter emails received on or after this date (ISO format).
      • toDate: Filter emails received on or before this date (ISO format).
      • maxMailboxes: Limit the number of mailboxes searched (JXA only) for performance tuning.
    • Updated the tool definition (tools.ts) and server logic (index.ts) to support these new parameters.
  3. Refactored Search Implementation (utils/mail.ts):

    • searchMails function: Heavily refactored to accept and utilize the new filtering parameters (accountName, mailboxName, fromDate, toDate, maxMailboxes).
    • AppleScript: Rewritten to handle account/mailbox scoping, escape inputs, extract more details (truncated content, full mailbox path including account), improve error handling, and attempt date sorting. Includes an optimization to potentially stop searching early.
    • JXA Fallback: Updated to also handle the new filtering parameters, including date range filtering and limiting the number of mailboxes searched. Content search was removed from JXA for performance reasons (now searches Subject/Sender only). Results are sorted by date.
    • Removed getLatestMails: The unused getLatestMails function was removed.
  4. Improved Input Validation (index.ts):

    • The isMailArgs validation function was updated to correctly handle the new optional parameters (fromDate, toDate, maxMailboxes) and the removal of the list operation. It now allows an empty string for searchTerm in the search operation.

@advenimus
Copy link

LOL How has this not been merged yet?

@Dhravya
Copy link
Collaborator

Dhravya commented Jun 9, 2025

my bad - Will test and merge today

@cduguet
Copy link
Author

cduguet commented Jun 12, 2025

any updates?

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.

3 participants