fix: persist Slack signing secret and sync models.json in web mode

Two critical correctness bugs from recent commits:

1. Hermes Slack signingSecret was stripped from config.yaml on save but
   never written to SLACK_SIGNING_SECRET in ~/.hermes/.env, causing data
   loss and broken HTTP webhook mode after any channel save.

2. Tauri write_openclaw_config syncs providers to agents/*/models.json
   (Issue #127 fix) but the dev-api web shim did not, leaving Gateway
   with stale models.json after Models page saves in browser mode.

Add regression tests for both paths.

Co-authored-by: 晴天 <1186258278@users.noreply.github.com>
This commit is contained in:
Cursor Agent
2026-05-29 11:10:22 +00:00
parent 38934fe754
commit 2debbc5f2e
4 changed files with 208 additions and 0 deletions

View File

@@ -3402,6 +3402,10 @@ fn build_hermes_channel_config_values(
.unwrap_or_default();
form.insert("appToken".to_string(), Value::String(app_token));
insert_json_string_if_present(&mut form, &extra, "signing_secret", "signingSecret");
let signing_secret = hermes_env_value(env_values, "SLACK_SIGNING_SECRET")
.or_else(|| json_form_string(&form, "signingSecret"))
.unwrap_or_default();
form.insert("signingSecret".to_string(), Value::String(signing_secret));
insert_json_string_if_present(&mut form, &extra, "webhook_path", "webhookPath");
}
"feishu" => {
@@ -11182,6 +11186,10 @@ fn build_hermes_channel_env_updates(platform: &str, form: &Value) -> Vec<(String
"SLACK_APP_TOKEN",
form_string(form, "appToken").unwrap_or_default(),
);
push(
"SLACK_SIGNING_SECRET",
form_string(form, "signingSecret").unwrap_or_default(),
);
push("SLACK_ALLOWED_USERS", csv_env_value(form, "allowFrom"));
if let Some(value) = form_bool(form, "requireMention") {
push("SLACK_REQUIRE_MENTION", bool_env_value(value));
@@ -24517,6 +24525,41 @@ platforms:
);
}
#[test]
fn channel_env_updates_include_slack_signing_secret() {
let env = build_hermes_channel_env_updates(
"slack",
&json!({
"botToken": "xoxb-new",
"appToken": "xapp-new",
"signingSecret": "new-signing-secret",
"allowFrom": ["U1"],
"requireMention": true,
}),
);
assert!(env.contains(&(
"SLACK_BOT_TOKEN".to_string(),
"xoxb-new".to_string()
)));
assert!(env.contains(&(
"SLACK_APP_TOKEN".to_string(),
"xapp-new".to_string()
)));
assert!(env.contains(&(
"SLACK_SIGNING_SECRET".to_string(),
"new-signing-secret".to_string()
)));
assert!(env.contains(&(
"SLACK_ALLOWED_USERS".to_string(),
"U1".to_string()
)));
assert!(env.contains(&(
"SLACK_REQUIRE_MENTION".to_string(),
"true".to_string()
)));
}
#[test]
fn plugin_platform_values_prefer_env_and_preserve_yaml_runtime_fields() {
let config: serde_yaml::Value = serde_yaml::from_str(