Skip to content

Commit

Permalink
Not clearing preamble messages (#137)
Browse files Browse the repository at this point in the history
* Not clearing preamble messages

* Fixed bug where preambles would stack when switching phase
  • Loading branch information
gsproston-scottlogic committed Aug 14, 2023
1 parent 3002284 commit 5a4497e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ function App() {
};

const clearMessages = () => {
setMessages([]);
// resetting the current phase will also reset the messages
setNewPhase(currentPhase);
};

const clearEmailBox = () => {
Expand All @@ -65,8 +66,9 @@ function App() {
const setNewPhase = (newPhase: number) => {
// reset emails and messages from front and backend
clearChat();
clearMessages();
clearEmailBox();
// clear frontend messages
setMessages([]);
setCurrentPhase(newPhase);

// add the preamble to the chat
Expand All @@ -89,10 +91,7 @@ function App() {
getCompletedPhases().then((numCompletedPhases) => {
setNumCompletedPhases(numCompletedPhases);
});
// get the default sandbox preamble
clearMessages();
const preambleMessage = PHASES[currentPhase].preamble;
addPhasePreambleMessage(preambleMessage.toLowerCase());
setNewPhase(currentPhase);
}, []);

return (
Expand Down

0 comments on commit 5a4497e

Please sign in to comment.