Skip to content

AI-powered virtual executive team — a single coherent executive persona backed by 8 specialist agents (FastAPI + Next.js).

fix(people): point roster emails at Home and name who a reply is about (#366)

Rufus8c15b9d8b737
diff --git a/packages/core/openexecutive/integrations/roster_intake.py b/packages/core/openexecutive/integrations/roster_intake.py
index ad816e31..c8d430b1 100644
--- a/packages/core/openexecutive/integrations/roster_intake.py
+++ b/packages/core/openexecutive/integrations/roster_intake.py
@@ -252,15 +252,20 @@ def _chat_prompt(request: rr.RosterRequest, acknowledged: bool = True) -> str:
"they said.\n"
f"Tell me who {who} is and I'll add them — for example \"that's Annamarie, "
"add her to the team\", \"add them as a contact\", \"that's <someone already "
- "on the People list>\", or \"ignore\". The card on your Today page works too."
+ "on the People list>\", or \"ignore\". The card on your Home page works too."
)
+def _subject_who(request: rr.RosterRequest) -> str:
+ """Who a request is about, safe for a Subject line: the name comes from the
+ unknown sender, so line breaks are collapsed and its length capped."""
+ return " ".join((request.display_name or request.channel_ref).split())[:80]
+
+
def _email_prompt(
request: rr.RosterRequest, token: str, acknowledged: bool = True,
) -> tuple[str, str]:
- subject_who = request.display_name or request.channel_ref
- subject = f"Who is {subject_who}? [{token}]"
+ subject = f"Who is {_subject_who(request)}? [{token}]"
body = (
f"{rr.describe(request)}.\n\n"
f"{_told(acknowledged)}. I haven't replied to what they said.\n\n"
@@ -270,7 +275,7 @@ def _email_prompt(
" - \"Add them as a contact\"\n"
" - \"That's <someone already on the People list>\"\n"
" - \"Ignore\"\n\n"
- "Or use the card on your Today page.\n\n"
+ "Or use the card on your Home page.\n\n"
f"(Reference {token} — keep it in your reply. It works once.)"
)
return subject, body
@@ -660,7 +665,7 @@ async def _apply_answer(request: rr.RosterRequest, text: str, *, via: str) -> st
if ambiguous:
return (
f"More than one person on your People list is called {name}, so "
- "they're still waiting. Use the full name, or the card on your Today page."
+ "they're still waiting. Use the full name, or the card on your Home page."
)
if person is not None and person.id is not None:
await answer(request.id, "link", via=via, link_person_id=person.id)
@@ -668,7 +673,7 @@ async def _apply_answer(request: rr.RosterRequest, text: str, *, via: str) -> st
if decision == "link":
return (
f"I couldn't find {name or 'that person'} on your People list, so "
- "they're still waiting. Use their full name, or the card on your Today page."
+ "they're still waiting. Use their full name, or the card on your Home page."
)
full_name = name or request.display_name
if not full_name:
@@ -690,7 +695,7 @@ async def _reply_to_principal(gateway: Any, to: str, request: rr.RosterRequest,
try:
with set_session(None):
await send_from_executive(
- gateway, to=to, subject=f"Re: roster request {request.id}", body=text,
+ gateway, to=to, subject=f"Re: Who is {_subject_who(request)}?", body=text,
)
except Exception:
logger.warning("roster_intake: replying to the principal failed", exc_info=True)
diff --git a/packages/core/tests/unit/test_roster_intake.py b/packages/core/tests/unit/test_roster_intake.py
index 77f4020d..e10ee855 100644
--- a/packages/core/tests/unit/test_roster_intake.py
+++ b/packages/core/tests/unit/test_roster_intake.py
@@ -433,6 +433,16 @@ def test_the_principal_adds_them_by_email(pending: tuple[rr.RosterRequest, str])
# The parser reads the principal's own words, not the quoted request.
assert seen == ["That's Annamarie Chen, add her"]
assert sent.await_args.args[1]["arguments"]["to"] == OWNER
+ # The confirmation names who it is about, not an internal record number.
+ assert sent.await_args.args[1]["arguments"]["subject"] == f"Re: Who is {req.display_name}?"
+
+
+def test_the_subject_names_who_safely_even_without_a_display_name() -> None:
+ no_name = SimpleNamespace(display_name="", channel_ref="[email protected]")
+ assert roster_intake._subject_who(no_name) == "[email protected]" # type: ignore[arg-type]
+ hostile = SimpleNamespace(display_name="Bob\r\nBcc: [email protected]" + "y" * 200, channel_ref="r")
+ who = roster_intake._subject_who(hostile) # type: ignore[arg-type]
+ assert "\r" not in who and "\n" not in who and len(who) == 80
def test_this_is_someone_on_the_list_links_them(pending: tuple[rr.RosterRequest, str], roster: SimpleNamespace) -> None: