| @@ -1011,8 +1011,21 @@ | ||
| 1011 | 1011 | if (function_exists('add_settings_error')) { |
| 1012 | 1012 | add_settings_error('mxchat_pinecone_addon_options', 'mxchat_pinecone_docs_unverified', __('The document index host has not been checked, so the index type stayed on Vector index. Click Check index (or Create index for me) and save again.', 'mxchat')); |
| 1013 | 1013 | } |
| 1014 | 1014 | } |
| 1015 | + // 3e83e4: never point the live chatbot at a document index whose copy is | |
| 1016 | + // still running — the save keeps the previous type unless the owner | |
| 1017 | + // ticked Switch anyway. Only a vector → document switch is gated. | |
| 1018 | + $existing_type = (($existing['mxchat_pinecone_index_type'] ?? 'vector') === 'document') ? 'document' : 'vector'; | |
| 1019 | + if ($index_type === 'document' && $existing_type !== 'document' && class_exists('MxChat_Pinecone_Documents') && empty($input['mxchat_pinecone_docs_switch_anyway'])) { | |
| 1020 | + $running = MxChat_Pinecone_Documents::migration_blocks_switch($host_for_check); | |
| 1021 | + if ($running !== null) { | |
| 1022 | + $index_type = 'vector'; | |
| 1023 | + if (function_exists('add_settings_error')) { | |
| 1024 | + add_settings_error('mxchat_pinecone_addon_options', 'mxchat_pinecone_docs_copy_running', MxChat_Pinecone_Documents::switch_blocked_message($running)); | |
| 1025 | + } | |
| 1026 | + } | |
| 1027 | + } | |
| 1015 | 1028 | $sanitized['mxchat_pinecone_index_type'] = $index_type; |
| 1016 | 1029 | $sanitized['mxchat_pinecone_docs_verified_host'] = $verified_host; |
| 1017 | 1030 | $vector_host = str_replace(['https://', 'http://'], '', sanitize_text_field($input['mxchat_pinecone_vector_host'] ?? ($existing['mxchat_pinecone_vector_host'] ?? ''))); |
| 1018 | 1031 | $sanitized['mxchat_pinecone_vector_host'] = trim($vector_host, '/'); |