🐘
check_pending_artifact.php
Back
📝 Php ⚡ Executable Ctrl+S: Save • Ctrl+R: Run • Ctrl+F: Find
<?php // check_pending_artifact.php - Check for pending artifacts and process them session_start(); header('Content-Type: application/json'); if (isset($_SESSION['pending_artifact'])) { $artifact = $_SESSION['pending_artifact']; // Add artifact to chat log $_SESSION['chat_log'][] = [ 'role' => 'artifact', 'title' => $artifact['title'], 'content' => $artifact['content'], 'compactContent' => $artifact['compactContent'], 'ts' => time() ]; // Add a simple acknowledgment request $userMessage = 'I submitted an artifact. Please briefly acknowledge you received it.'; // Add user message to chat log $_SESSION['chat_log'][] = [ 'role' => 'user', 'content' => $userMessage, 'ts' => time() ]; // Clear the pending artifact unset($_SESSION['pending_artifact']); // Return the data for dynamic loading echo json_encode([ 'pending' => true, 'artifact' => [ 'title' => htmlspecialchars($artifact['title'], ENT_QUOTES), 'content' => htmlspecialchars($artifact['content'], ENT_QUOTES), 'compactContent' => htmlspecialchars($artifact['compactContent'], ENT_QUOTES) ], 'userMessage' => htmlspecialchars($userMessage, ENT_QUOTES), 'autoSend' => true ]); } else { echo json_encode(['pending' => false]); } ?>