diff --git a/browser/ai_chat/ai_chat_throttle_unittest.cc b/browser/ai_chat/ai_chat_throttle_unittest.cc index e88c69e0e0f7..4cf514656885 100644 --- a/browser/ai_chat/ai_chat_throttle_unittest.cc +++ b/browser/ai_chat/ai_chat_throttle_unittest.cc @@ -77,7 +77,7 @@ INSTANTIATE_TEST_SUITE_P( TEST_P(AiChatThrottleUnitTest, CancelNavigationFromTab) { content::MockNavigationHandle test_handle(web_contents()); - test_handle.set_url(GURL(kAIChatUIURL)()); + test_handle.set_url(GURL(kAIChatUIURL)); #if BUILDFLAG(IS_ANDROID) ui::PageTransition transition = ui::PageTransitionFromInt( @@ -105,7 +105,7 @@ TEST_P(AiChatThrottleUnitTest, CancelNavigationFromTab) { TEST_P(AiChatThrottleUnitTest, CancelNavigationToFrame) { content::MockNavigationHandle test_handle(web_contents()); - test_handle.set_url(GURL(kAIChatUntrustedConversationUIURL)()); + test_handle.set_url(GURL(kAIChatUntrustedConversationUIURL)); #if BUILDFLAG(IS_ANDROID) ui::PageTransition transition = ui::PageTransitionFromInt( @@ -128,7 +128,7 @@ TEST_P(AiChatThrottleUnitTest, CancelNavigationToFrame) { TEST_P(AiChatThrottleUnitTest, AllowNavigationFromPanel) { content::MockNavigationHandle test_handle(web_contents()); - test_handle.set_url(GURL(kAIChatUIURL)()); + test_handle.set_url(GURL(kAIChatUIURL)); #if BUILDFLAG(IS_ANDROID) ui::PageTransition transition = diff --git a/browser/ui/webui/ai_chat/ai_chat_untrusted_conversation_ui.cc b/browser/ui/webui/ai_chat/ai_chat_untrusted_conversation_ui.cc index f86a077dad01..7378cfdfcbcb 100644 --- a/browser/ui/webui/ai_chat/ai_chat_untrusted_conversation_ui.cc +++ b/browser/ui/webui/ai_chat/ai_chat_untrusted_conversation_ui.cc @@ -152,7 +152,7 @@ AIChatUntrustedConversationUI::AIChatUntrustedConversationUI( "img-src 'self' blob: chrome-untrusted://resources;"); source->OverrideContentSecurityPolicy( network::mojom::CSPDirectiveName::FontSrc, - "font-src 'self' data: chrome-untrusted://resources;"); + "font-src 'self' chrome-untrusted://resources;"); source->OverrideContentSecurityPolicy( network::mojom::CSPDirectiveName::FrameAncestors, base::StringPrintf("frame-ancestors %s;", kAIChatUIURL)); diff --git a/ios/brave-ios/Sources/AIChat/Components/AIChatView.swift b/ios/brave-ios/Sources/AIChat/Components/AIChatView.swift index ab6bc0193844..8262b8de52ac 100644 --- a/ios/brave-ios/Sources/AIChat/Components/AIChatView.swift +++ b/ios/brave-ios/Sources/AIChat/Components/AIChatView.swift @@ -507,7 +507,7 @@ public struct AIChatView: View { icon: Image(braveSystemName: "leo.thumb.up"), onSelected: { Task { @MainActor in - let ratingId = await model.rateConversation(isLiked: true, turnId: UInt(turnIndex)) + let ratingId = await model.rateConversation(isLiked: true, turnId: turn.uuid) if ratingId != nil { feedbackToast = .success(isLiked: true) } else { @@ -522,7 +522,7 @@ public struct AIChatView: View { icon: Image(braveSystemName: "leo.thumb.down"), onSelected: { Task { @MainActor in - let ratingId = await model.rateConversation(isLiked: false, turnId: UInt(turnIndex)) + let ratingId = await model.rateConversation(isLiked: false, turnId: turn.uuid) if let ratingId = ratingId { feedbackToast = .success( isLiked: false, diff --git a/ios/brave-ios/Sources/AIChat/ModelView/AIChatViewModel.swift b/ios/brave-ios/Sources/AIChat/ModelView/AIChatViewModel.swift index 9662538f107b..1e66e25e44bc 100644 --- a/ios/brave-ios/Sources/AIChat/ModelView/AIChatViewModel.swift +++ b/ios/brave-ios/Sources/AIChat/ModelView/AIChatViewModel.swift @@ -209,7 +209,7 @@ public class AIChatViewModel: NSObject, ObservableObject { } @MainActor - func rateConversation(isLiked: Bool, turnId: UInt) async -> String? { + func rateConversation(isLiked: Bool, turnId: String) async -> String? { return await api.rateMessage(isLiked, turnId: turnId) } diff --git a/ios/browser/api/ai_chat/BUILD.gn b/ios/browser/api/ai_chat/BUILD.gn index 1b40a6fd3610..b71e081cfe5a 100644 --- a/ios/browser/api/ai_chat/BUILD.gn +++ b/ios/browser/api/ai_chat/BUILD.gn @@ -67,18 +67,23 @@ source_set("ai_chat") { ios_objc_mojom_wrappers("ai_chat_mojom_wrappers") { mojom_target = "//brave/components/ai_chat/core/common/mojom" - sources = [ "//brave/components/ai_chat/core/common/mojom/ai_chat.mojom" ] + sources = [ + "//brave/components/ai_chat/core/common/mojom/ai_chat.mojom", + "//brave/components/ai_chat/core/common/mojom/untrusted_frame.mojom", + ] output_dir = "$root_gen_dir/brave/components/ai_chat/core/common/mojom/ios" - + generate_namespace = false # These types have pending_receiver arguments which aren't # supported in objc_mojom_wrappers, but should be refactored to support # binding to them for iOS. exclude_types = [ "AIChatUIHandler", + "ChatUI", + "ConversationEntriesState", + "ParentUIFrame", "Service", "UntrustedConversationHandler", "UntrustedConversationUI", - "ConversationEntriesState", - "ChatUI", + "UntrustedUIHandler", ] } diff --git a/ios/browser/api/ai_chat/ai_chat.h b/ios/browser/api/ai_chat/ai_chat.h index 60b8d58037ba..8c365648588b 100644 --- a/ios/browser/api/ai_chat/ai_chat.h +++ b/ios/browser/api/ai_chat/ai_chat.h @@ -47,7 +47,7 @@ OBJC_EXPORT actionType:(AiChatActionType)actionType; - (void)rateMessage:(bool)isLiked - turnId:(NSUInteger)turnId + turnId:(NSString*)turnId completion: (void (^_Nullable)(NSString* _Nullable identifier))completion; diff --git a/ios/browser/api/ai_chat/ai_chat.mm b/ios/browser/api/ai_chat/ai_chat.mm index 387930908b83..92ecf8e83c10 100644 --- a/ios/browser/api/ai_chat/ai_chat.mm +++ b/ios/browser/api/ai_chat/ai_chat.mm @@ -193,10 +193,10 @@ - (void)submitSelectedText:(NSString*)selectedText } - (void)rateMessage:(bool)isLiked - turnId:(NSUInteger)turnId + turnId:(NSString*)turnId completion:(void (^)(NSString* identifier))completion { current_conversation_->RateMessage( - isLiked, turnId, + isLiked, base::SysNSStringToUTF8(turnId), base::BindOnce( [](void (^completion)(NSString*), const std::optional& identifier) {