diff --git a/AppImage/components/script-terminal-modal.tsx b/AppImage/components/script-terminal-modal.tsx
index e626759..ecb2a7d 100644
--- a/AppImage/components/script-terminal-modal.tsx
+++ b/AppImage/components/script-terminal-modal.tsx
@@ -359,6 +359,35 @@ export function ScriptTerminalModal({
}
}, [])
+ useEffect(() => {
+ if (!isOpen) return
+
+ const handleVisibilityChange = () => {
+ if (document.hidden) {
+ // Enviar ping para mantener conexión activa cuando la pantalla se bloquea
+ if (wsRef.current && wsRef.current.readyState === WebSocket.OPEN) {
+ wsRef.current.send(JSON.stringify({ type: "ping" }))
+ }
+ }
+ }
+
+ document.addEventListener("visibilitychange", handleVisibilityChange)
+
+ const keepAliveInterval = setInterval(() => {
+ if (wsRef.current && wsRef.current.readyState === WebSocket.OPEN) {
+ wsRef.current.send(JSON.stringify({ type: "ping" }))
+ }
+ }, 30000)
+
+ return () => {
+ document.removeEventListener("visibilitychange", handleVisibilityChange)
+ clearInterval(keepAliveInterval)
+ if (checkConnectionInterval.current) {
+ clearInterval(checkConnectionInterval.current)
+ }
+ }
+ }, [isOpen])
+
const getScriptWebSocketUrl = (sid: string): string => {
if (typeof window === "undefined") {
return `ws://localhost:${API_PORT}/ws/script/${sid}`
@@ -509,6 +538,7 @@ export function ScriptTerminalModal({
style={{ height: isMobile || isTablet ? "80vh" : `${modalHeight}px`, maxHeight: "none" }}
onInteractOutside={(e) => e.preventDefault()}
onEscapeKeyDown={(e) => e.preventDefault()}
+ hideClose={true}
>