Skip to content

The agent that grows with you

fix(photon): setup without a phone number ends on saved-not-live, not "complete"

Tekniuma97f13ff3fba
diff --git a/plugins/platforms/photon/cli.py b/plugins/platforms/photon/cli.py
index 8a4fc414373..bc1f76c509d 100644
--- a/plugins/platforms/photon/cli.py
+++ b/plugins/platforms/photon/cli.py
@@ -161,7 +161,7 @@ def _cmd_setup(args: argparse.Namespace) -> int:
# 4. Register the operator's phone number as a Spectrum user (idempotent).
phone = args.phone or _prompt(color("[4/5] Your iMessage phone number (E.164, e.g. +15551234567): ", Colors.CYAN))
agent_number = registered_phone = registered_user_id = None
- routing_live = True
+ routing_live = False # only an opted-in, registered number makes setup "complete"
if not phone:
print(" Skipped user registration (no phone given). Re-run with --phone later.")
else:
@@ -185,6 +185,7 @@ def _cmd_setup(args: argparse.Namespace) -> int:
# service sets once the human texts the assigned line from their phone (the API cannot
# set it). Name the line and wait for the opt-in; a re-run on an opted-in row passes.
if photon_auth.user_opted_in(user):
+ routing_live = True
print(" ✓ number is opted in — routing is live")
elif not agent_number: # nothing to text yet, so a wait could never end in an opt-in
routing_live = False
@@ -230,6 +231,10 @@ def _cmd_setup(args: argparse.Namespace) -> int:
print(" ✓ photon platform enabled in config.yaml")
except Exception as e:
print(f" (could not enable Photon in config: {e})", file=sys.stderr)
+ if not phone: # saved, but nothing can route until a number is registered and opted in
+ print("\n⚠ Photon setup saved, but iMessage routing is NOT live: no phone number is registered.\n"
+ " Finish with: hermes photon setup --phone +15551234567")
+ return 0
if not routing_live: # saved, but not "complete": the gateway cannot reach this number yet
print(f"\n⚠ Photon setup saved, but iMessage routing is NOT live: text {agent_number or 'your assigned line'} "
f"once from {phone}.\n Check with `hermes photon status`; start the gateway once it shows opted in.")
diff --git a/tests/plugins/platforms/photon/test_setup_access.py b/tests/plugins/platforms/photon/test_setup_access.py
index 0286b808a56..28f4051c265 100644
--- a/tests/plugins/platforms/photon/test_setup_access.py
+++ b/tests/plugins/platforms/photon/test_setup_access.py
@@ -205,3 +205,26 @@ def test_opt_in_wait_always_names_a_line_to_text(
assert waited == [dedicated_line]
else:
assert waited == [] and "skipping the opt-in wait" in out and "hermes photon status" in out
+
+
+def test_setup_without_phone_does_not_report_complete(
+ monkeypatch: pytest.MonkeyPatch, capsys,
+) -> None:
+ """No --phone and an empty answer: nothing is registered, so nothing can route."""
+ monkeypatch.setattr(cli.photon_auth, "load_photon_token", lambda: "token")
+ monkeypatch.setattr(cli.photon_auth, "check_photon_token_valid", lambda token: True)
+ monkeypatch.setattr(cli.photon_auth, "load_dashboard_project_id", lambda: "dashboard")
+ monkeypatch.setattr(cli.photon_auth, "load_project_credentials", lambda: ("dashboard", "s"))
+ monkeypatch.setattr(cli.photon_auth, "list_users", lambda pid, secret: [])
+ monkeypatch.setattr(cli.photon_auth, "store_project_credentials", lambda **kwargs: None)
+ monkeypatch.setattr(cli.photon_auth, "get_imessage_line", lambda token, pid: None)
+ monkeypatch.setattr(cli, "_prompt", lambda *a, **k: "")
+
+ rc = cli._cmd_setup(argparse.Namespace(
+ project_name=None, phone=None, first_name=None, last_name=None,
+ email=None, no_browser=True, skip_sidecar_install=True))
+
+ out = capsys.readouterr().out
+ assert rc == 0
+ assert "setup complete" not in out
+ assert "routing is NOT live" in out and "--phone" in out