Skip to content

Commit

Permalink
build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
petemill committed Oct 22, 2024
1 parent 658c1da commit 988abbe
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 28 deletions.
4 changes: 2 additions & 2 deletions browser/ai_chat/ai_chat_throttle_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ INSTANTIATE_TEST_SUITE_P(
info.param ? "Enabled" : "Disabled");
});

TEST_F(AiChatThrottleUnitTest, CancelNavigationFromTab) {
TEST_P(AiChatThrottleUnitTest, CancelNavigationFromTab) {
content::MockNavigationHandle test_handle(web_contents());

test_handle.set_url(GURL("chrome-untrusted://chat"));
Expand Down Expand Up @@ -99,7 +99,7 @@ TEST_F(AiChatThrottleUnitTest, CancelNavigationFromTab) {
}
}

TEST_F(AiChatThrottleUnitTest, AllowNavigationFromPanel) {
TEST_P(AiChatThrottleUnitTest, AllowNavigationFromPanel) {
content::MockNavigationHandle test_handle(web_contents());

test_handle.set_url(GURL("chrome-untrusted://chat"));
Expand Down
1 change: 1 addition & 0 deletions browser/ui/webui/ai_chat/ai_chat_ui_page_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define BRAVE_BROWSER_UI_WEBUI_AI_CHAT_AI_CHAT_UI_PAGE_HANDLER_H_

#include <memory>
#include <string>

#include "base/memory/weak_ptr.h"
#include "base/scoped_observation.h"
Expand Down
20 changes: 2 additions & 18 deletions components/ai_chat/core/browser/ai_chat_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ ConversationHandler* AIChatService::CreateConversation() {
// Create the conversation metadata
{
mojom::ConversationPtr conversation = mojom::Conversation::New(
conversation_uuid, "", "", base::Time::Now(), false);
conversation_uuid, "", base::Time::Now(), false);
conversations_.insert_or_assign(conversation_uuid, std::move(conversation));
}
mojom::Conversation* conversation =
Expand Down Expand Up @@ -299,12 +299,10 @@ void AIChatService::OnConversationEntriesChanged(
CHECK(conversation_it != conversations_.end());
auto& conversation = conversation_it->second;
if (!entries.empty()) {
bool notify = false;
// First time a new entry has appeared
if (!conversation->has_content && entries.size() == 1) {
// This conversation is visible once the first response begins
conversation->has_content = true;
notify = true;
if (ai_chat_metrics_ != nullptr) {
if (entries.size() == 1) {
ai_chat_metrics_->RecordNewChat();
Expand All @@ -315,22 +313,8 @@ void AIChatService::OnConversationEntriesChanged(
if (entries.back()->character_type == mojom::CharacterType::HUMAN) {
ai_chat_metrics_->RecordNewPrompt();
}
if (entries.size() >= 2) {
if (conversation->summary.size() < 70) {
for (const auto& entry : entries) {
if (entry->character_type == mojom::CharacterType::ASSISTANT &&
!entry->text.empty()) {
conversation->summary = entry->text.substr(0, 70);
notify = true;
break;
}
}
}
}
if (notify) {
OnConversationListChanged();
}
}
OnConversationListChanged();
}
// TODO(petemill): Persist the entries, but consider receiving finer grained
// entry update events.
Expand Down
2 changes: 2 additions & 0 deletions components/ai_chat/core/browser/ai_chat_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ class MockConversationHandlerClient : public mojom::ConversationUI {

MOCK_METHOD(void, OnFaviconImageDataChanged, (), (override));

MOCK_METHOD(void, OnConversationDeleted, (), (override));

private:
mojo::Receiver<mojom::ConversationUI> conversation_ui_receiver_{this};
mojo::Remote<mojom::ConversationHandler> conversation_handler_remote_;
Expand Down
1 change: 0 additions & 1 deletion components/ai_chat/core/browser/conversation_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,6 @@ void ConversationHandler::UpdateOrCreateLastAssistantEntry(
return;
}


entry->events->push_back(std::move(event));
// Update clients for partial entries but not observers, who will get notified
// when we know this is a complete entry.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ class MockConversationHandlerClient : public mojom::ConversationUI {

MOCK_METHOD(void, OnFaviconImageDataChanged, (), (override));

MOCK_METHOD(void, OnConversationDeleted, (), (override));

private:
mojo::Receiver<mojom::ConversationUI> conversation_ui_receiver_{this};
mojo::Remote<mojom::ConversationHandler> conversation_handler_;
Expand Down Expand Up @@ -200,7 +202,8 @@ class ConversationHandlerUnitTest : public testing::Test {
model_service_.get(), std::move(credential_manager), &prefs_, nullptr,
shared_url_loader_factory_, "");

conversation_ = mojom::Conversation::New("uuid", "title", false);
conversation_ =
mojom::Conversation::New("uuid", "title", base::Time::Now(), false);

conversation_handler_ = std::make_unique<ConversationHandler>(
conversation_.get(), ai_chat_service_.get(), model_service_.get(),
Expand Down
4 changes: 1 addition & 3 deletions components/ai_chat/core/common/mojom/ai_chat.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,7 @@ struct Conversation {
string uuid;
// Set by the LLM or the user
string title;
// First few characters of content, used if title isn't set
// or where more context is needed.
string summary;
// Time used for ordering purposes
mojo_base.mojom.Time created_time;
// If there are entries and the conversation should be selectable
bool has_content;
Expand Down
2 changes: 0 additions & 2 deletions components/ai_chat/resources/page/components/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ const Logo = ({ isPremium }: { isPremium: boolean }) => <div className={styles.l
</div>

const getTitle = (activeConversation?: Conversation) => activeConversation?.title
|| activeConversation?.summary
|| getLocale('conversationListUntitled')


const newChatButtonLabel = getLocale('newChatButtonLabel')
const closeButtonLabel = getLocale('closeLabel')
const openFullPageButtonLabel = getLocale('openFullPageLabel')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export default function SidebarNav(props: SidebarNavProps) {
</div>
) : (
<DisplayTitle
title={item.title ? item.title : item.summary ? item.summary : getLocale('conversationListUntitled')}
title={item.title || getLocale('conversationListUntitled')}
description={''}
onEditTitle={() => aiChatContext.setEditingConversationId(item.uuid)}
onDelete={() => getAPI().Service.deleteConversation(item.uuid)}
Expand Down

0 comments on commit 988abbe

Please sign in to comment.