mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-12-15 00:26:23 +00:00
Update script-terminal-modal.tsx
This commit is contained in:
@@ -44,6 +44,16 @@ export function ScriptTerminalModal({
|
|||||||
const [interactionInput, setInteractionInput] = useState("")
|
const [interactionInput, setInteractionInput] = useState("")
|
||||||
const terminalRef = useRef<any>(null)
|
const terminalRef = useRef<any>(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:", {
|
console.log("[v0] ScriptTerminalModal opened with:", {
|
||||||
@@ -70,12 +80,17 @@ export function ScriptTerminalModal({
|
|||||||
const wsUrl = getScriptWebSocketUrl()
|
const wsUrl = getScriptWebSocketUrl()
|
||||||
|
|
||||||
const handleWebInteraction = (interaction: WebInteraction) => {
|
const handleWebInteraction = (interaction: WebInteraction) => {
|
||||||
console.log("[v0] Received web interaction:", interaction)
|
console.log("[v0] handleWebInteraction called with:", interaction)
|
||||||
setCurrentInteraction(interaction)
|
setCurrentInteraction(interaction)
|
||||||
|
console.log("[v0] setCurrentInteraction called with interaction")
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleInteractionResponse = (value: string) => {
|
const handleInteractionResponse = (value: string) => {
|
||||||
if (!terminalRef.current || !currentInteraction) return
|
console.log("[v0] handleInteractionResponse called with value:", value)
|
||||||
|
if (!terminalRef.current || !currentInteraction) {
|
||||||
|
console.log("[v0] Cannot send response - no terminal ref or interaction")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const response = JSON.stringify({
|
const response = JSON.stringify({
|
||||||
type: "interaction_response",
|
type: "interaction_response",
|
||||||
@@ -89,8 +104,12 @@ export function ScriptTerminalModal({
|
|||||||
const terminal = terminalRef.current
|
const terminal = terminalRef.current
|
||||||
if (terminal?.terminals?.[0]?.ws) {
|
if (terminal?.terminals?.[0]?.ws) {
|
||||||
terminal.terminals[0].ws.send(response)
|
terminal.terminals[0].ws.send(response)
|
||||||
|
console.log("[v0] Response sent successfully")
|
||||||
|
} else {
|
||||||
|
console.log("[v0] Could not send response - no WebSocket available")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("[v0] Clearing currentInteraction after response")
|
||||||
setCurrentInteraction(null)
|
setCurrentInteraction(null)
|
||||||
setInteractionInput("")
|
setInteractionInput("")
|
||||||
}
|
}
|
||||||
@@ -148,11 +167,11 @@ export function ScriptTerminalModal({
|
|||||||
<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) => {
|
||||||
// Prevent closing when clicking outside
|
console.log("[v0] onInteractOutside triggered - preventing close")
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
}}
|
}}
|
||||||
onEscapeKeyDown={(e) => {
|
onEscapeKeyDown={(e) => {
|
||||||
// Prevent closing with ESC key
|
console.log("[v0] onEscapeKeyDown triggered - preventing close")
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user