tui: allow auto-accepting only edit permissions instead of all permissions
parent
ac244b1458
commit
ad545d0cc9
|
|
@ -63,6 +63,7 @@ export namespace Agent {
|
||||||
question: "deny",
|
question: "deny",
|
||||||
plan_enter: "deny",
|
plan_enter: "deny",
|
||||||
plan_exit: "deny",
|
plan_exit: "deny",
|
||||||
|
edit: "ask",
|
||||||
// mirrors github.com/github/gitignore Node.gitignore pattern for .env files
|
// mirrors github.com/github/gitignore Node.gitignore pattern for .env files
|
||||||
read: {
|
read: {
|
||||||
"*": "allow",
|
"*": "allow",
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ export function Prompt(props: PromptProps) {
|
||||||
const renderer = useRenderer()
|
const renderer = useRenderer()
|
||||||
const { theme, syntax } = useTheme()
|
const { theme, syntax } = useTheme()
|
||||||
const kv = useKV()
|
const kv = useKV()
|
||||||
const [autoaccept, setAutoaccept] = kv.signal("permission_auto_accept", false)
|
const [autoaccept, setAutoaccept] = kv.signal<"none" | "edit">("permission_auto_accept", "edit")
|
||||||
|
|
||||||
function promptModelWarning() {
|
function promptModelWarning() {
|
||||||
toast.show({
|
toast.show({
|
||||||
|
|
@ -159,13 +159,13 @@ export function Prompt(props: PromptProps) {
|
||||||
command.register(() => {
|
command.register(() => {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
title: autoaccept() ? "Disable permissions" : "Enable permissions",
|
title: autoaccept() === "none" ? "Enable autoedit" : "Disable autoedit",
|
||||||
value: "permission.auto_accept.toggle",
|
value: "permission.auto_accept.toggle",
|
||||||
search: "toggle permissions",
|
search: "toggle permissions",
|
||||||
keybind: "permission_auto_accept_toggle",
|
keybind: "permission_auto_accept_toggle",
|
||||||
category: "Agent",
|
category: "Agent",
|
||||||
onSelect: (dialog) => {
|
onSelect: (dialog) => {
|
||||||
setAutoaccept(!autoaccept() as any)
|
setAutoaccept(() => (autoaccept() === "none" ? "edit" : "none"))
|
||||||
dialog.clear()
|
dialog.clear()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -1005,9 +1005,9 @@ export function Prompt(props: PromptProps) {
|
||||||
</box>
|
</box>
|
||||||
</Show>
|
</Show>
|
||||||
</box>
|
</box>
|
||||||
<Show when={autoaccept()}>
|
<Show when={autoaccept() === "edit"}>
|
||||||
<text>
|
<text>
|
||||||
<span style={{ fg: theme.warning, bold: true }}>auto-accept</span>
|
<span style={{ fg: theme.warning, bold: true }}>auto-edit</span>
|
||||||
</text>
|
</text>
|
||||||
</Show>
|
</Show>
|
||||||
</box>
|
</box>
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
|
||||||
|
|
||||||
const sdk = useSDK()
|
const sdk = useSDK()
|
||||||
const kv = useKV()
|
const kv = useKV()
|
||||||
const [autoaccept] = kv.signal("permission_auto_accept", false)
|
const [autoaccept] = kv.signal<"none" | "edit">("permission_auto_accept", "edit")
|
||||||
|
|
||||||
sdk.event.listen((e) => {
|
sdk.event.listen((e) => {
|
||||||
const event = e.details
|
const event = e.details
|
||||||
|
|
@ -130,7 +130,7 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
|
||||||
|
|
||||||
case "permission.asked": {
|
case "permission.asked": {
|
||||||
const request = event.properties
|
const request = event.properties
|
||||||
if (autoaccept()) {
|
if (autoaccept() === "edit" && request.permission === "edit") {
|
||||||
sdk.client.permission.reply({
|
sdk.client.permission.reply({
|
||||||
reply: "once",
|
reply: "once",
|
||||||
requestID: request.id,
|
requestID: request.id,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue