Skip to content

Commit c88326e

Browse files
authored
Merge pull request #5 from CodeRifle/jules-18062725759943665074-25baba07
Fix Chrome AI Initialization and Remove Custom Domain
2 parents 396a470 + d776af7 commit c88326e

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎script.js‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ async function initializeSession() {
5050
}
5151
}
5252

53-
// Call initializeSession when the script loads
54-
initializeSession();
53+
// Initialize session on user gesture instead of script load
5554

5655

5756
function addMessage(message, isUser = false) {
@@ -88,7 +87,12 @@ async function sendMessage() {
8887
simulateTyping(); // Show typing indicator
8988

9089
if (!modelSession) {
91-
addMessage("Chat assistant is not available. Session not initialized.", false);
90+
await initializeSession();
91+
}
92+
93+
if (!modelSession) {
94+
// If it's still null after attempting to initialize
95+
addMessage("Chat assistant is not available. Session could not be initialized.", false);
9296
typingIndicator.style.display = 'none';
9397
return;
9498
}

0 commit comments

Comments
 (0)