Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chat-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ async function pollinationsFetch(url, options = {}, { timeoutMs = 45000 } = {})
try {
const res = await fetch(
url,
{ ...options, signal: controller.signal, cache: 'no-store' }
{ ...options, signal: controller.signal, cache: 'no-store' } // fixed: spread options
);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res;
Expand Down
20 changes: 12 additions & 8 deletions chat-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,16 +572,20 @@ document.addEventListener("DOMContentLoaded", () => {
});
sendButton.addEventListener("click", handleSendMessage);

// Send on Enter, allow newline with Shift+Enter
// Send on Enter; newline with Shift+Enter
chatInput.addEventListener('keydown', (e) => {
if (e.key === 'Enter') {
if (e.shiftKey) return; // allow newline
e.preventDefault();
// Directly invoke the send handler so the message is processed
// even if the button state would block programmatic clicks.
handleSendMessage();
// IME safety and repeats
if (e.isComposing || e.key !== 'Enter') return;

if (e.shiftKey) {
// allow newline
return;
}
});

e.preventDefault();
// Do not rely on button state—call the handler directly.
handleSendMessage();
}, { once: false });
sendButton.disabled = chatInput.value.trim() === "";
chatInput.dispatchEvent(new Event("input"));
const initialSession = Storage.getCurrentSession();
Expand Down
24 changes: 0 additions & 24 deletions chat-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,30 +602,6 @@ document.addEventListener("DOMContentLoaded", () => {
console.log("Click detected on image-button-container, preventing propagation");
}
}, true);
const sendButton = document.getElementById("send-button");
function handleSendMessage() {
const message = chatInput.value.trim();
if (message === "") return;
window.addNewMessage({ role: "user", content: message });
chatInput.value = "";
chatInput.style.height = "auto";
window.sendToPollinations(() => {
sendButton.disabled = false;
chatInput.disabled = false;
chatInput.focus();
});
sendButton.disabled = true;
chatInput.disabled = true;
}
chatInput.addEventListener("input", () => {
sendButton.disabled = chatInput.value.trim() === "";
chatInput.style.height = "auto";
chatInput.style.height = chatInput.scrollHeight + "px";
});
sendButton.addEventListener("click", () => {
handleSendMessage();
});
sendButton.disabled = chatInput.value.trim() === "";
const initialSession = Storage.getCurrentSession();
if (initialSession.messages && initialSession.messages.length > 0) {
renderStoredMessages(initialSession.messages);
Expand Down