Remove local hash comparison for publish state detection
Simplified approach: just show the moderation status from the server without trying to detect local modifications. This eliminates the fragile hash comparison that kept breaking due to representation differences between to_dict(), raw YAML, and server-side normalization. States are now simply: local, pending, published, changes_requested, rejected Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
66c0fc77ae
commit
9f60e84075
|
|
@ -20,7 +20,6 @@ from ...tool import (
|
|||
get_tools_dir
|
||||
)
|
||||
from ...config import load_config
|
||||
from ...hash_utils import compute_config_hash
|
||||
|
||||
|
||||
class StatusSyncWorker(QThread):
|
||||
|
|
@ -99,12 +98,11 @@ def get_tool_publish_state(tool_name: str) -> Tuple[str, Optional[str]]:
|
|||
|
||||
Returns:
|
||||
Tuple of (state, registry_hash) where state is:
|
||||
- "published" - approved in registry and current hash matches
|
||||
- "published" - approved in registry
|
||||
- "pending" - submitted but awaiting moderation
|
||||
- "changes_requested" - admin requested changes before approval
|
||||
- "rejected" - rejected by admin
|
||||
- "modified" - has registry_hash but current hash differs
|
||||
- "local" - no registry_hash (never published/downloaded)
|
||||
- "local" - no registry_hash (never published)
|
||||
"""
|
||||
config_path = get_tools_dir() / tool_name / "config.yaml"
|
||||
if not config_path.exists():
|
||||
|
|
@ -118,14 +116,7 @@ def get_tool_publish_state(tool_name: str) -> Tuple[str, Optional[str]]:
|
|||
if not registry_hash:
|
||||
return ("local", None)
|
||||
|
||||
# Compute hash from raw config, same as server does during publish
|
||||
# Don't use to_dict() as it may add/remove fields (e.g., empty arguments: [])
|
||||
current_hash = compute_config_hash(config)
|
||||
|
||||
if current_hash != registry_hash:
|
||||
return ("modified", registry_hash)
|
||||
|
||||
# Hash matches - check moderation status
|
||||
# Return the moderation status directly - no local hash comparison
|
||||
if registry_status == "approved":
|
||||
return ("published", registry_hash)
|
||||
elif registry_status == "changes_requested":
|
||||
|
|
@ -133,7 +124,6 @@ def get_tool_publish_state(tool_name: str) -> Tuple[str, Optional[str]]:
|
|||
elif registry_status == "rejected":
|
||||
return ("rejected", registry_hash)
|
||||
else:
|
||||
# pending or unknown
|
||||
return ("pending", registry_hash)
|
||||
except Exception:
|
||||
return ("local", None)
|
||||
|
|
@ -334,10 +324,6 @@ class ToolsPage(QWidget):
|
|||
display_name = f"{name} ✗"
|
||||
tooltip = "Rejected by moderator"
|
||||
color = QColor(220, 38, 38) # Red
|
||||
elif state == "modified":
|
||||
display_name = f"{name} ●"
|
||||
tooltip = "Published to registry - local modifications"
|
||||
color = QColor(221, 107, 32) # Orange
|
||||
else:
|
||||
display_name = name
|
||||
tooltip = "Local tool - not published"
|
||||
|
|
@ -556,12 +542,6 @@ class ToolsPage(QWidget):
|
|||
f"padding: 8px 12px; margin-bottom: 12px; font-size: 12px;'>"
|
||||
f"<strong>Reason:</strong><br>{feedback_escaped}</div>"
|
||||
)
|
||||
elif state == "modified":
|
||||
lines.append(
|
||||
"<p style='background: #feebc8; color: #c05621; padding: 6px 10px; "
|
||||
"border-radius: 4px; margin-bottom: 12px; font-size: 12px;'>"
|
||||
"● Modified since last publish - republish to update registry</p>"
|
||||
)
|
||||
|
||||
# Source info
|
||||
if tool.source:
|
||||
|
|
|
|||
Loading…
Reference in New Issue