Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Fix unnecessary calls (Chat-input-panel) #565

Merged
merged 1 commit into from
Sep 6, 2024

Conversation

charles-marion
Copy link
Collaborator

Issue #, if available:

Description of changes:
The useEffect fetching the models & workspace is called multiple times. It should be running once.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

id: props.sessionId ?? uuidv4(),
loading: typeof props.sessionId !== "undefined",
});
const [session, setSession] = useState<{ id: string; loading: boolean } | undefined>();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Session id was created twice.

@@ -263,7 +263,7 @@ export default function ChatInputPanel(props: ChatInputPanelProps) {
setReadyState(ReadyState.CLOSED);
}
})();
}, [appContext, state.modelsStatus, props]);
}, [appContext, props.session.id]); // eslint-disable-line react-hooks/exhaustive-deps
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

props was causing a new refresh on render. Instead it should refresh on a new session.

@charles-marion charles-marion merged commit 3e3d283 into aws-samples:main Sep 6, 2024
1 check passed
@charles-marion charles-marion deleted the bug_refresh branch September 6, 2024 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants