From 943a8bf02dd41ed6408e439004ac20e75e07b395 Mon Sep 17 00:00:00 2001 From: MacRimi Date: Wed, 10 Dec 2025 18:54:35 +0100 Subject: [PATCH] Update script-terminal-modal.tsx --- AppImage/components/script-terminal-modal.tsx | 161 ++++++++++-------- 1 file changed, 89 insertions(+), 72 deletions(-) diff --git a/AppImage/components/script-terminal-modal.tsx b/AppImage/components/script-terminal-modal.tsx index c88acd5..f9ab4bb 100644 --- a/AppImage/components/script-terminal-modal.tsx +++ b/AppImage/components/script-terminal-modal.tsx @@ -8,7 +8,6 @@ import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { Loader2, Activity, GripHorizontal } from "lucide-react" import { API_PORT } from "../lib/api-config" -import { useIsMobile } from "@/hooks/use-mobile" interface WebInteraction { type: "yesno" | "menu" | "msgbox" | "input" | "inputbox" @@ -49,7 +48,8 @@ export function ScriptTerminalModal({ const [currentInteraction, setCurrentInteraction] = useState(null) const [interactionInput, setInteractionInput] = useState("") const checkConnectionInterval = useRef(null) - const isMobile = useIsMobile() + const [isMobile, setIsMobile] = useState(false) + const [isTablet, setIsTablet] = useState(false) const [isWaitingNextInteraction, setIsWaitingNextInteraction] = useState(false) const waitingTimeoutRef = useRef(null) @@ -341,6 +341,25 @@ export function ScriptTerminalModal({ } }, [isOpen]) + useEffect(() => { + const updateDeviceType = () => { + const width = window.innerWidth + const isTouchDevice = "ontouchstart" in window || navigator.maxTouchPoints > 0 + const isTabletSize = width >= 768 && width <= 1366 + + setIsMobile(width < 768) + setIsTablet(isTouchDevice && isTabletSize) + } + + updateDeviceType() + const handleResize = () => updateDeviceType() + window.addEventListener("resize", handleResize) + + return () => { + window.removeEventListener("resize", handleResize) + } + }, []) + const getScriptWebSocketUrl = (sid: string): string => { if (typeof window === "undefined") { return `ws://localhost:${API_PORT}/ws/script/${sid}` @@ -488,7 +507,7 @@ export function ScriptTerminalModal({ e.preventDefault()} onEscapeKeyDown={(e) => e.preventDefault()} > @@ -514,78 +533,76 @@ export function ScriptTerminalModal({ )} - {isMobile && ( -
-
- - - - - - - - -
+ {(isMobile || isTablet) && ( +
+ + + + + + + +
)} - {!isMobile && ( + {!isMobile && !isTablet && (