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 6008b88 commit 13d9fbf
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 27 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
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
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,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 @@ -198,7 +200,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 @@ -243,9 +243,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 13d9fbf

Please sign in to comment.