Skip to content

fix(gateway): persist /sethome home channel to .env across all platforms#16900

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-4c5fa789
Apr 28, 2026
Merged

fix(gateway): persist /sethome home channel to .env across all platforms#16900
teknium1 merged 2 commits into
mainfrom
hermes/hermes-4c5fa789

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

/sethome now persists across gateway restarts on every platform — not just Feishu. Previously it wrote {PLATFORM}_HOME_CHANNEL as a top-level key into config.yaml, but load_gateway_config() only reads home channels from env vars, so the setting was silently dropped on every restart.

Root cause: _handle_set_home_command used a bespoke YAML write path that nothing reads. Since the handler builds the env key from platform_name.upper(), switching it to save_env_value() (which writes .env and updates os.environ atomically) fixes /sethome for every platform at once.

Changes

  • gateway/run.py: replace YAML write with save_env_value(env_key, chat_id)
  • hermes_cli/config.py: widen _EXTRA_ENV_KEYS so every platform's HOME_CHANNEL + HOME_CHANNEL_NAME is treated as a managed env var (SIGNAL, SLACK, SMS, DINGTALK, BLUEBUBBLES, FEISHU, WECOM, YUANBAO, plus missing *_NAME variants for DISCORD/TELEGRAM/MATTERMOST)
  • scripts/release.py: AUTHOR_MAP entry for @ztexydt-cqh

Validation

Before After
/sethome on Feishu lost on restart persists via .env
/sethome on Slack/SMS/Dingtalk/etc. lost on restart persists via .env
Managed-env parity Feishu, Slack, SMS, etc. not in _EXTRA_ENV_KEYS all platforms covered

E2E: wrote FEISHU/SLACK/SMS home channels via save_env_value(), purged os.environ, reloaded from .env, confirmed load_gateway_config() reconstructs HomeChannel(chat_id=...) correctly for each. Targeted tests: 202 passed.

Credit

Cherry-picked from #16870 by @ztexydt-cqh — their gateway/run.py fix was the core insight; authorship preserved. Dropped the Feishu-only config.yaml → env mapping since no other platform offers that path, and widened _EXTRA_ENV_KEYS for cross-platform parity.

Closes #16806

ztexydt-cqh and others added 2 commits April 28, 2026 01:16
_handle_set_home_command wrote FEISHU_HOME_CHANNEL / DISCORD_HOME_CHANNEL /
etc. as top-level keys into config.yaml, but load_gateway_config() only
reads home channels from env vars. After every gateway restart the home
channel was lost — on every platform, not just Feishu.

Fix: switch /sethome to save_env_value(), which atomically writes to
~/.hermes/.env and updates the current process env in one shot. The
handler builds the env key from platform_name.upper(), so one line
change repairs /sethome for every platform that has a HOME_CHANNEL
env var.

Also widen _EXTRA_ENV_KEYS in hermes_cli/config.py so HOME_CHANNEL and
HOME_CHANNEL_NAME for every platform are treated as managed env vars:
SIGNAL, SLACK, SMS, DINGTALK, BLUEBUBBLES, FEISHU, WECOM, YUANBAO, plus
the missing *_NAME variants for DISCORD/TELEGRAM/MATTERMOST.

Closes #16806

Co-authored-by: teknium1 <screenmachine@gmail.com>
@teknium1 teknium1 merged commit c8ef786 into main Apr 28, 2026
10 of 11 checks passed
@teknium1 teknium1 deleted the hermes/hermes-4c5fa789 branch April 28, 2026 08:17
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery area/config Config system, migrations, profiles labels Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feishu /sethome silently fails: home channel not persisted, prompts every startup

3 participants