fix(gateway): persist /sethome home channel to .env across all platforms#16900
Merged
Conversation
_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>
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/sethomenow persists across gateway restarts on every platform — not just Feishu. Previously it wrote{PLATFORM}_HOME_CHANNELas a top-level key intoconfig.yaml, butload_gateway_config()only reads home channels from env vars, so the setting was silently dropped on every restart.Root cause:
_handle_set_home_commandused a bespoke YAML write path that nothing reads. Since the handler builds the env key fromplatform_name.upper(), switching it tosave_env_value()(which writes.envand updatesos.environatomically) fixes/sethomefor every platform at once.Changes
gateway/run.py: replace YAML write withsave_env_value(env_key, chat_id)hermes_cli/config.py: widen_EXTRA_ENV_KEYSso every platform'sHOME_CHANNEL+HOME_CHANNEL_NAMEis treated as a managed env var (SIGNAL, SLACK, SMS, DINGTALK, BLUEBUBBLES, FEISHU, WECOM, YUANBAO, plus missing*_NAMEvariants for DISCORD/TELEGRAM/MATTERMOST)scripts/release.py: AUTHOR_MAP entry for @ztexydt-cqhValidation
/sethomeon Feishu.env/sethomeon Slack/SMS/Dingtalk/etc..env_EXTRA_ENV_KEYSE2E: wrote FEISHU/SLACK/SMS home channels via
save_env_value(), purgedos.environ, reloaded from.env, confirmedload_gateway_config()reconstructsHomeChannel(chat_id=...)correctly for each. Targeted tests: 202 passed.Credit
Cherry-picked from #16870 by @ztexydt-cqh — their
gateway/run.pyfix was the core insight; authorship preserved. Dropped the Feishu-onlyconfig.yaml → envmapping since no other platform offers that path, and widened_EXTRA_ENV_KEYSfor cross-platform parity.Closes #16806