Feat: surface total result count in query-based tool responses#49
Open
JonathanGodley wants to merge 1 commit into
Open
Feat: surface total result count in query-based tool responses#49JonathanGodley wants to merge 1 commit into
JonathanGodley wants to merge 1 commit into
Conversation
Query-based tools (list_emails, search_emails, get_recent_emails, advanced_search, list_contacts, search_contacts, list_calendar_events) now show "Showing X of Y results" when results are truncated, so callers know more data is available. Uses JMAP calculateTotal (RFC 8620 §5.5) and a shared QueryResult type. When total is unavailable, the count is omitted rather than showing a misleading "X of X".
Owner
|
Still interested in this one — surfacing "Showing 20 of 3376" is genuinely useful for AI callers deciding whether to paginate or refine. It's the last open PR from your batch, but main has moved a lot since it was cut (v1.9.2 through v1.11.0): the limit caps you added here landed separately, and the search/list surface grew *_metadata variants (#70) plus multi-mailbox filters (#71) that would also want totals. If you're up for rebasing onto current main and extending QueryResult across the new variants, I'd be glad to review and land it in the next feature release. If not, let me know and we'll fold the calculateTotal work in ourselves with credit. |
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
QueryResult<T>interface andgetQueryResult()helper in jmap-clientgetEmails,searchEmails,getRecentEmails,advancedSearch) passcalculateTotal: trueand returnQueryResultwith items + totalformatQueryResult()helper generates the summary linelist_emails,search_emails, andadvanced_searchThis gives AI clients visibility into how many results exist beyond the returned page, which is useful for deciding whether to refine a search or paginate.
Test plan
getEmailsreturns QueryResult with totalsearchEmailsreturns QueryResult with totalgetRecentEmailsreturns QueryResult with totaladvancedSearchreturns QueryResult with totalformatQueryResultgenerates correct summary lines