| 122 | |
| 123 | // Insert sensor variable at cursor position |
| 124 | const insertSystemPromptText = (text: string) => { |
| 125 | if (!textareaRef.current) return; |
| 126 | const { selectionStart, selectionEnd, value } = textareaRef.current; |
| 127 | const newPrompt = `${value.substring(0, selectionStart)} ${text} ${value.substring(selectionEnd)}`; |
| 128 | setEditedPrompt(newPrompt); |
| 129 | setTimeout(() => { |
| 130 | textareaRef.current?.focus(); |
| 131 | const newPos = selectionStart + text.length + 2; |
| 132 | textareaRef.current?.setSelectionRange(newPos, newPos); |
| 133 | }, 0); |
| 134 | }; |
| 135 | |
| 136 | // Handle modal close with save |
| 137 | const handleClose = () => { |