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

aichat: prevent page from being summarized multiple times #23647

Merged
merged 3 commits into from
May 30, 2024

Conversation

nullhook
Copy link
Contributor

Resolves brave/brave-browser#36541

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:

Comment on lines 470 to 474
if (!has_summarized_) {
suggestions_.emplace_back(
is_video_ ? l10n_util::GetStringUTF8(IDS_CHAT_UI_SUMMARIZE_VIDEO)
: l10n_util::GetStringUTF8(IDS_CHAT_UI_SUMMARIZE_PAGE));
}
Copy link
Contributor Author

@nullhook nullhook May 15, 2024

Choose a reason for hiding this comment

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

another possible solution is to infer whether it's an initial conversation and add summary-related suggestions only then. this can avoid us maintaining an internal state. cc @petemill

Copy link
Member

Choose a reason for hiding this comment

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

Initial conversation? Not sure what that means exactly. In any case it seems ok to keep internal state about has_summarized if it's a requirement of the UI to only show the summarize button if it hasn't been clicked yet.

Copy link
Member

Choose a reason for hiding this comment

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

I suppose the alternative (perhaps better?) is to check if any history items have action_type == mojom::ActionType::SUMMARIZE_PAGE (or ..._VIDEO)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

checking history now. updated.

Copy link
Member

@petemill petemill left a comment

Choose a reason for hiding this comment

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

Perhaps it's better to check the history?

@nullhook nullhook requested a review from petemill May 16, 2024 18:49
@@ -10,6 +10,7 @@
#include <optional>
#include <string>
#include <string_view>
#include <utility>
Copy link
Member

Choose a reason for hiding this comment

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

this addition doesn't seem related?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was left out in one of your PRs (conversation api one?) which resulted in the following format issue

../components/ai_chat/core/browser/conversation_driver.h:147: (cpplint) Add #include for move [build/include_what_you_use] [4]

@nullhook nullhook merged commit 3fecd7d into master May 30, 2024
19 checks passed
@nullhook nullhook deleted the aichat-summarize-twice branch May 30, 2024 16:09
@github-actions github-actions bot added this to the 1.68.x - Nightly milestone May 30, 2024
brave-builds added a commit that referenced this pull request May 31, 2024
@stephendonner
Copy link
Collaborator

stephendonner commented May 31, 2024

Verification PASSED using

Brave | 1.68.65 Chromium: 126.0.6478.26 (Official Build) nightly (x86_64)
-- | --
Revision | 2b1404f75647a5223f109757d4551c7a045532b7
OS | macOS Version 11.7.10 (Build 20G1427)

First, easily reproduced the issue using both mentioned methods (context menu, open and close tab), using 1.67.100 Chromium: 125.0.6422.112 (Official Build) beta (x86_64):

Screen Shot 2024-05-31 at 3 19 36 PM

Case 1: context-menu - PASSED

Steps:

  1. installed 1.68.65
  2. launched Brave
  3. loaded https://www.wired.com/story/google-ai-overviews-broken-how-ai-works/
  4. clicked on Leo in the sidebar
  5. clicked on Summarize this page
  6. clicked on I understand
  7. confirmed page summarization
  8. confirmed only Suggest questions... appeared beneath the response
  9. highlighted the first paragraph
  10. selected Leo AI Tools --> Summarize

Confirmed although it summarized the selected paragraph, the Summarize this page button no longer re-appeared

example example example
Screen Shot 2024-05-31 at 3 31 24 PM Screen Shot 2024-05-31 at 3 43 24 PM Screen Shot 2024-05-31 at 3 43 41 PM

Case 2: open and close Leo panel/sidebar - PASSED

Steps:

  1. installed 1.68.65
  2. launched Brave
  3. loaded https://abcnews.go.com/Health/whooping-cough-cases-rise-3-times-high-year/story?id=110708078
  4. clicked on Leo in the sidebar
  5. clicked on Summarize this page
  6. clicked on I understand
  7. confirmed page summarization
  8. confirmed only Suggest questions... appeared beneath the response
  9. clicked on Suggest questions...
  10. closed and reopened the Leo panel
  11. confirmed only Suggest questions... buttons remained
example example example example
Screen Shot 2024-05-31 at 4 03 31 PM Screen Shot 2024-05-31 at 4 03 37 PM Screen Shot 2024-05-31 at 4 03 42 PM Screen Shot 2024-05-31 at 4 03 52 PM

nullhook pushed a commit that referenced this pull request Jun 3, 2024
kjozwiak pushed a commit that referenced this pull request Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants