Skip to content

Commit

Permalink
feat: add notification to settings that will reset LLM chat history (#…
Browse files Browse the repository at this point in the history
…428)

fixes #420
  • Loading branch information
ellvix authored Mar 6, 2024
1 parent 2a3d6af commit 01f42d0
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/js/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ class Menu {
</div>
</div>
<div class="modal-footer">
<button type="button" id="save_and_close_menu">Save and Close</button>
<button type="button" id="save_and_close_menu" aria-labelledby="save_and_close_text"><span id="save_and_close_text">Save and Close</span></button>
<button type="button" id="close_menu">Close</button>
</div>
</div>
Expand Down Expand Up @@ -580,6 +580,16 @@ class Menu {
}
},
]);

// trigger notification that LLM will be reset
// this is done on change of LLM model, multi settings, or skill level
constants.events.push([
document.getElementById('LLM_model'),
'change',
function (e) {
menu.NotifyOfLLMReset();
},
]);
}

/**
Expand Down Expand Up @@ -721,6 +731,9 @@ class Menu {
document.getElementById('LLM_preferences').value =
constants.LLMPreferences;
}
if (document.getElementById('LLM_reset_notification')) {
document.getElementById('LLM_reset_notification').remove();
}
}

/**
Expand Down Expand Up @@ -778,6 +791,24 @@ class Menu {
.setAttribute('aria-live', constants.ariaMode);
}

/**
* Notifies the user that the LLM will be reset.
*/
NotifyOfLLMReset() {
let html =
'<p id="LLM_reset_notification">Note: Changes in LLM settings will reset any existing conversation.</p>';
document
.getElementById('save_and_close_menu')
.insertAdjacentHTML('beforebegin', html);

// add to aria button text
document
.getElementById('save_and_close_menu')
.setAttribute(
'aria-labelledby',
'save_and_close_text LLM_reset_notification'
);
}
/**
* Handles changes to the LLM model and multi-modal settings.
* We reset if we change the LLM model, multi settings, or skill level.
Expand Down

0 comments on commit 01f42d0

Please sign in to comment.