From 66c0fc77aec08c330e0b836a3adba840d8eeb15e Mon Sep 17 00:00:00 2001 From: rob Date: Fri, 16 Jan 2026 20:37:29 -0400 Subject: [PATCH] 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 --- src/cmdforge/gui/dialogs/publish_dialog.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cmdforge/gui/dialogs/publish_dialog.py b/src/cmdforge/gui/dialogs/publish_dialog.py index 6fd1316..0e0a250 100644 --- a/src/cmdforge/gui/dialogs/publish_dialog.py +++ b/src/cmdforge/gui/dialogs/publish_dialog.py @@ -170,6 +170,9 @@ class PublishDialog(QDialog): self.progress.show() 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.success.connect(self._on_success) self._worker.error.connect(self._on_error) @@ -183,16 +186,20 @@ class PublishDialog(QDialog): self.status_label.setText("Published successfully!") 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") moderation_status = result.get("status", "pending") if config_hash and hasattr(self._tool, 'path') and self._tool.path: try: config_path = self._tool.path - if config_path.exists(): - config_data = yaml.safe_load(config_path.read_text()) or {} + if config_path.exists() and hasattr(self, '_published_config'): + # 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_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)) except Exception: pass # Non-critical - just won't show publish state