diff options
| author | Dax Raad <[email protected]> | 2025-11-04 20:46:01 -0500 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-11-04 20:46:01 -0500 |
| commit | 234db24f1f995d680d2e33002f13b03b1eacba79 (patch) | |
| tree | 266f971bdefe00a7a274e7746fd7ab9d047c94d9 /packages | |
| parent | 04546c0873b6c379b9a4c92b7301249eea009b0b (diff) | |
| download | opencode-234db24f1f995d680d2e33002f13b03b1eacba79.tar.gz opencode-234db24f1f995d680d2e33002f13b03b1eacba79.zip | |
tui: fix command validation to prevent invalid commands from being executed
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx index 349026e99..d66b8e0a3 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx @@ -28,6 +28,7 @@ import { useExit } from "../../context/exit" import { Clipboard } from "../../util/clipboard" import type { FilePart } from "@opencode-ai/sdk" import { TuiEvent } from "../../event" +import { iife } from "@/util/iife" export type PromptProps = { sessionID?: string @@ -363,8 +364,15 @@ export function Prompt(props: PromptProps) { }, }) setStore("mode", "normal") - } else if (inputText.startsWith("/")) { - const [command, ...args] = inputText.split(" ") + } else if ( + inputText.startsWith("/") && + iife(() => { + const command = inputText.split(" ")[0].slice(1) + console.log(command) + return sync.data.command.some((x) => x.name === command) + }) + ) { + let [command, ...args] = inputText.split(" ") sdk.client.session.command({ path: { id: sessionID, |
