summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src/components/prompt-input/submit.test.ts
diff options
context:
space:
mode:
authorAdam <[email protected]>2026-03-02 13:10:37 -0600
committerAdam <[email protected]>2026-03-02 13:10:37 -0600
commit78069369e2253c9788c09b7a71478d140c9741f2 (patch)
treee15011250cd1a92953dfe0584facbc26bcb92309 /packages/app/src/components/prompt-input/submit.test.ts
parent1cd77b10724ad87acc96790bec4a524614b20ad6 (diff)
downloadopencode-78069369e2253c9788c09b7a71478d140c9741f2.tar.gz
opencode-78069369e2253c9788c09b7a71478d140c9741f2.zip
fix(app): default auto-respond to false
Diffstat (limited to 'packages/app/src/components/prompt-input/submit.test.ts')
-rw-r--r--packages/app/src/components/prompt-input/submit.test.ts38
1 files changed, 38 insertions, 0 deletions
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" }])
+ })
})