Skip to content
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

Adds preferences and methods to delete Leo conversations on Android #27074

Merged
merged 2 commits into from
Dec 20, 2024

Conversation

SergeyZhukovsky
Copy link
Member

@SergeyZhukovsky SergeyZhukovsky commented Dec 19, 2024

Issues:

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

STR 1:

  1. Make some chats using Leo AI.
  2. Go to Settings->Leo->Delete all Leo AI conversation data and click confirm.
  3. Make sure all chats history is deleted.
    Screenshot_20241219_143501

STR 2:

  1. Make some chats using Leo AI.
  2. Go to Settings->Brave Shields & privacy->Delete browsing data and go to Advanced tab there.
  3. Check Leo AI and click Delete data and confirm it.
  4. Make sure all chats history is deleted.
    Screenshot_20241219_143429

STR 3(make sure that deleting browsing history deletes any related web page visit from conversations):

  1. Go to brave.com.
  2. Open Leo tab and summarize the page.
  3. Make sure you see the website info if you open the summarized conversation from the conversation list.
    Screenshot_20241219_161624
  4. Close Leo tab.
  5. Go to Settings->Brave Shields & privacy->Delete browsing data and go to Basic tab there. Make sure Browsing history is checked there
    Screenshot_20241219_161832
  6. Go to a new tab and open Leo tab from there.
  7. Select the summarized conversation from the conversation list and make sure there is no website info
    Screenshot_20241219_162011

@SergeyZhukovsky
Copy link
Member Author

@diracdeltas let me know do you want me to open an issue for a sec review. I didn't do it as it's basically a fix related to the original sec review for that feature.

Copy link
Contributor

@samartnik samartnik left a comment

Choose a reason for hiding this comment

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

java patching lgtm

if (!service) {
return;
}
service->DeleteConversations();
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we just pass the AIChatService mojo to the UI instead of passing it via the AIChatSettingsHelper mojo?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we ever passed native services to java via mojo. Why do we need that?

Copy link
Member

Choose a reason for hiding this comment

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

we are passing AIChatSettingsHelper to Java and its calling a function which then calls the service function only. So why not just pass the Service to Java now that we have one? AIChatSettingsHelper was made before AIChatService and now that it exists maybe we shouldn't add new things to AIChatSettingsHelper

Copy link
Member Author

Choose a reason for hiding this comment

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

as per discussion in DM we decided to leave as is as there are questions about the service lifetime, there has to be a native object that hold a pointer for Java.

Copy link
Contributor

@AlexeyBarabash AlexeyBarabash left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@deeppandya deeppandya left a comment

Choose a reason for hiding this comment

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

LGTM

@diracdeltas
Copy link
Member

diracdeltas commented Dec 19, 2024

Shivan is out, but the original privacy requirement from https://github.com/brave/reviews/issues/1768#issuecomment-2536586219 said Regular browser history data deletion deletes any related web page visit from conversations.

Is that the case with this PR? If so there should be a test plan that clearing browser history also clears leo or at least any leo conversations with page context. cc @bridiver if this is your understanding since you were involved in the above privacy review.

This is also stated in @petemill 's comment here btw https://github.com/brave/reviews/issues/1703#issuecomment-2523752623. The items below should be implemented on Android before this feature is enabled.

A Notice that encrypted conversation persistance is now enabled is shown to all users (with link to the help center article which explains how to disable it)
There is a setting in Brave's Preferences which disables storage
Regular browser history data deletion deletes any related web page visit from conversations
A new "Leo AI" browser data deletion checkbox deletes all AI conversations

@petemill
Copy link
Member

Shivan is out, but the original privacy requirement from brave/reviews#1768 (comment) said Regular browser history data deletion deletes any related web page visit from conversations.

Is that the case with this PR? If so there should be a test plan that clearing browser history also clears leo or at least any leo conversations with page context. cc @bridiver if this is your understanding since you were involved in the above privacy review.

This is also stated in @petemill 's comment here btw brave/reviews#1703 (comment). The items below should be implemented on Android before this feature is enabled.

A Notice that encrypted conversation persistance is now enabled is shown to all users (with link to the help center article which explains how to disable it)
There is a setting in Brave's Preferences which disables storage
Regular browser history data deletion deletes any related web page visit from conversations
A new "Leo AI" browser data deletion checkbox deletes all AI conversations

I think Android uses the same browser data deletion handling as desktop @diracdeltas

@SergeyZhukovsky
Copy link
Member Author

SergeyZhukovsky commented Dec 19, 2024

Is that the case with this PR? If so there should be a test plan that clearing browser history also clears leo or at least any leo conversations with page context.

@diracdeltas correct it is the case with this PR. I just added STR3 with that case in the test plan.

@@ -22,17 +23,30 @@
import org.chromium.ui.text.SpanApplier.SpanInfo;

public class BraveClearBrowsingDataFragmentAdvanced extends ClearBrowsingDataFragmentAdvanced {
ClearBrowsingDataCheckBoxPreference mClearBrowsingDataCheckBoxPreference;
Copy link
Member

Choose a reason for hiding this comment

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

Should this be named to mention that it's the checkbox for AIChat? e.g. mClearAIChatDataCheckBoxPreference?

Copy link
Member Author

Choose a reason for hiding this comment

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

good point, renaming it

Comment on lines 105 to 123
@Override
protected void onClearBrowsingData() {
super.onClearBrowsingData();
if (mClearBrowsingDataCheckBoxPreference != null
&& mClearBrowsingDataCheckBoxPreference.isChecked()) {
Profile profile = getProfile();
if (profile == null) {
return;
}
BraveLeoMojomHelper.getInstance(profile).deleteConversations();
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

In Desktop's settings WebUI we add a new checkbox with a browser.clear_data.brave_leo key (should have been ai_chat!). The desktop WebUI (and assume somewhere in android preferences) we call browsing_data::GetDataTypeFromDeletionPreference which we override to provide BrowsingDataType::BRAVE_AI_CHAT when the browser.clear_data.brave_leo key is provided. And the rest is handled by the delegate.

Copy link
Member Author

Choose a reason for hiding this comment

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

we basically discussed that in DM it gets triggered on Android, but for Android case we would need to make a lot of patches inside java files by adding extra type inside ClearBrowsingDataFragment.DialogOption and surrounding
functions. I added a comment inside browser/browsing_data/brave_browsing_data_remover_delegate.cc where Android implementation is.

@SergeyZhukovsky SergeyZhukovsky force-pushed the android_delete_leo_history branch from 3df3911 to 10b350a Compare December 20, 2024 16:25
@SergeyZhukovsky SergeyZhukovsky force-pushed the android_delete_leo_history branch from 10b350a to 4d05ccd Compare December 20, 2024 16:46
@SergeyZhukovsky SergeyZhukovsky requested a review from a team December 20, 2024 19:41
Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

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

string reviewers ++

Copy link
Collaborator

@aseren aseren left a comment

Choose a reason for hiding this comment

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

LGTM

@SergeyZhukovsky SergeyZhukovsky merged commit 9f3121e into master Dec 20, 2024
18 checks passed
@SergeyZhukovsky SergeyZhukovsky deleted the android_delete_leo_history branch December 20, 2024 23:52
@github-actions github-actions bot added this to the 1.75.x - Nightly milestone Dec 20, 2024
@brave-builds
Copy link
Collaborator

Released in v1.75.117

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.

Android Settings can delete Leo AI history
9 participants