diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
index 10e340d7f8f..4083668c8d6 100644
--- a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
+++ b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
@@ -54,6 +54,7 @@ import { TodoItem } from "../../component/todo-item"
import { DialogMessage } from "./dialog-message"
import type { PromptInfo } from "../../component/prompt/history"
import { DialogConfirm } from "@tui/ui/dialog-confirm"
+import { DialogPrompt } from "@tui/ui/dialog-prompt"
import { DialogTimeline } from "./dialog-timeline"
import { DialogForkFromTimeline } from "./dialog-fork-from-timeline"
import { DialogSessionRename } from "../../component/dialog-session-rename"
@@ -69,6 +70,7 @@ import { Footer } from "./footer.tsx"
import { usePromptRef } from "../../context/prompt"
import { useExit } from "../../context/exit"
import { Filesystem } from "@/util/filesystem"
+import { iife } from "@/util/iife"
import { PermissionPrompt } from "./permission"
import { QuestionPrompt } from "./question"
import { DialogExportOptions } from "../../ui/dialog-export-options"
@@ -254,6 +256,49 @@ export function Session() {
dialog.clear()
}
+ useKeyboard(async (evt) => {
+ if (dialog.stack.length > 0) return
+
+ const first = permissions()[0]
+ if (first) {
+ if (evt.ctrl || evt.meta) return
+
+ // Handle interject with "i" key - opens prompt for user suggestion
+ if (evt.name === "i") {
+ const interjection = await DialogPrompt.show(dialog, "Interject", {
+ placeholder: "Enter your suggestion...",
+ description: () => (
+
+ Provide a suggestion or correction for the model to consider
+
+ ),
+ })
+ if (interjection !== null && interjection.trim()) {
+ sdk.client.permission.reply({
+ requestID: first.id,
+ reply: "interject",
+ interjection: interjection.trim(),
+ })
+ }
+ return
+ }
+
+ const response = iife(() => {
+ if (evt.name === "return") return "once"
+ if (evt.name === "a") return "always"
+ if (evt.name === "d") return "reject"
+ if (evt.name === "escape") return "reject"
+ return
+ })
+ if (response) {
+ sdk.client.permission.reply({
+ requestID: first.id,
+ reply: response,
+ })
+ }
+ }
+ })
+
function toBottom() {
setTimeout(() => {
if (scroll) scroll.scrollTo(scroll.scrollHeight)
diff --git a/packages/opencode/src/cli/cmd/tui/ui/dialog-prompt.tsx b/packages/opencode/src/cli/cmd/tui/ui/dialog-prompt.tsx
index 1b9acb5898e..519a75dd1a1 100644
--- a/packages/opencode/src/cli/cmd/tui/ui/dialog-prompt.tsx
+++ b/packages/opencode/src/cli/cmd/tui/ui/dialog-prompt.tsx
@@ -21,6 +21,7 @@ export function DialogPrompt(props: DialogPromptProps) {
useKeyboard((evt) => {
if (evt.name === "return") {
props.onConfirm?.(textarea.plainText)
+ dialog.clear()
}
})
@@ -45,6 +46,7 @@ export function DialogPrompt(props: DialogPromptProps) {