Fix GUI publish to save normalized config for hash consistency

The GUI was sending to_dict() output to server but only updating the
existing config file with the hash. This caused mismatches because
to_dict() adds fields like 'arguments: []' that weren't in the original.

Now saves the exact config that was published, ensuring local file
matches what was sent to server.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
rob 2026-01-16 20:37:29 -04:00
parent d7d0019472
commit 66c0fc77ae
1 changed files with 10 additions and 3 deletions

View File

@ -170,6 +170,9 @@ class PublishDialog(QDialog):
self.progress.show() self.progress.show()
self.status_label.setText("Publishing...") self.status_label.setText("Publishing...")
# Store the config we're publishing so we can save it on success
self._published_config = tool_config
self._worker = PublishWorker(config_yaml, readme) self._worker = PublishWorker(config_yaml, readme)
self._worker.success.connect(self._on_success) self._worker.success.connect(self._on_success)
self._worker.error.connect(self._on_error) self._worker.error.connect(self._on_error)
@ -183,16 +186,20 @@ class PublishDialog(QDialog):
self.status_label.setText("Published successfully!") self.status_label.setText("Published successfully!")
self.status_label.setStyleSheet("color: #38a169; font-weight: 600;") self.status_label.setStyleSheet("color: #38a169; font-weight: 600;")
# Save registry_hash and moderation status to local config for publish state tracking # Save the published config with registry tracking fields
# This ensures local file matches exactly what was sent to server (for hash consistency)
config_hash = result.get("config_hash") config_hash = result.get("config_hash")
moderation_status = result.get("status", "pending") moderation_status = result.get("status", "pending")
if config_hash and hasattr(self._tool, 'path') and self._tool.path: if config_hash and hasattr(self._tool, 'path') and self._tool.path:
try: try:
config_path = self._tool.path config_path = self._tool.path
if config_path.exists(): if config_path.exists() and hasattr(self, '_published_config'):
config_data = yaml.safe_load(config_path.read_text()) or {} # Use the exact config we published, add registry tracking fields
config_data = self._published_config.copy()
config_data["registry_hash"] = config_hash config_data["registry_hash"] = config_hash
config_data["registry_status"] = moderation_status config_data["registry_status"] = moderation_status
# Clear any old feedback
config_data.pop("registry_feedback", None)
config_path.write_text(yaml.dump(config_data, default_flow_style=False, sort_keys=False)) config_path.write_text(yaml.dump(config_data, default_flow_style=False, sort_keys=False))
except Exception: except Exception:
pass # Non-critical - just won't show publish state pass # Non-critical - just won't show publish state