Fix connection profile for CC setting incorrect source by preset

9197ed7fcef9ca9ab6c443bbb1de770d1af311ec

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +19 -11Ignore whitespace
public/script.js+12 -5
@@ -8569,20 +8569,27 @@ async function connectAPISlash(args, text) {
85698569 return '';
85708570 }
85718571
8572- $(`#main_api option[value='${apiConfig.selected || text}']`).prop('selected', true);
8572+ let connectionRequired = false;
8573- $('#main_api').trigger('change');
85748573
85758574 if (main_api !== apiConfig.sourceselected) {
8575+ $(`#main_api option[value='${apiConfig.selected || text}']`).prop('selected', true);
8576+ $('#main_api').trigger('change');
8577+ connectionRequired = true;
8578+ }
8579+
8580+ if (apiConfig.source && oai_settings.chat_completion_source !== apiConfig.source) {
85768581 $(`#chat_completion_source option[value='${apiConfig.source}']`).prop('selected', true);
85778582 $('#chat_completion_source').trigger('change');
8583+ connectionRequired = true;
85788584 }
85798585
85808586 if (apiConfig.type && textgen_settings.type !== apiConfig.type) {
85818587 $(`#textgen_type option[value='${apiConfig.type}']`).prop('selected', true);
85828588 $('#textgen_type').trigger('change');
8589+ connectionRequired = true;
85838590 }
85848591
85858592 if (connectionRequired && apiConfig.button) {
85868593 $(apiConfig.button).trigger('click');
85878594 }
85888595
public/scripts/extensions/connection-manager/index.js+7 -6
@@ -19,20 +19,21 @@ const DEFAULT_SETTINGS = {
1919 selectedProfile: null,
2020};
2121
2222const COMMON_COMMANDSCC_COMMANDS = [
2323 'api',
2424 'preset',
25+ // Do not fix; CC needs to set the API twice because it could be overridden by the preset
26+ 'api',
2527 'api-url',
2628 'model',
27-];
28-
29-const CC_COMMANDS = [
30- ...COMMON_COMMANDS,
3129 'proxy',
3230];
3331
3432const TC_COMMANDS = [
35- ...COMMON_COMMANDS,
33+ 'api',
34+ 'preset',
35+ 'api-url',
36+ 'model',
3637 'instruct',
3738 'context',
3839 'instruct-state',