refactor: update CheckboxButton to support controlled state and enhance ToolsDropdown with permission-based toggles for web search and code interpreter

This commit is contained in:
Danny Avila 2025-06-22 11:45:15 -04:00
parent 727d4a8a77
commit 9eb62370a4
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
5 changed files with 84 additions and 51 deletions

View file

@ -54,8 +54,11 @@ export function useToolToggle({
},
);
const isAuthenticated =
externalIsAuthenticated ?? (authConfig ? (authQuery?.data?.authenticated ?? false) : false);
const isAuthenticated = useMemo(
() =>
externalIsAuthenticated ?? (authConfig ? (authQuery?.data?.authenticated ?? false) : false),
[externalIsAuthenticated, authConfig, authQuery.data?.authenticated],
);
const isToolEnabled = useMemo(() => {
return ephemeralAgent?.[toolKey] ?? false;
@ -72,10 +75,10 @@ export function useToolToggle({
);
const handleChange = useCallback(
(e: React.ChangeEvent<HTMLInputElement>, isChecked: boolean) => {
({ e, isChecked }: { e?: React.ChangeEvent<HTMLInputElement>; isChecked: boolean }) => {
if (isAuthenticated !== undefined && !isAuthenticated && setIsDialogOpen) {
setIsDialogOpen(true);
e.preventDefault();
e?.preventDefault?.();
return;
}
setToggleState(isChecked);