shelley: don't submit on Enter for mobile input

Philip Zeyliger created

I'm not convinced this is going to work for me, but let's
try it and see.

Prompt: In a new worktree, make the mobile input for enter not send
the message since the send button is right there.

On mobile devices, pressing Enter should create a newline instead of
submitting the message. Users have the send button readily available
for submission, and newlines are common in mobile messaging.

Change summary

ui/src/components/MessageInput.tsx | 7 +++++++
1 file changed, 7 insertions(+)

Detailed changes

ui/src/components/MessageInput.tsx 🔗

@@ -309,6 +309,13 @@ function MessageInput({
       return;
     }
     if (e.key === "Enter" && !e.shiftKey) {
+      // On mobile, let Enter create newlines since there's a send button
+      // I'm not convinced the divergence from desktop is the correct answer,
+      // but we can try it and see how it feels.
+      const isMobile = "ontouchstart" in window;
+      if (isMobile) {
+        return;
+      }
       e.preventDefault();
       handleSubmit(e);
     }