Skip to content

fix: Apply comments' suggestions on summary and translation PRs#2926

Open
Elouan1411 wants to merge 7 commits into
translate-emailfrom
corrected-comments-summary-translation
Open

fix: Apply comments' suggestions on summary and translation PRs#2926
Elouan1411 wants to merge 7 commits into
translate-emailfrom
corrected-comments-summary-translation

Conversation

@Elouan1411
Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings June 2, 2026 09:46
@Elouan1411 Elouan1411 changed the base branch from main to translate-email June 2, 2026 09:47
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Despite the title suggesting only a comment fix, this PR is a broader cleanup around the AI Summary/Translate flow. It removes the now-unused actionCloseSummaryWindow string in the base locale and 12 translations, renames the Matomo event SummarySummarize (and updates its single call site), renames AiProcessState.Error.isRetryisRetryAttempt, adds a GPL license header to ic_paragraph_shorten.xml, reorders operations in getCurrentLanguageCode, simplifies setTranslateUi/setSummaryUi away from with(...), and—most substantially—moves the AI summary/translate state machine (timers, API calls, body updates) from ThreadFragment into ThreadViewModel, surfacing UI updates via a new aiStateUpdates: SingleLiveEvent<AiStateUpdate> and new AiAction/AiBodyUpdate types.

Changes:

  • Refactor AI summary/translate logic from ThreadFragment into ThreadViewModel, with retry timers, state map updates and a new AiStateUpdate event consumed by the fragment.
  • Rename AiProcessState.Error.isRetryisRetryAttempt (with adapter updated) and Matomo SummarySummarize.
  • Remove the unused actionCloseSummaryWindow string from base + 12 locale files; add license header to ic_paragraph_shorten.xml; minor tweaks to getCurrentLanguageCode and MailActionsBottomSheetDialog UI setters.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
app/src/main/res/values/strings.xml Removes unused actionCloseSummaryWindow base string.
app/src/main/res/values-{da,de,el,es,fi,fr,it,nb,nl,pl,pt,sv}/strings.xml Removes the corresponding translated actionCloseSummaryWindow entries.
app/src/main/res/drawable/ic_paragraph_shorten.xml Adds GPL license header.
app/src/main/java/com/infomaniak/mail/utils/extensions/ContextExt.kt Reorders take(2).lowercase() and trims a trailing blank line.
app/src/main/java/com/infomaniak/mail/ui/main/thread/ThreadViewModel.kt Adds AI action orchestration, retry timers, AiStateUpdate event and related enums.
app/src/main/java/com/infomaniak/mail/ui/main/thread/ThreadState.kt Renames isRetryisRetryAttempt on AiProcessState.Error.
app/src/main/java/com/infomaniak/mail/ui/main/thread/ThreadFragment.kt Delegates AI flow to the view model and observes aiStateUpdates; drops local timers and helpers.
app/src/main/java/com/infomaniak/mail/ui/main/thread/ThreadAdapter.kt Updates AiAction import to the view-model namespace, renames usage to isRetryAttempt, removes stray kotlin.context import.
app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/MessageActionsBottomSheetDialog.kt Tracks MatomoName.Summarize instead of Summary.
app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/MailActionsBottomSheetDialog.kt Rewrites setTranslateUi/setSummaryUi without with(...).
app/src/main/java/com/infomaniak/mail/MatomoMail.kt Renames Matomo enum entry Summary("summary")Summarize("summarize").
Comments suppressed due to low confidence (1)

app/src/main/java/com/infomaniak/mail/ui/main/thread/ThreadFragment.kt:294

  • After the refactor, onDestroyView no longer does any AI-related cleanup, but a stray blank line was left at the start of the method body. Please remove it to match the style of the surrounding overrides.
    override fun onDestroyView() {

        threadAdapter.resetCallbacks()
        super.onDestroyView()
        _binding = null

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/src/main/java/com/infomaniak/mail/ui/main/thread/ThreadViewModel.kt Outdated

val result = when (aiAction) {
AiAction.SUMMARY -> ApiRepository.aiSummary(languageCode, content)
AiAction.TRANSLATE -> ApiRepository.aiTranslate(languageCode, mailbox().uuid, messageUid)
Comment thread app/src/main/java/com/infomaniak/mail/ui/main/thread/ThreadFragment.kt Outdated
@Elouan1411 Elouan1411 changed the title Fix: Correct comments on summary translation PR Fix: Correct comments on summary and translation PRs Jun 2, 2026
@Elouan1411 Elouan1411 force-pushed the corrected-comments-summary-translation branch from fc7baa4 to b36f3a3 Compare June 2, 2026 09:50
@Elouan1411 Elouan1411 changed the title Fix: Correct comments on summary and translation PRs fix: Correct comments on summary and translation PRs Jun 2, 2026
@Elouan1411 Elouan1411 force-pushed the corrected-comments-summary-translation branch from b36f3a3 to cb64a93 Compare June 2, 2026 13:51
@FabianDevel FabianDevel changed the title fix: Correct comments on summary and translation PRs fix: Apply comments' suggestions on summary and translation PRs Jun 3, 2026
Comment on lines +1062 to +1063
AiAction.SUMMARY -> ThreadAdapter.NotifyType.AiSummaryStateChanged
AiAction.TRANSLATE -> ThreadAdapter.NotifyType.AiTranslateStateChanged
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AiAction.SUMMARY -> ThreadAdapter.NotifyType.AiSummaryStateChanged
AiAction.TRANSLATE -> ThreadAdapter.NotifyType.AiTranslateStateChanged
AiAction.SUMMARY -> NotifyType.AiSummaryStateChanged
AiAction.TRANSLATE -> NotifyType.AiTranslateStateChanged

Copy link
Copy Markdown
Contributor

@FabianDevel FabianDevel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to extract the whole code of your actions to another viewModel 'AiActionsViewModel' or to a manager

@Elouan1411 Elouan1411 force-pushed the corrected-comments-summary-translation branch from d50fbd7 to 972f513 Compare June 3, 2026 15:10
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 3, 2026

isVisible = true
fun setSummaryUi(isEnabled: Boolean) {
binding.summary.isEnabled = isEnabled
binding.summary.isVisible = true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why changing that ?

}

val cleanCode = languageCode?.lowercase()?.take(2) ?: defaultLanguage
val cleanCode = languageCode?.take(2)?.lowercase() ?: defaultLanguage
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the same ... right ?

hideButtonProgress(R.string.aiButtonRetry)

if (state.isRetry && !state.wasLoaderShown) {
if (state.asAlreadyRetried && !state.wasLoaderShown) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean hasAlreadyRetried ?

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.

4 participants