Apply PR #12633: feat(tui): add auto-accept mode for permission requests

This commit is contained in:
opencode-agent[bot] 2026-05-29 19:07:34 +00:00
commit aa5d4c1849
4 changed files with 35 additions and 1 deletions

View file

@ -157,6 +157,7 @@ export function Prompt(props: PromptProps) {
const dimensions = useTerminalDimensions()
const { theme, syntax } = useTheme()
const kv = useKV()
const [autoaccept, setAutoaccept] = kv.signal<"none" | "edit">("permission_auto_accept", "edit")
const animationsEnabled = createMemo(() => kv.get("animations_enabled", true))
const list = createMemo(() => props.placeholders?.normal ?? [])
const shell = createMemo(() => props.placeholders?.shell ?? [])
@ -404,6 +405,15 @@ export function Prompt(props: PromptProps) {
const promptCommands = createMemo(() =>
[
{
title: autoaccept() === "none" ? "Enable autoedit" : "Disable autoedit",
name: "permission.auto_accept.toggle",
category: "Agent",
run: () => {
setAutoaccept(() => (autoaccept() === "none" ? "edit" : "none"))
dialog.clear()
},
},
{
title: "Clear prompt",
name: "prompt.clear",
@ -1596,8 +1606,13 @@ export function Prompt(props: PromptProps) {
)}
</Show>
</box>
<Show when={hasRightContent()}>
<Show when={hasRightContent() || autoaccept() === "edit"}>
<box flexDirection="row" gap={1} alignItems="center">
<Show when={autoaccept() === "edit"}>
<text>
<span style={{ fg: theme.warning }}>autoedit</span>
</text>
</Show>
{props.right}
</box>
</Show>

View file

@ -111,6 +111,7 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
const project = useProject()
const sdk = useSDK()
const kv = useKV()
const [autoaccept] = kv.signal<"none" | "edit">("permission_auto_accept", "edit")
const fullSyncedSessions = new Set<string>()
@ -152,6 +153,13 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
case "permission.asked": {
const request = event.properties
if (autoaccept() === "edit" && request.permission === "edit") {
void sdk.client.permission.reply({
reply: "once",
requestID: request.id,
})
break
}
const requests = store.permission[request.sessionID]
if (!requests) {
setStore("permission", request.sessionID, [request])

View file

@ -658,6 +658,8 @@ export function Session() {
{
title: sidebarVisible() ? "Hide sidebar" : "Show sidebar",
value: "session.sidebar.toggle",
search: "toggle sidebar",
keybind: "sidebar_toggle",
category: "Session",
run: () => {
batch(() => {
@ -671,6 +673,8 @@ export function Session() {
{
title: conceal() ? "Disable code concealment" : "Enable code concealment",
value: "session.toggle.conceal",
search: "toggle code concealment",
keybind: "messages_toggle_conceal" as any,
category: "Session",
run: () => {
setConceal((prev) => !prev)
@ -697,6 +701,8 @@ export function Session() {
return "Expand thinking"
})(),
value: "session.toggle.thinking",
search: "toggle thinking",
keybind: "display_thinking",
category: "Session",
slash: {
name: "thinking",
@ -710,6 +716,8 @@ export function Session() {
{
title: showDetails() ? "Hide tool details" : "Show tool details",
value: "session.toggle.actions",
search: "toggle tool details",
keybind: "tool_details",
category: "Session",
run: () => {
setShowDetails((prev) => !prev)
@ -719,6 +727,8 @@ export function Session() {
{
title: "Toggle session scrollbar",
value: "session.toggle.scrollbar",
search: "toggle session scrollbar",
keybind: "scrollbar_toggle",
category: "Session",
run: () => {
setShowScrollbar((prev) => !prev)

View file

@ -52,6 +52,7 @@ export interface DialogSelectOption<T = any> {
value: T
description?: string
details?: string[]
search?: string
footer?: JSX.Element | string
category?: string
categoryView?: JSX.Element