diff --git a/AppImage/components/hardware.tsx b/AppImage/components/hardware.tsx index ea765d4..5c99d68 100644 --- a/AppImage/components/hardware.tsx +++ b/AppImage/components/hardware.tsx @@ -2043,7 +2043,9 @@ export default function Hardware() { }} scriptPath="/usr/local/share/proxmenux/scripts/gpu_tpu/nvidia_installer.sh" scriptName="nvidia_installer" - params={{}} + params={{ + EXECUTION_MODE: "web", + }} title="NVIDIA Driver Installation" description="Installing NVIDIA proprietary drivers for GPU monitoring..." /> diff --git a/AppImage/components/script-terminal-modal.tsx b/AppImage/components/script-terminal-modal.tsx index 5f8660a..d1d0244 100644 --- a/AppImage/components/script-terminal-modal.tsx +++ b/AppImage/components/script-terminal-modal.tsx @@ -10,11 +10,12 @@ import { TerminalPanel } from "./terminal-panel" import { API_PORT } from "@/lib/api-config" interface WebInteraction { - type: "yesno" | "menu" | "msgbox" | "input" + type: "yesno" | "menu" | "msgbox" | "input" | "inputbox" id: string title: string message: string options?: Array<{ label: string; value: string }> + default?: string } interface ScriptTerminalModalProps { @@ -42,6 +43,7 @@ export function ScriptTerminalModal({ const [currentInteraction, setCurrentInteraction] = useState(null) const [interactionInput, setInteractionInput] = useState("") const terminalRef = useRef(null) + const wsRef = useRef(null) useEffect(() => { if (open) { @@ -57,10 +59,34 @@ export function ScriptTerminalModal({ useEffect(() => { if (!open) return - // We'll pass initMessage prop to TerminalPanel instead + const handleWebSocketMessage = (event: MessageEvent) => { + try { + const data = JSON.parse(event.data) + console.log("[v0] Received WebSocket message:", data) + + if (data.type === "web_interaction") { + console.log("[v0] Detected web interaction:", data.interaction) + setCurrentInteraction(data.interaction) + } + } catch (e) { + // Not JSON, ignore (it's terminal output) + } + } + + const checkWs = setInterval(() => { + if (terminalRef.current?.ws) { + wsRef.current = terminalRef.current.ws + wsRef.current.addEventListener("message", handleWebSocketMessage) + clearInterval(checkWs) + console.log("[v0] Attached WebSocket message listener") + } + }, 100) return () => { - // Cleanup if needed + clearInterval(checkWs) + if (wsRef.current) { + wsRef.current.removeEventListener("message", handleWebSocketMessage) + } } }, [open]) @@ -82,7 +108,7 @@ export function ScriptTerminalModal({ }) const handleInteractionResponse = (value: string) => { - if (!terminalRef.current || !currentInteraction) return + if (!wsRef.current || !currentInteraction) return const response = JSON.stringify({ type: "interaction_response", @@ -91,7 +117,7 @@ export function ScriptTerminalModal({ }) console.log("[v0] Sending interaction response:", response) - terminalRef.current.send(response) + wsRef.current.send(response) setCurrentInteraction(null) setInteractionInput("") } @@ -148,7 +174,7 @@ export function ScriptTerminalModal({ {currentInteraction.title}
-

{currentInteraction.message}

+

{currentInteraction.message}

{currentInteraction.type === "yesno" && (
@@ -176,23 +202,25 @@ export function ScriptTerminalModal({
)} - {currentInteraction.type === "input" && ( -
- - setInteractionInput(e.target.value)} - onKeyDown={(e) => { - if (e.key === "Enter") { - handleInteractionResponse(interactionInput) - } - }} - /> - -
- )} + {currentInteraction.type === "input" || + (currentInteraction.type === "inputbox" && ( +
+ + setInteractionInput(e.target.value)} + onKeyDown={(e) => { + if (e.key === "Enter") { + handleInteractionResponse(interactionInput) + } + }} + placeholder={currentInteraction.default || ""} + /> + +
+ ))} {currentInteraction.type === "msgbox" && (