nextcloud / nextcloud/mail

Add an option to only summarize last email for thread summaries

Open
#12,945 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

1. to develop enhancement
Dominant language
JavaScript
Stars
1k
Forks
348
Avg merge
12h 28m
Merged PRs (30d)
91

Description

Is your feature request related to a problem? Please describe.

Hi team,
It would be great to have an option (like a toggle button or something like that) to only send the last email to the AI for the "Thread summary" feature. The reason is that normally the other emails are already included in the body of the last email, so it's a waste of tokens and time sending/processing the same information a lot of times (once per email in the thread).

Describe the solution you'd like

Add a button in Mail's configuration that enables code like:

Instead of the $messagesBodies in
https://github.com/nextcloud/mail/blob/203ce3603f6abf3640dbc4856e422162a55e5531/lib/Service/AiIntegrations/AiIntegrationsService.php#L146

Have only the body of the last one:

$lastMessage = $messages[array_key_last($messages)];
$mailbox = $this->mailManager->getMailbox($currentUserId, $lastMessage->getMailboxId());
$imapMessage = $this->mailManager->getImapMessage(
    $client,
    $account,
    $mailbox,
    $lastMessage->getUid(), true
);
$messagesBodies = [$imapMessage->getPlainBody()];
Describe alternatives you've considered

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/Service/AiIntegrations/AiIntegrationsService.php around line 146 and trace how thread summaries assemble message bodies. Then inspect Mail's configuration entry points for where the option should be exposed. Done means the setting can enable sending only the last email's plain body to the AI, while the existing behavior remains available.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
ai, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
60/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.