{% block title %}chat{% endblock %}
-
+
+
{% block body %}{% endblock %}
diff --git a/chat/templates/chat.html b/chat/templates/chat.html
index 7f16c65..5b1453f 100644
--- a/chat/templates/chat.html
+++ b/chat/templates/chat.html
@@ -162,6 +162,22 @@ document.querySelector('.drawer-toggle')?.addEventListener('click', (e) => {
}
});
+ // Enter-to-send (Shift+Enter for newline). Submits via the form's
+ // own submit event so all the optimistic-render + fetch logic
+ // below applies uniformly to keyboard and click submissions.
+ if (textarea) {
+ textarea.addEventListener('keydown', (e) => {
+ if (e.key === 'Enter' && !e.shiftKey && !e.isComposing) {
+ e.preventDefault();
+ if (typeof form.requestSubmit === 'function') {
+ form.requestSubmit();
+ } else {
+ form.dispatchEvent(new Event('submit', { cancelable: true }));
+ }
+ }
+ });
+ }
+
// Render the user's prose optimistically as a turn-you DOM node.
// Without this the user can't see what they just sent until the page
// reloads — the server persists ``user_turn`` events but doesn't