-
Notifications
You must be signed in to change notification settings - Fork 887
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
[AI Chat] fix issues with conversation context menu #26990
base: master
Are you sure you want to change the base?
Conversation
16e68d6
to
78b50d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm assuming Nala bump is separated
conversation->title = title; | ||
void AIChatService::OnConversationTitleChanged( | ||
const std::string& conversation_uuid, | ||
const std::string& new_title) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this just take a std::string
so we can move the new_title
into this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as discussed in the slack thread, doesn't seem like it's worth the optimization
auto& conversation_metadata = conversation_it->second; | ||
conversation_metadata->title = new_title; | ||
|
||
OnConversationListChanged(); | ||
|
||
// Persist the change | ||
if (ai_chat_db_) { | ||
ai_chat_db_ | ||
.AsyncCall(base::IgnoreResult(&AIChatDatabase::UpdateConversationTitle)) | ||
.WithArgs(handler->get_conversation_uuid(), std::move(title)); | ||
.WithArgs(conversation_uuid, new_title); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we just take a std::string
:
auto& conversation_metadata = conversation_it->second; | |
conversation_metadata->title = new_title; | |
OnConversationListChanged(); | |
// Persist the change | |
if (ai_chat_db_) { | |
ai_chat_db_ | |
.AsyncCall(base::IgnoreResult(&AIChatDatabase::UpdateConversationTitle)) | |
.WithArgs(handler->get_conversation_uuid(), std::move(title)); | |
.WithArgs(conversation_uuid, new_title); | |
auto& conversation_metadata = conversation_it->second; | |
conversation_metadata->title = std::move(new_title); | |
OnConversationListChanged(); | |
// Persist the change | |
if (ai_chat_db_) { | |
ai_chat_db_ | |
.AsyncCall(base::IgnoreResult(&AIChatDatabase::UpdateConversationTitle)) | |
.WithArgs(conversation_uuid, conversation_metadata->title); |
@@ -1685,7 +1685,7 @@ void ConversationHandler::OnClientConnectionChanged() { | |||
|
|||
void ConversationHandler::OnConversationTitleChanged(std::string title) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this take a const std::string&
or a string_view
? It's not doing anything async
@@ -1685,7 +1685,7 @@ void ConversationHandler::OnClientConnectionChanged() { | |||
|
|||
void ConversationHandler::OnConversationTitleChanged(std::string title) { | |||
for (auto& observer : observers_) { | |||
observer.OnConversationTitleChanged(this, title); | |||
observer.OnConversationTitleChanged(metadata_->uuid, title); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one is a const std::string&
const [isButtonMenuVisible, setIsButtonMenuVisible] = React.useState(false) | ||
const [isOptionsMenuOpen, setIsOptionsMenuOpen] = React.useState(false) | ||
|
||
const handleButtonMenuChange = React.useCallback((e: {isOpen: boolean}) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional: with stuff like this where you're at a leaf node, I think its okay to not wrap things in a useCallback
(or do it inline)
Up to you on this one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just wasn't sure if our web component would cause a new listener to be added (and the old one removed) on every single render. But I suppose we're doing that everywhere anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will 😆 - but its the same with every other component that does this so 🤷
And with React compiler it will (probably) Just Work (tm)
className={styles.displayTitle} | ||
onMouseEnter={() => setIsButtonMenuVisible(true)} | ||
onMouseLeave={() => setIsButtonMenuVisible(false)} | ||
className={classnames(styles.displayTitle, isOptionsMenuOpen && styles.isOptionsMenuOpen)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a handy util taher added!
@@ -28,11 +28,11 @@ function SearchSummary (props: { searchQueries: string[] }) { | |||
const message = formatMessage(getLocale('searchQueries'), { | |||
placeholders: { | |||
$1: props.searchQueries.map((query, i, a) => ( | |||
<> | |||
<React.Fragment key={i}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 you're a hero - these errors drive me nuts
// Unknown events should be ignored | ||
return null | ||
} | ||
|
||
export default function AssistantResponse(props: { entry: Mojom.ConversationTurn, isEntryInProgress: boolean }) { | ||
const searchQueriesEvent = props.entry.events?.find(event => !!event.searchQueriesEvent)?.searchQueriesEvent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
superfluous !!
const searchQueriesEvent = props.entry.events?.find(event => !!event.searchQueriesEvent)?.searchQueriesEvent | |
const searchQueriesEvent = props.entry.events?.find(event => event.searchQueriesEvent)?.searchQueriesEvent |
export default function AssistantResponse(props: { entry: Mojom.ConversationTurn, isEntryInProgress: boolean }) { | ||
const searchQueriesEvent = props.entry.events?.find(event => !!event.searchQueriesEvent)?.searchQueriesEvent | ||
const hasCompletionStarted = !props.isEntryInProgress || props.entry.events?.find(event => !!event.completionEvent) | ||
const hasCompletionStarted = !props.isEntryInProgress || | ||
(props.entry.events?.some(event => !!event.completionEvent) ?? false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
superfluous !!
(props.entry.events?.some(event => !!event.completionEvent) ?? false) | |
(props.entry.events?.some(event => event.completionEvent) ?? false) |
optional:
(props.entry.events?.some(event => !!event.completionEvent) ?? false) | |
const hasCompletionStarted = props.isEntryInProgress | |
|| !!props.entry.events?.some(e => e.completionEvent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been studying this for a good few minutes and I still can't quickly reason with the names here, or how your suggestion is equivalent to what's there at the moment. Not introduced in this PR but I think we can improve it at some point.
ce3b00c
to
84b6868
Compare
|
78b50d7
to
4004682
Compare
8cd1e4c
to
f086917
Compare
A Storybook has been deployed to preview UI for the latest push |
1e12113
to
0f6e891
Compare
- ButtonMenu can open without being tiny and scrolling - make sure edit isn't blocked by the link activation - storybook get edit ability
and log database title because of historical bad values due to ref expiring
storybook context can use react hooks
0f6e891
to
dd1e08f
Compare
Blocked on:
Resolves
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: