Skip to content

Commit e89376d

Browse files
nftpoetristteknium1
authored andcommitted
fix(setup): add missing SLACK_HOME_CHANNEL prompt to _setup_slack()
_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.
1 parent 81ce945 commit e89376d

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

‎hermes_cli/setup.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,6 +2047,16 @@ def _setup_slack():
20472047
print_warning("⚠️ No Slack allowlist set - unpaired users will be denied by default.")
20482048
print_info(" Set SLACK_ALLOW_ALL_USERS=true or GATEWAY_ALLOW_ALL_USERS=true only if you intentionally want open workspace access.")
20492049

2050+
print()
2051+
print_info("📬 Home Channel: where Hermes delivers cron job results,")
2052+
print_info(" cross-platform messages, and notifications.")
2053+
print_info(" To get a channel ID: open the channel in Slack, then right-click")
2054+
print_info(" the channel name → Copy link — the ID starts with C (e.g. C01ABC2DE3F).")
2055+
print_info(" You can also set this later by typing /set-home in a Slack channel.")
2056+
home_channel = prompt("Home channel ID (leave empty to set later with /set-home)")
2057+
if home_channel:
2058+
save_env_value("SLACK_HOME_CHANNEL", home_channel.strip())
2059+
20502060

20512061
def _write_slack_manifest_and_instruct():
20522062
"""Generate the Slack manifest, write it under HERMES_HOME, and print

‎tests/hermes_cli/test_setup.py‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,3 +613,35 @@ def fake_execvp(path, argv):
613613
setup_mod._offer_launch_chat()
614614

615615
assert exec_calls == [(sys.executable, [sys.executable, "-m", "hermes_cli.main", "chat"])]
616+
617+
618+
def test_setup_slack_saves_home_channel(monkeypatch):
619+
"""_setup_slack() saves SLACK_HOME_CHANNEL when the user provides one."""
620+
saved = {}
621+
prompts = iter(["xoxb-test-token", "xapp-test-token", "", "C01ABC2DE3F"])
622+
623+
monkeypatch.setattr(setup_mod, "get_env_value", lambda key: "")
624+
monkeypatch.setattr(setup_mod, "save_env_value", lambda k, v: saved.update({k: v}))
625+
monkeypatch.setattr(setup_mod, "prompt", lambda *_a, **_kw: next(prompts))
626+
monkeypatch.setattr(setup_mod, "prompt_yes_no", lambda *_a, **_kw: False)
627+
monkeypatch.setattr(setup_mod, "_write_slack_manifest_and_instruct", lambda: None)
628+
629+
setup_mod._setup_slack()
630+
631+
assert saved.get("SLACK_HOME_CHANNEL") == "C01ABC2DE3F"
632+
633+
634+
def test_setup_slack_home_channel_empty_not_saved(monkeypatch):
635+
"""_setup_slack() does not save SLACK_HOME_CHANNEL when left blank."""
636+
saved = {}
637+
prompts = iter(["xoxb-test-token", "xapp-test-token", "", ""])
638+
639+
monkeypatch.setattr(setup_mod, "get_env_value", lambda key: "")
640+
monkeypatch.setattr(setup_mod, "save_env_value", lambda k, v: saved.update({k: v}))
641+
monkeypatch.setattr(setup_mod, "prompt", lambda *_a, **_kw: next(prompts))
642+
monkeypatch.setattr(setup_mod, "prompt_yes_no", lambda *_a, **_kw: False)
643+
monkeypatch.setattr(setup_mod, "_write_slack_manifest_and_instruct", lambda: None)
644+
645+
setup_mod._setup_slack()
646+
647+
assert "SLACK_HOME_CHANNEL" not in saved

0 commit comments

Comments
 (0)