Fix rating bar not showing for own published tools in flat directories
Tools published by the user and stored at ~/.cmdforge/<name>/ (no owner subdir) had no way to resolve the registry owner, so get_tool_registry_info returned None and the rating bar was hidden. Added fallback_owner parameter that uses the current user's slug when no owner can be determined from the path or config. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
7022bb10f2
commit
9a284d7d04
|
|
@ -154,10 +154,16 @@ def get_tool_publish_state(tool_name: str) -> Tuple[str, Optional[str]]:
|
|||
return ("local", None)
|
||||
|
||||
|
||||
def get_tool_registry_info(tool_name: str) -> Optional[Tuple[str, str]]:
|
||||
def get_tool_registry_info(tool_name: str, fallback_owner: Optional[str] = None) -> Optional[Tuple[str, str]]:
|
||||
"""
|
||||
Get registry owner/name for a tool if it's registry-sourced.
|
||||
|
||||
Args:
|
||||
tool_name: Qualified or simple tool name.
|
||||
fallback_owner: Owner slug to use when the tool has a registry_hash
|
||||
but no owner can be determined from the path or config (e.g. the
|
||||
user's own published tools stored in a flat directory).
|
||||
|
||||
Returns:
|
||||
(owner, name) tuple if tool is from registry, None if local-only.
|
||||
"""
|
||||
|
|
@ -185,6 +191,10 @@ def get_tool_registry_info(tool_name: str) -> Optional[Tuple[str, str]]:
|
|||
if len(parts) == 2:
|
||||
return (parts[0], parts[1])
|
||||
|
||||
# Last resort: use fallback owner (current user's slug)
|
||||
if fallback_owner:
|
||||
return (fallback_owner, tool_name)
|
||||
|
||||
return None
|
||||
except Exception:
|
||||
return None
|
||||
|
|
@ -804,7 +814,7 @@ class ToolsPage(QWidget):
|
|||
|
||||
def _update_rating_bar(self, qname: str):
|
||||
"""Update the rating bar widget at the bottom of the detail panel."""
|
||||
registry_info = get_tool_registry_info(qname)
|
||||
registry_info = get_tool_registry_info(qname, self._my_slug)
|
||||
if not registry_info:
|
||||
self.rating_bar.setVisible(False)
|
||||
return
|
||||
|
|
@ -953,7 +963,7 @@ class ToolsPage(QWidget):
|
|||
self.btn_rate.setVisible(False)
|
||||
return
|
||||
|
||||
registry_info = get_tool_registry_info(tool_name)
|
||||
registry_info = get_tool_registry_info(tool_name, self._my_slug)
|
||||
if not registry_info:
|
||||
self.btn_rate.setVisible(False)
|
||||
return
|
||||
|
|
@ -1001,7 +1011,7 @@ class ToolsPage(QWidget):
|
|||
|
||||
def _fetch_rating_if_needed(self, tool_name: str):
|
||||
"""Fetch rating data for a registry tool if not cached."""
|
||||
registry_info = get_tool_registry_info(tool_name)
|
||||
registry_info = get_tool_registry_info(tool_name, self._my_slug)
|
||||
if not registry_info:
|
||||
return
|
||||
|
||||
|
|
@ -1046,7 +1056,7 @@ class ToolsPage(QWidget):
|
|||
return
|
||||
|
||||
tool_name = self._get_qualified_name() or self._current_tool.name
|
||||
registry_info = get_tool_registry_info(tool_name)
|
||||
registry_info = get_tool_registry_info(tool_name, self._my_slug)
|
||||
if not registry_info:
|
||||
return
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue