Skip to content

Commit

Permalink
Fix stop button bug
Browse files Browse the repository at this point in the history
We were setting the stop button to true and it would unset if there was an error, then set again as the other item started streaming. This should make the stop button dependent on the fetch function in the child.
  • Loading branch information
rebeccaalpert committed Nov 6, 2024
1 parent c3a288f commit 5344bcc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/app/Compare/CompareLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,18 @@ export const CompareLayout: React.FunctionComponent = () => {

React.useEffect(() => {
if (status) {
if (status.child1.isMessageStreaming || status.child2.isMessageStreaming) {
const childIsStreaming = status.child1.isMessageStreaming || status.child2.isMessageStreaming;
const childrenHaveStopped =
status.child1.isMessageStreaming === false && status.child2.isMessageStreaming === false;
if (childIsStreaming) {
setHasStopButton(true);
return;
}
if (childrenHaveStopped) {
setHasStopButton(false);
return;
}
}
setHasStopButton(false);
return;
}, [status]);

Expand All @@ -91,7 +97,6 @@ export const CompareLayout: React.FunctionComponent = () => {
const handleSend = (value: string) => {
setInput(value);
setHasNewInput(!hasNewInput);
setHasStopButton(true);
};

const changeSearchParams = (_event, value: string, order: string) => {
Expand Down

0 comments on commit 5344bcc

Please sign in to comment.