Now add the `deleteAiResponse()` JS function in thread_view.php. Let me find a good spot near the other response functions:


3201:        async function quickViewResponse(responseId) {


  3196→                document.getElementById('loading-overlay').classList.remove('active');
  3197→            }
  3198→        }
  3199→
  3200→        // Quick view response in modal (no page scroll)
  3201→        async function quickViewResponse(responseId) {
  3202→            try {
  3203→                // Mark this row as last viewed

                document.getElementById('loading-overlay').classList.remove('active');
            }
        }

        // Quick view response in modal (no page scroll)
        async function quickViewResponse(responseId) {
            try {
                // Mark this row as last viewed


Edit

        // Quick view response in modal (no page scroll)
        async function quickViewResponse(responseId) {

        // Delete a saved AI response
        async function deleteAiResponse(responseId) {
            if (!confirm('Delete this AI response? This cannot be undone.')) return;
            try {
                var response = await fetch('api.php?action=delete_ai_response', {
                    method: 'POST',
                    headers: {'Content-Type': 'application/json'},
                    body: JSON.stringify({response_id: responseId})
                });
                var data = await response.json();
                if (data.success) {
                    var el = document.getElementById('saved-response-' + responseId);
                    if (el) el.remove();
                } else {
                    alert('Error: ' + (data.error || 'Delete failed'));
                }
            } catch(e) {
                alert('Error deleting response: ' + e.message);
            }
        }

        // Quick view response in modal (no page scroll)
        async function quickViewResponse(responseId) {