Skip to content
Open
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
11 changes: 11 additions & 0 deletions packages/app/src/components/prompt-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from "solid-js"
import { createStore, produce } from "solid-js/store"
import { createFocusSignal } from "@solid-primitives/active-element"
import { createMediaQuery } from "@solid-primitives/media"
import { useLocal } from "@/context/local"
import { useFile, type FileSelection } from "@/context/file"
import {
Expand Down Expand Up @@ -130,6 +131,11 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
const providers = useProviders()
const command = useCommand()
const permission = usePermission()
const isTouchDevice = createMemo(() => {
const isCoarsePointer = window.matchMedia("(pointer: coarse)").matches
const hasTouchSupport = "ontouchstart" in window || navigator.maxTouchPoints > 0
return isCoarsePointer || hasTouchSupport
})
const language = useLanguage()
let editorRef!: HTMLDivElement
let fileInputRef!: HTMLInputElement
Expand Down Expand Up @@ -1055,6 +1061,11 @@ export const PromptInput: Component<PromptInputProps> = (props) => {

// Note: Shift+Enter is handled earlier, before IME check
if (event.key === "Enter" && !event.shiftKey) {
if (isTouchDevice()) {
addPart({ type: "text", content: "\n", start: 0, end: 0 })
event.preventDefault()
return
}
handleSubmit(event)
}
if (event.key === "Escape") {
Expand Down