mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-12-14 16:16:21 +00:00
Update AppImage
This commit is contained in:
@@ -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, type TerminalPanelHandle } from "./terminal-panel"
|
import { TerminalPanel } from "./terminal-panel"
|
||||||
import { API_PORT } from "@/lib/api-config"
|
import { API_PORT } from "@/lib/api-config"
|
||||||
|
|
||||||
interface WebInteraction {
|
interface WebInteraction {
|
||||||
@@ -42,36 +42,16 @@ 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<TerminalPanelHandle>(null)
|
const wsRef = useRef<WebSocket | null>(null)
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
console.log("[v0] currentInteraction changed:", currentInteraction)
|
|
||||||
if (currentInteraction) {
|
|
||||||
console.log("[v0] Interaction opened, type:", currentInteraction.type, "id:", currentInteraction.id)
|
|
||||||
} else {
|
|
||||||
console.log("[v0] Interaction closed/cleared")
|
|
||||||
console.trace("[v0] Stack trace for currentInteraction = null")
|
|
||||||
}
|
|
||||||
}, [currentInteraction])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (open) {
|
if (open) {
|
||||||
console.log("[v0] ScriptTerminalModal opened with:", {
|
|
||||||
scriptPath,
|
|
||||||
scriptName,
|
|
||||||
params,
|
|
||||||
sessionId,
|
|
||||||
})
|
|
||||||
// Reset state only when modal opens
|
|
||||||
setIsComplete(false)
|
setIsComplete(false)
|
||||||
setExitCode(null)
|
setExitCode(null)
|
||||||
setInteractionInput("")
|
setInteractionInput("")
|
||||||
// Don't clear currentInteraction here - it causes issues
|
|
||||||
} else {
|
|
||||||
// Clear interaction when modal closes
|
|
||||||
setCurrentInteraction(null)
|
setCurrentInteraction(null)
|
||||||
}
|
}
|
||||||
}, [open]) // Only depend on 'open' to avoid unnecessary re-runs
|
}, [open])
|
||||||
|
|
||||||
const getScriptWebSocketUrl = (): string => {
|
const getScriptWebSocketUrl = (): string => {
|
||||||
if (typeof window === "undefined") {
|
if (typeof window === "undefined") {
|
||||||
@@ -85,16 +65,16 @@ export function ScriptTerminalModal({
|
|||||||
|
|
||||||
const wsUrl = getScriptWebSocketUrl()
|
const wsUrl = getScriptWebSocketUrl()
|
||||||
|
|
||||||
|
const handleWebSocketCreated = (ws: WebSocket) => {
|
||||||
|
wsRef.current = ws
|
||||||
|
}
|
||||||
|
|
||||||
const handleWebInteraction = (interaction: WebInteraction) => {
|
const handleWebInteraction = (interaction: WebInteraction) => {
|
||||||
console.log("[v0] handleWebInteraction called with:", interaction)
|
|
||||||
setCurrentInteraction(interaction)
|
setCurrentInteraction(interaction)
|
||||||
console.log("[v0] currentInteraction set to:", interaction.type, interaction.id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleInteractionResponse = (value: string) => {
|
const handleInteractionResponse = (value: string) => {
|
||||||
console.log("[v0] handleInteractionResponse called with value:", value)
|
if (!wsRef.current || !currentInteraction) {
|
||||||
if (!terminalRef.current || !currentInteraction) {
|
|
||||||
console.log("[v0] Cannot send response - no terminal ref or interaction")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,12 +84,10 @@ export function ScriptTerminalModal({
|
|||||||
value: value,
|
value: value,
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log("[v0] Sending interaction response:", response)
|
if (wsRef.current.readyState === WebSocket.OPEN) {
|
||||||
|
wsRef.current.send(response)
|
||||||
|
}
|
||||||
|
|
||||||
terminalRef.current.sendMessage(response)
|
|
||||||
console.log("[v0] Response sent successfully")
|
|
||||||
|
|
||||||
console.log("[v0] Clearing currentInteraction after response")
|
|
||||||
setCurrentInteraction(null)
|
setCurrentInteraction(null)
|
||||||
setInteractionInput("")
|
setInteractionInput("")
|
||||||
}
|
}
|
||||||
@@ -144,13 +122,13 @@ export function ScriptTerminalModal({
|
|||||||
|
|
||||||
<div className="flex-1 overflow-hidden">
|
<div className="flex-1 overflow-hidden">
|
||||||
<TerminalPanel
|
<TerminalPanel
|
||||||
ref={terminalRef}
|
|
||||||
websocketUrl={wsUrl}
|
websocketUrl={wsUrl}
|
||||||
initMessage={{
|
initMessage={{
|
||||||
script_path: scriptPath,
|
script_path: scriptPath,
|
||||||
params: params,
|
params: params,
|
||||||
}}
|
}}
|
||||||
onWebInteraction={handleWebInteraction}
|
onWebInteraction={handleWebInteraction}
|
||||||
|
onWebSocketCreated={handleWebSocketCreated}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -163,17 +141,11 @@ export function ScriptTerminalModal({
|
|||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
{currentInteraction && (
|
{currentInteraction && (
|
||||||
<Dialog open={true} modal={true}>
|
<Dialog open={true}>
|
||||||
<DialogContent
|
<DialogContent
|
||||||
className="max-w-4xl max-h-[80vh] overflow-y-auto"
|
className="max-w-4xl max-h-[80vh] overflow-y-auto"
|
||||||
onInteractOutside={(e) => {
|
onInteractOutside={(e) => e.preventDefault()}
|
||||||
console.log("[v0] onInteractOutside triggered - preventing close")
|
onEscapeKeyDown={(e) => e.preventDefault()}
|
||||||
e.preventDefault()
|
|
||||||
}}
|
|
||||||
onEscapeKeyDown={(e) => {
|
|
||||||
console.log("[v0] onEscapeKeyDown triggered - preventing close")
|
|
||||||
e.preventDefault()
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<DialogTitle>{currentInteraction.title}</DialogTitle>
|
<DialogTitle>{currentInteraction.title}</DialogTitle>
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
@@ -212,25 +184,24 @@ export function ScriptTerminalModal({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{currentInteraction.type === "input" ||
|
{(currentInteraction.type === "input" || currentInteraction.type === "inputbox") && (
|
||||||
(currentInteraction.type === "inputbox" && (
|
<div className="space-y-2">
|
||||||
<div className="space-y-2">
|
<Label>Your input:</Label>
|
||||||
<Label>Your input:</Label>
|
<Input
|
||||||
<Input
|
value={interactionInput}
|
||||||
value={interactionInput}
|
onChange={(e) => setInteractionInput(e.target.value)}
|
||||||
onChange={(e) => setInteractionInput(e.target.value)}
|
onKeyDown={(e) => {
|
||||||
onKeyDown={(e) => {
|
if (e.key === "Enter") {
|
||||||
if (e.key === "Enter") {
|
handleInteractionResponse(interactionInput)
|
||||||
handleInteractionResponse(interactionInput)
|
}
|
||||||
}
|
}}
|
||||||
}}
|
placeholder={currentInteraction.default || ""}
|
||||||
placeholder={currentInteraction.default || ""}
|
/>
|
||||||
/>
|
<Button onClick={() => handleInteractionResponse(interactionInput)} className="w-full">
|
||||||
<Button onClick={() => handleInteractionResponse(interactionInput)} className="w-full">
|
Submit
|
||||||
Submit
|
</Button>
|
||||||
</Button>
|
</div>
|
||||||
</div>
|
)}
|
||||||
))}
|
|
||||||
|
|
||||||
{currentInteraction.type === "msgbox" && (
|
{currentInteraction.type === "msgbox" && (
|
||||||
<Button onClick={() => handleInteractionResponse("ok")} className="w-full">
|
<Button onClick={() => handleInteractionResponse("ok")} className="w-full">
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user