Update AppImage

This commit is contained in:
MacRimi
2025-12-06 13:48:46 +01:00
parent 84e8e18ef8
commit fed242315d
2 changed files with 845 additions and 828 deletions

View File

@@ -6,7 +6,7 @@ import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input" import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label" import { Label } from "@/components/ui/label"
import { X, CheckCircle2, XCircle, Loader2 } from "lucide-react" import { X, CheckCircle2, XCircle, Loader2 } from "lucide-react"
import { TerminalPanel } from "./terminal-panel" import { TerminalPanel, type TerminalPanelHandle } from "./terminal-panel"
import { API_PORT } from "@/lib/api-config" import { API_PORT } from "@/lib/api-config"
interface WebInteraction { interface WebInteraction {
@@ -42,7 +42,7 @@ export function ScriptTerminalModal({
const [exitCode, setExitCode] = useState<number | null>(null) const [exitCode, setExitCode] = useState<number | null>(null)
const [currentInteraction, setCurrentInteraction] = useState<WebInteraction | null>(null) const [currentInteraction, setCurrentInteraction] = useState<WebInteraction | null>(null)
const [interactionInput, setInteractionInput] = useState("") const [interactionInput, setInteractionInput] = useState("")
const terminalRef = useRef<any>(null) const terminalRef = useRef<TerminalPanelHandle>(null)
useEffect(() => { useEffect(() => {
console.log("[v0] currentInteraction changed:", currentInteraction) console.log("[v0] currentInteraction changed:", currentInteraction)
@@ -106,14 +106,8 @@ export function ScriptTerminalModal({
console.log("[v0] Sending interaction response:", response) console.log("[v0] Sending interaction response:", response)
// Access the terminal instance to send the response terminalRef.current.sendMessage(response)
const terminal = terminalRef.current
if (terminal?.terminals?.[0]?.ws) {
terminal.terminals[0].ws.send(response)
console.log("[v0] Response sent successfully") console.log("[v0] Response sent successfully")
} else {
console.log("[v0] Could not send response - no WebSocket available")
}
console.log("[v0] Clearing currentInteraction after response") console.log("[v0] Clearing currentInteraction after response")
setCurrentInteraction(null) setCurrentInteraction(null)

View File

@@ -1,7 +1,7 @@
"use client" "use client"
import type React from "react" import type React from "react"
import { useEffect, useRef, useState } from "react" import { useEffect, useRef, useState, forwardRef, useImperativeHandle } from "react"
import { API_PORT } from "../lib/api-config" import { API_PORT } from "../lib/api-config"
import { fetchApi } from "@/lib/api-config" // Cambiando import para usar fetchApi directamente import { fetchApi } from "@/lib/api-config" // Cambiando import para usar fetchApi directamente
import { import {
@@ -30,6 +30,10 @@ type TerminalPanelProps = {
onWebInteraction?: (interaction: any) => void onWebInteraction?: (interaction: any) => void
} }
export interface TerminalPanelHandle {
sendMessage: (message: string) => void
}
interface TerminalInstance { interface TerminalInstance {
id: string id: string
title: string title: string
@@ -134,12 +138,8 @@ const proxmoxCommands = [
{ cmd: "clear", desc: "Clear terminal screen" }, { cmd: "clear", desc: "Clear terminal screen" },
] ]
export const TerminalPanel: React.FC<TerminalPanelProps> = ({ const TerminalPanel = forwardRef<TerminalPanelHandle, TerminalPanelProps>(
websocketUrl, ({ websocketUrl, onClose, initMessage, onWebInteraction }, ref) => {
onClose,
initMessage,
onWebInteraction,
}) => {
const [terminals, setTerminals] = useState<TerminalInstance[]>([]) const [terminals, setTerminals] = useState<TerminalInstance[]>([])
const [activeTerminalId, setActiveTerminalId] = useState<string>("") const [activeTerminalId, setActiveTerminalId] = useState<string>("")
const [layout, setLayout] = useState<"single" | "grid">("grid") const [layout, setLayout] = useState<"single" | "grid">("grid")
@@ -155,6 +155,24 @@ export const TerminalPanel: React.FC<TerminalPanelProps> = ({
const containerRefs = useRef<{ [key: string]: HTMLDivElement | null }>({}) const containerRefs = useRef<{ [key: string]: HTMLDivElement | null }>({})
useImperativeHandle(
ref,
() => ({
sendMessage: (message: string) => {
console.log("[v0] TerminalPanel.sendMessage called with:", message)
// Send to the first terminal (or active terminal if available)
const terminal = terminals.find((t) => t.id === activeTerminalId) || terminals[0]
if (terminal?.ws && terminal.ws.readyState === WebSocket.OPEN) {
console.log("[v0] Sending message via WebSocket")
terminal.ws.send(message)
} else {
console.log("[v0] Cannot send message - no active WebSocket")
}
},
}),
[terminals, activeTerminalId],
)
useEffect(() => { useEffect(() => {
const updateDeviceType = () => { const updateDeviceType = () => {
const width = window.innerWidth const width = window.innerWidth
@@ -1022,4 +1040,9 @@ export const TerminalPanel: React.FC<TerminalPanelProps> = ({
</Dialog> </Dialog>
</div> </div>
) )
} },
)
TerminalPanel.displayName = "TerminalPanel"
export default TerminalPanel