Skip to content

feat(gmail): Add thread message count to search results#99

Merged
steipete merged 1 commit intoopenclaw:mainfrom
jeanregisser:add-thread-count-indicator-new
Jan 21, 2026
Merged

feat(gmail): Add thread message count to search results#99
steipete merged 1 commit intoopenclaw:mainfrom
jeanregisser:add-thread-count-indicator-new

Conversation

@jeanregisser
Copy link
Copy Markdown
Contributor

@jeanregisser jeanregisser commented Jan 20, 2026

Show message count in search output to help agents and users understand when an email is part of a multi-message conversation.

Problem

When searching Gmail via gog gmail search, the results show thread IDs but not the number of messages in each thread. This makes it difficult for AI agents (and humans) to determine if a message is a standalone email or part of a conversation.

Example scenario:

  • User asks agent: "Are there any new emails from Claire?"
  • Agent runs gog gmail search 'newer_than:1d'
  • Results show "Meilleurs vœux 2026" from Claire
  • Agent reads the email and sees it's a New Year's greeting
  • Missing: The agent doesn't see that there are 6 messages in this thread with a back-and-forth conversation

Solution

This PR adds message count to the search output:

Before:

ID  DATE  FROM  SUBJECT  LABELS
19b97acb5adefd83  Jan 20  Claire  Meilleurs vœux 2026  CATEGORY_PERSONAL,INBOX

After:

ID  DATE  FROM  SUBJECT  LABELS  THREAD
19b97acb5adefd83  Jan 20  Claire  Meilleurs vœux 2026  CATEGORY_PERSONAL,INBOX  [6 msgs]

Single-message emails show -, multi-message threads show [X msgs].
The LABELS column is preserved for backward compatibility.

Changes

  1. Added MessageCount field to threadItem struct (for JSON output)
  2. Populated message count from len(thread.Messages) in fetchThreadDetails
  3. Added new THREAD column showing [X msgs] for threads, - for single messages
  4. Preserved LABELS column for backward compatibility
  5. JSON output includes messageCount field for programmatic access

Feedback Requested

  • Should the THREAD column be moved closer to the beginning (e.g., right after SUBJECT instead of at the end)?
  • Is the [X msgs] format clear, or should we just show the raw count (e.g., 6 instead of [6 msgs])?
  • Alternative approaches for making thread context visible?

Additional Notes

I considered updating the gogcli skill documentation to reduce confusion around when to use gog gmail get vs gog gmail thread get. However, having thread message count visible in search results benefits all users, not just agents — similar to how Gmail's web UI shows conversation counts.

I was using MiniMax M2.1 for this session. It's unclear if a more capable model like Claude Opus would have been less confused by the lack of thread context, but making this information explicit removes the ambiguity entirely.

Testing

  • All existing Gmail tests pass
  • Manual testing confirms:
    • Both LABELS and THREAD columns are displayed
    • Single messages show - in THREAD column
    • Multi-message threads show [X msgs] (e.g., [6 msgs])
    • JSON output includes messageCount field

Show message count in search output to help agents and users understand
when an email is part of a multi-message conversation.

Before:
  ID  DATE  FROM  SUBJECT  LABELS
  xxx Jan 20  John  Hello    INBOX

After:
  ID  DATE  FROM  SUBJECT  LABELS  THREAD
  xxx Jan 20  John  Hello    INBOX   [3 msgs]

Problem:
When searching Gmail, the results show thread IDs but not the number of
messages in each thread. This makes it hard for AI agents to determine
if a message is a standalone email or part of a conversation. Agents
often miss full thread context when they only fetch a single message.

Solution:
- Add MessageCount field to threadItem struct
- Populate message count from thread.Messages
- Add new THREAD column: [X msgs] for threads, - for single messages
- Keep LABELS column for backward compatibility
- Include messageCount in JSON output for programmatic access
- Update tests to verify MessageCount in JSON output

Prompt context that inspired this change:
> I'm using gogcli from an AI agent and I was looking at recent emails.
> I searched for emails from today and found an email from Claire but I
> couldn't see that there were replies in the thread. The search results
> only showed the original email, not the replies.

This change makes it immediately visible when search results contain
threads with multiple messages, allowing agents to fetch the full thread
when needed.
@steipete steipete merged commit c2b784a into openclaw:main Jan 21, 2026
4 checks passed
@steipete
Copy link
Copy Markdown
Collaborator

Landed via temp rebase onto main.\n\n- Gate: pnpm lint && pnpm build && pnpm test\n- Land commit: b6a19e6\n- Merge commit: c2b784a\n\nThanks @jeanregisser!

vidarbrekke added a commit to vidarbrekke/gogcli-enhanced that referenced this pull request Mar 6, 2026
…ounts openclaw#99; changelog only, feature already on main)

Made-with: Cursor
klodr pushed a commit to klodr/gogcli that referenced this pull request Apr 22, 2026
…icator-new

feat(gmail): Add thread message count to search results
klodr pushed a commit to klodr/gogcli that referenced this pull request Apr 22, 2026
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.

2 participants