Просмотр исходного кода

fix: permission prompt should ignore keyboard events while dialog stack len > 0 (#10338)

justfortheloveof 4 недель назад
Родитель
Сommit
077d17d433
1 измененных файлов с 7 добавлено и 0 удалено
  1. 7 0
      packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx

+ 7 - 0
packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx

@@ -14,6 +14,7 @@ import { LANGUAGE_EXTENSIONS } from "@/lsp/language"
 import { Keybind } from "@/util/keybind"
 import { Keybind } from "@/util/keybind"
 import { Locale } from "@/util/locale"
 import { Locale } from "@/util/locale"
 import { Global } from "@/global"
 import { Global } from "@/global"
+import { useDialog } from "../../ui/dialog"
 
 
 type PermissionStage = "permission" | "always" | "reject"
 type PermissionStage = "permission" | "always" | "reject"
 
 
@@ -304,8 +305,11 @@ function RejectPrompt(props: { onConfirm: (message: string) => void; onCancel: (
   const textareaKeybindings = useTextareaKeybindings()
   const textareaKeybindings = useTextareaKeybindings()
   const dimensions = useTerminalDimensions()
   const dimensions = useTerminalDimensions()
   const narrow = createMemo(() => dimensions().width < 80)
   const narrow = createMemo(() => dimensions().width < 80)
+  const dialog = useDialog()
 
 
   useKeyboard((evt) => {
   useKeyboard((evt) => {
+    if (dialog.stack.length > 0) return
+
     if (evt.name === "escape" || keybind.match("app_exit", evt)) {
     if (evt.name === "escape" || keybind.match("app_exit", evt)) {
       evt.preventDefault()
       evt.preventDefault()
       props.onCancel()
       props.onCancel()
@@ -384,8 +388,11 @@ function Prompt<const T extends Record<string, string>>(props: {
   })
   })
   const diffKey = Keybind.parse("ctrl+f")[0]
   const diffKey = Keybind.parse("ctrl+f")[0]
   const narrow = createMemo(() => dimensions().width < 80)
   const narrow = createMemo(() => dimensions().width < 80)
+  const dialog = useDialog()
 
 
   useKeyboard((evt) => {
   useKeyboard((evt) => {
+    if (dialog.stack.length > 0) return
+
     if (evt.name === "left" || evt.name == "h") {
     if (evt.name === "left" || evt.name == "h") {
       evt.preventDefault()
       evt.preventDefault()
       const idx = keys.indexOf(store.selected)
       const idx = keys.indexOf(store.selected)