diff --git a/packages/tfcode/src/cli/cmd/tui/component/dialog-tf-hooks.tsx b/packages/tfcode/src/cli/cmd/tui/component/dialog-tf-hooks.tsx index cc080d097..f4d183e26 100644 --- a/packages/tfcode/src/cli/cmd/tui/component/dialog-tf-hooks.tsx +++ b/packages/tfcode/src/cli/cmd/tui/component/dialog-tf-hooks.tsx @@ -5,6 +5,7 @@ import { TextAttributes } from "@opentui/core" import { Global } from "@/global" import path from "path" import { useToast } from "../ui/toast" +import { useDialog } from "../ui/dialog" import { Keybind } from "@/util/keybind" interface Hook { @@ -12,8 +13,8 @@ interface Hook { name: string description?: string remote_environment_name?: string - code_execution_instructions?: string - predefined_code_snippet?: string + customExecutionInstructions?: string + customExecutionCode?: string execute_as_static_script?: boolean execute_as_python_tool?: boolean secrets_injected?: boolean @@ -56,6 +57,7 @@ function HookStatus(props: { hook: Hook }) { export function DialogTfHooks(props: { onSelect?: (hook: Hook) => void }) { const toast = useToast() + const dialog = useDialog() const { theme } = useTheme() const [, setRef] = createSignal>() const [loading, setLoading] = createSignal(false) @@ -175,6 +177,7 @@ export function DialogTfHooks(props: { onSelect?: (hook: Hook) => void }) { onSelect={(option) => { if (option.value.id === "loading" || option.value.id === "empty") return props.onSelect?.(option.value) + dialog.clear() }} /> ) diff --git a/packages/tfcode/src/cli/cmd/tui/component/prompt/index.tsx b/packages/tfcode/src/cli/cmd/tui/component/prompt/index.tsx index 21a0c0b61..433d661ee 100644 --- a/packages/tfcode/src/cli/cmd/tui/component/prompt/index.tsx +++ b/packages/tfcode/src/cli/cmd/tui/component/prompt/index.tsx @@ -378,15 +378,19 @@ export function Prompt(props: PromptProps) { { const parts = [] - if (hook.code_execution_instructions) parts.push(hook.code_execution_instructions) - if (hook.predefined_code_snippet) parts.push("\n\n```python\n" + hook.predefined_code_snippet + "\n```") + if (hook.customExecutionInstructions) parts.push(hook.customExecutionInstructions) + if (hook.customExecutionCode) parts.push("\n\n```python\n" + hook.customExecutionCode + "\n```") const text = parts.join("") if (text) { - input.setText(text) setStore("prompt", { input: text, parts: [] }) - input.gotoBufferEnd() + setTimeout(() => { + if (input && !input.isDestroyed) { + input.setText(text) + input.gotoBufferEnd() + input.focus() + } + }, 0) } - dialog.clear() }} /> ))