fix: Improve tool metadata and dropdown state management (#7257)

* 🐛 (component.py): Fix issue where tags attribute may not exist on tool object
🐛 (index.tsx): Fix bug where value may not be included in options before setting it

* 🐛 (component.py): fix issue where tags list is empty if tool.tags is not defined, now default to [tool.name] to ensure at least one tag is present

---------

Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
This commit is contained in:
Cristhian Zanforlin Lousa 2025-03-25 15:21:03 -03:00 committed by GitHub
commit ce5a4ff786
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -1166,7 +1166,7 @@ class Component(CustomComponent):
{
"name": tool.name,
"description": tool.description,
"tags": tool.tags,
"tags": tool.tags if hasattr(tool, "tags") and tool.tags else [tool.name],
"status": True, # Initialize all tools with status True
}
for tool in tools

View file

@ -62,6 +62,12 @@ export default function Dropdown({
const [refreshOptions, setRefreshOptions] = useState(false);
const refButton = useRef<HTMLButtonElement>(null);
value = useMemo(() => {
if (!options.includes(value)) {
return null;
}
return value;
}, [value, options]);
// Initialize utilities and constants
const placeholderName = name
? formatPlaceholderName(name)