From 78069369e2253c9788c09b7a71478d140c9741f2 Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Mon, 2 Mar 2026 13:10:37 -0600 Subject: fix(app): default auto-respond to false --- .../app/src/components/prompt-input/submit.test.ts | 38 ++++++++++++++++++++++ packages/app/src/components/prompt-input/submit.ts | 5 +++ 2 files changed, 43 insertions(+) (limited to 'packages/app/src/components/prompt-input') diff --git a/packages/app/src/components/prompt-input/submit.test.ts b/packages/app/src/components/prompt-input/submit.test.ts index c3d6a9281..c633525a2 100644 --- a/packages/app/src/components/prompt-input/submit.test.ts +++ b/packages/app/src/components/prompt-input/submit.test.ts @@ -5,6 +5,7 @@ let createPromptSubmit: typeof import("./submit").createPromptSubmit const createdClients: string[] = [] const createdSessions: string[] = [] +const enabledAutoAccept: Array<{ sessionID: string; directory: string }> = [] const sentShell: string[] = [] const syncedDirectories: string[] = [] @@ -69,6 +70,14 @@ beforeAll(async () => { }), })) + mock.module("@/context/permission", () => ({ + usePermission: () => ({ + enableAutoAccept(sessionID: string, directory: string) { + enabledAutoAccept.push({ sessionID, directory }) + }, + }), + })) + mock.module("@/context/prompt", () => ({ usePrompt: () => ({ current: () => promptValue, @@ -145,6 +154,7 @@ beforeAll(async () => { beforeEach(() => { createdClients.length = 0 createdSessions.length = 0 + enabledAutoAccept.length = 0 sentShell.length = 0 syncedDirectories.length = 0 selected = "/repo/worktree-a" @@ -156,6 +166,7 @@ describe("prompt submit worktree selection", () => { info: () => undefined, imageAttachments: () => [], commentCount: () => 0, + autoAccept: () => false, mode: () => "shell", working: () => false, editor: () => undefined, @@ -181,4 +192,31 @@ describe("prompt submit worktree selection", () => { expect(sentShell).toEqual(["/repo/worktree-a", "/repo/worktree-b"]) expect(syncedDirectories).toEqual(["/repo/worktree-a", "/repo/worktree-b"]) }) + + test("applies auto-accept to newly created sessions", async () => { + const submit = createPromptSubmit({ + info: () => undefined, + imageAttachments: () => [], + commentCount: () => 0, + autoAccept: () => true, + mode: () => "shell", + working: () => false, + editor: () => undefined, + queueScroll: () => undefined, + promptLength: (value) => value.reduce((sum, part) => sum + ("content" in part ? part.content.length : 0), 0), + addToHistory: () => undefined, + resetHistoryNavigation: () => undefined, + setMode: () => undefined, + setPopover: () => undefined, + newSessionWorktree: () => selected, + onNewSessionWorktreeReset: () => undefined, + onSubmit: () => undefined, + }) + + const event = { preventDefault: () => undefined } as unknown as Event + + await submit.handleSubmit(event) + + expect(enabledAutoAccept).toEqual([{ sessionID: "session-1", directory: "/repo/worktree-a" }]) + }) }) diff --git a/packages/app/src/components/prompt-input/submit.ts b/packages/app/src/components/prompt-input/submit.ts index a7ff39e09..a8c2609f4 100644 --- a/packages/app/src/components/prompt-input/submit.ts +++ b/packages/app/src/components/prompt-input/submit.ts @@ -8,6 +8,7 @@ import { useGlobalSync } from "@/context/global-sync" import { useLanguage } from "@/context/language" import { useLayout } from "@/context/layout" import { useLocal } from "@/context/local" +import { usePermission } from "@/context/permission" import { type ImageAttachmentPart, type Prompt, usePrompt } from "@/context/prompt" import { useSDK } from "@/context/sdk" import { useSync } from "@/context/sync" @@ -27,6 +28,7 @@ type PromptSubmitInput = { info: Accessor<{ id: string } | undefined> imageAttachments: Accessor commentCount: Accessor + autoAccept: Accessor mode: Accessor<"normal" | "shell"> working: Accessor editor: () => HTMLDivElement | undefined @@ -56,6 +58,7 @@ export function createPromptSubmit(input: PromptSubmitInput) { const sync = useSync() const globalSync = useGlobalSync() const local = useLocal() + const permission = usePermission() const prompt = usePrompt() const layout = useLayout() const language = useLanguage() @@ -140,6 +143,7 @@ export function createPromptSubmit(input: PromptSubmitInput) { const projectDirectory = sdk.directory const isNewSession = !params.id + const shouldAutoAccept = isNewSession && input.autoAccept() const worktreeSelection = input.newSessionWorktree?.() || "main" let sessionDirectory = projectDirectory @@ -197,6 +201,7 @@ export function createPromptSubmit(input: PromptSubmitInput) { return undefined }) if (session) { + if (shouldAutoAccept) permission.enableAutoAccept(session.id, sessionDirectory) layout.handoff.setTabs(base64Encode(sessionDirectory), session.id) navigate(`/${base64Encode(sessionDirectory)}/session/${session.id}`) } -- cgit v1.2.3