| @@ -1063,8 +1063,15 @@ | ||
| 1063 | 1063 | $new_value = ($value === 'document') ? 'document' : 'vector'; |
| 1064 | 1064 | if ($new_value === 'document' && strtolower(trim((string) ($current_options['mxchat_pinecone_host'] ?? ''), '/')) !== strtolower((string) ($current_options['mxchat_pinecone_docs_verified_host'] ?? ''))) { |
| 1065 | 1065 | wp_send_json_error(['message' => esc_html__('Check the document index host first (Check index or Create index for me).', 'mxchat')]); |
| 1066 | 1066 | } |
| 1067 | + // 3e83e4: same gate as the form save — no switch onto a half-copied index. | |
| 1068 | + if ($new_value === 'document' && (($current_options['mxchat_pinecone_index_type'] ?? 'vector') !== 'document') && class_exists('MxChat_Pinecone_Documents')) { | |
| 1069 | + $running = MxChat_Pinecone_Documents::migration_blocks_switch((string) ($current_options['mxchat_pinecone_host'] ?? '')); | |
| 1070 | + if ($running !== null) { | |
| 1071 | + wp_send_json_error(['message' => MxChat_Pinecone_Documents::switch_blocked_message($running)]); | |
| 1072 | + } | |
| 1073 | + } | |
| 1067 | 1074 | break; |
| 1068 | 1075 | case 'mxchat_pinecone_vector_host': |
| 1069 | 1076 | $new_value = trim(str_replace(['https://', 'http://'], '', sanitize_text_field($value)), '/'); |
| 1070 | 1077 | break; |