From c56d2b2201a628745893eb2bc61ab577f4eb6326 Mon Sep 17 00:00:00 2001 From: Lars Date: Thu, 26 Mar 2026 11:40:19 +0100 Subject: [PATCH] fix: delete insights + placeholder cursor insertion (Issue #44) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BUG #44: Analysen löschen schlug fehl (kein Auth-Token) FIX: - api.deleteInsight() in api.js hinzugefügt - Analysis.jsx nutzt jetzt api.js mit Error-Handling - Nicht mehr raw fetch() ohne Token BUG: Platzhalter wurden am Ende eingefügt statt an Cursor-Position FIX: - useRef für baseTemplateRef hinzugefügt - Cursor-Position tracking (onClick + onKeyUp) - Insert at cursor: template.slice(0, pos) + placeholder + template.slice(pos) - Focus + Cursor-Position nach Insert wiederhergestellt version: 9.5.2 (bugfix) module: prompts 2.0.2, insights 1.3.1 --- .../src/components/UnifiedPromptModal.jsx | 25 ++++++++++++++++--- frontend/src/pages/Analysis.jsx | 13 +++++----- frontend/src/utils/api.js | 1 + 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/UnifiedPromptModal.jsx b/frontend/src/components/UnifiedPromptModal.jsx index 2157eb2..24badf7 100644 --- a/frontend/src/components/UnifiedPromptModal.jsx +++ b/frontend/src/components/UnifiedPromptModal.jsx @@ -1,4 +1,4 @@ -import { useState, useEffect } from 'react' +import { useState, useEffect, useRef } from 'react' import { api } from '../utils/api' import { X, Plus, Trash2, MoveUp, MoveDown, Code } from 'lucide-react' import PlaceholderPicker from './PlaceholderPicker' @@ -39,6 +39,8 @@ export default function UnifiedPromptModal({ prompt, onSave, onClose }) { const [error, setError] = useState(null) const [showPlaceholderPicker, setShowPlaceholderPicker] = useState(false) const [pickerTarget, setPickerTarget] = useState(null) // 'base' or {stage, promptIdx} + const [cursorPosition, setCursorPosition] = useState(null) // Track cursor position for insertion + const baseTemplateRef = useRef(null) // Test functionality const [testing, setTesting] = useState(false) @@ -514,9 +516,12 @@ export default function UnifiedPromptModal({ prompt, onSave, onClose }) {

Template