diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx index 720a05ff7e1..30787646947 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx @@ -157,41 +157,21 @@ export function PermissionPrompt(props: { request: PermissionRequest }) { return ( - - - - - - - This will allow the following patterns until OpenCode is restarted - - - {(pattern) => ( - - {"- "} - {pattern} - - )} - - - - - - } - options={{ confirm: "Confirm", cancel: "Cancel" }} - escapeKey="cancel" - onSelect={(option) => { + { setStore("stage", "permission") - if (option === "cancel") return void sdk.client.permission.reply({ reply: "always", requestID: props.request.id, workspace: project.workspace.current(), + patterns: patterns.length > 0 ? patterns : undefined, }) }} + onCancel={() => { + setStore("stage", "permission") + }} /> @@ -459,6 +439,97 @@ export function PermissionPrompt(props: { request: PermissionRequest }) { ) } +function AlwaysEditPrompt(props: { + initial: string[] + permission: string + onConfirm: (patterns: string[]) => void + onCancel: () => void +}) { + let input: TextareaRenderable + const { theme } = useTheme() + const keybind = useKeybind() + const textareaKeybindings = useTextareaKeybindings() + const dimensions = useTerminalDimensions() + const narrow = createMemo(() => dimensions().width < 80) + const dialog = useDialog() + const initialText = props.initial.join("\n") + + useKeyboard((evt) => { + if (dialog.stack.length > 0) return + + if (evt.name === "escape" || keybind.match("app_exit", evt)) { + evt.preventDefault() + props.onCancel() + return + } + if (evt.name === "return" && !evt.meta && !evt.shift) { + evt.preventDefault() + const patterns = input.plainText + .split("\n") + .map((line) => line.trim()) + .filter((line) => line.length > 0) + props.onConfirm(patterns) + } + }) + + return ( + + + + {"△"} + Always allow + + + + {"Edit pattern(s) to allow for " + props.permission + " until OpenCode is restarted."} + + + + One pattern per line. Alt+Enter inserts a newline. + + + +