Skip to content

Commit 2d82390

Browse files
committed
Merge branch 'feat/double-escape-cancel' into dev
2 parents e8fe809 + 487b432 commit 2d82390

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

packages/app/src/components/prompt-input.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useFilteredList } from "@opencode-ai/ui/hooks"
2+
import { showToast } from "@opencode-ai/ui/toast"
23
import { createEffect, on, Component, Show, onCleanup, Switch, Match, createMemo, createSignal } from "solid-js"
34
import { createStore } from "solid-js/store"
45
import { createFocusSignal } from "@solid-primitives/active-element"
@@ -113,6 +114,8 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
113114

114115
const mirror = { input: false }
115116
const inset = 44
117+
let lastEscapeAt = 0
118+
const DOUBLE_ESCAPE_MS = 500
116119

117120
const scrollCursorIntoView = () => {
118121
const container = scrollRef
@@ -951,7 +954,17 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
951954
}
952955

953956
if (working()) {
954-
abort()
957+
const now = Date.now()
958+
if (now - lastEscapeAt < DOUBLE_ESCAPE_MS) {
959+
abort()
960+
lastEscapeAt = 0
961+
} else {
962+
lastEscapeAt = now
963+
showToast({
964+
title: "Press Escape again to cancel",
965+
description: "Press Escape once more to interrupt the response",
966+
})
967+
}
955968
event.preventDefault()
956969
event.stopPropagation()
957970
return

0 commit comments

Comments
 (0)