fix(cli): harden hermes portal SystemExit handling + finish model-pick doc sweep
Self-review of #38465 surfaced three real items: 1. SystemExit escape (defense): `_login_nous` raises SystemExit(130)/(1) on cancel/failure. The logged-out login path inside `_model_flow_nous` catches it, but the expired-session re-login path (main.py) only catches Exception, so a Ctrl-C during re-auth could propagate past `_run_portal_one_shot` and kill the CLI. Add SystemExit to the portal handler so all cancel/abort cases end with the graceful 'Setup cancelled / retry later' message. 2. Doc sweep: the model-pick step was only added to the bare-`hermes portal` prose. Propagate it to the surfaces describing `hermes setup --portal` behavior that still omitted model selection: - `--portal` argparse help (main.py) - nous-portal.md intro + the numbered 'what it does' step list (EN + zh-Hans) - run-hermes-with-nous-portal.md 'default model after setup --portal' line, which was now contradictory (there's a picker, not a forced default) (EN + zh) 3. Test coverage: add parametrized regression test asserting the portal handler swallows KeyboardInterrupt / EOFError / SystemExit (returns None, no escape). Note on 'Skip (keep current)': delegating to _model_flow_nous means picking Skip preserves the prior provider instead of force-switching to nous — this is intentional and matches quick setup exactly; docs now say 'sets Nous as your provider (when you pick a model)' rather than unconditionally.
This commit is contained in:
+6
-1
@@ -2770,7 +2770,12 @@ def _run_portal_one_shot(config: dict) -> None:
|
||||
from hermes_cli.main import _model_flow_nous
|
||||
|
||||
_model_flow_nous(config)
|
||||
except (KeyboardInterrupt, EOFError):
|
||||
except (KeyboardInterrupt, EOFError, SystemExit):
|
||||
# _login_nous raises SystemExit(130)/(1) on cancel/failure; the
|
||||
# logged-out path inside _model_flow_nous catches it, but the
|
||||
# expired-session re-login path only catches Exception, so a
|
||||
# SystemExit there would otherwise escape and kill the whole CLI.
|
||||
# Treat all of these as a graceful cancel/abort for the portal flow.
|
||||
print()
|
||||
print_info(" Setup cancelled.")
|
||||
print_info(" You can retry later with `hermes portal`.")
|
||||
|
||||
Reference in New Issue
Block a user