From e89376d66ff2f72caf069cdddd65c161bb4f7540 Mon Sep 17 00:00:00 2001 From: nftpoetrist Date: Sun, 3 May 2026 11:05:20 +0300 Subject: [PATCH] fix(setup): add missing SLACK_HOME_CHANNEL prompt to _setup_slack() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _setup_slack() was the only platform setup function that did not prompt for a home channel. All four sibling setups (_setup_telegram, _setup_discord, _setup_mattermost, _setup_bluebubbles) close with an identical home-channel block, and setup_gateway() already checks for SLACK_HOME_CHANNEL presence at the end of the wizard — but the value was never collected, leaving cron delivery and cross-platform notifications silently broken for Slack after a fresh hermes setup run. Add the standard home-channel prompt at the end of _setup_slack(), symmetric with the Discord implementation. Add two unit tests that verify the prompt is saved when provided and skipped when left blank. --- hermes_cli/setup.py | 10 ++++++++++ tests/hermes_cli/test_setup.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/hermes_cli/setup.py b/hermes_cli/setup.py index 9ca29968fd..6b51f81059 100644 --- a/hermes_cli/setup.py +++ b/hermes_cli/setup.py @@ -2047,6 +2047,16 @@ def _setup_slack(): print_warning("⚠️ No Slack allowlist set - unpaired users will be denied by default.") print_info(" Set SLACK_ALLOW_ALL_USERS=true or GATEWAY_ALLOW_ALL_USERS=true only if you intentionally want open workspace access.") + print() + print_info("📬 Home Channel: where Hermes delivers cron job results,") + print_info(" cross-platform messages, and notifications.") + print_info(" To get a channel ID: open the channel in Slack, then right-click") + print_info(" the channel name → Copy link — the ID starts with C (e.g. C01ABC2DE3F).") + print_info(" You can also set this later by typing /set-home in a Slack channel.") + home_channel = prompt("Home channel ID (leave empty to set later with /set-home)") + if home_channel: + save_env_value("SLACK_HOME_CHANNEL", home_channel.strip()) + def _write_slack_manifest_and_instruct(): """Generate the Slack manifest, write it under HERMES_HOME, and print diff --git a/tests/hermes_cli/test_setup.py b/tests/hermes_cli/test_setup.py index 72adc27c0c..f7b491ddf3 100644 --- a/tests/hermes_cli/test_setup.py +++ b/tests/hermes_cli/test_setup.py @@ -613,3 +613,35 @@ def test_offer_launch_chat_falls_back_to_module(monkeypatch): setup_mod._offer_launch_chat() assert exec_calls == [(sys.executable, [sys.executable, "-m", "hermes_cli.main", "chat"])] + + +def test_setup_slack_saves_home_channel(monkeypatch): + """_setup_slack() saves SLACK_HOME_CHANNEL when the user provides one.""" + saved = {} + prompts = iter(["xoxb-test-token", "xapp-test-token", "", "C01ABC2DE3F"]) + + monkeypatch.setattr(setup_mod, "get_env_value", lambda key: "") + monkeypatch.setattr(setup_mod, "save_env_value", lambda k, v: saved.update({k: v})) + monkeypatch.setattr(setup_mod, "prompt", lambda *_a, **_kw: next(prompts)) + monkeypatch.setattr(setup_mod, "prompt_yes_no", lambda *_a, **_kw: False) + monkeypatch.setattr(setup_mod, "_write_slack_manifest_and_instruct", lambda: None) + + setup_mod._setup_slack() + + assert saved.get("SLACK_HOME_CHANNEL") == "C01ABC2DE3F" + + +def test_setup_slack_home_channel_empty_not_saved(monkeypatch): + """_setup_slack() does not save SLACK_HOME_CHANNEL when left blank.""" + saved = {} + prompts = iter(["xoxb-test-token", "xapp-test-token", "", ""]) + + monkeypatch.setattr(setup_mod, "get_env_value", lambda key: "") + monkeypatch.setattr(setup_mod, "save_env_value", lambda k, v: saved.update({k: v})) + monkeypatch.setattr(setup_mod, "prompt", lambda *_a, **_kw: next(prompts)) + monkeypatch.setattr(setup_mod, "prompt_yes_no", lambda *_a, **_kw: False) + monkeypatch.setattr(setup_mod, "_write_slack_manifest_and_instruct", lambda: None) + + setup_mod._setup_slack() + + assert "SLACK_HOME_CHANNEL" not in saved