From a1b510650da421acdc0fe75302f56b5d8278eb91 Mon Sep 17 00:00:00 2001 From: sh-agents <350651734+sh-agents@users.noreply.github.com> Date: Thu, 12 Nov 2026 14:29:59 +0000 Subject: [PATCH] support bot light: show contact ids in /list --- apps/simplex-support-bot-light/README.md | 11 +++++----- .../src/support_bot_light/messages.py | 2 +- .../tests/test_boundaries.py | 2 +- .../tests/test_messages.py | 22 +++++++++++-------- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/apps/simplex-support-bot-light/README.md b/apps/simplex-support-bot-light/README.md index 7ae165662c..f339c14881 100644 --- a/apps/simplex-support-bot-light/README.md +++ b/apps/simplex-support-bot-light/README.md @@ -106,7 +106,7 @@ Available in the roster group. | Command | Effect | | --- | --- | | `/dm` | Join the roster. If the bot has no direct contact, it sends a contact request first; membership becomes active once that request is accepted. | -| `/list` | List active members, members who are no longer reachable, and those pending a contact request. | +| `/list` | List active members, members who are no longer reachable, and those pending a contact request, each as `ID:name`. | | `/leave` | Leave the roster. Chats already joined are unaffected. | | `/help` | Summarise the above. | | `/feed ` | Send a message to every chat. Only for `roster.broadcasters`. | @@ -128,10 +128,11 @@ installation sets `SIMPLEX_LIBS_DIR` to the output of `scripts/desktop/build-lib-linux.sh`, in `apps/multiplatform/common/src/commonMain/cpp/desktop/libs/linux-$(uname -m)`. -`roster.broadcasters` lists `"ID:name"` strings, such as `["12:Alice", "15:Bob"]`. -A broadcaster must be a contact of the bot; `/feed` from anyone else replies -with their contact id, or asks them to run `/dm` when they have no contact. The -bot exits at start if an id is not a contact or its display name differs. +`roster.broadcasters` lists `"ID:name"` strings, such as `["12:Alice", "15:Bob"]`; +`/list` shows the ID of each roster member. A broadcaster must be a contact of +the bot; `/feed` from anyone else replies with their contact id, or asks them to +run `/dm` when they have no contact. The bot exits at start if an id is not a +contact or its display name differs. ## State diff --git a/apps/simplex-support-bot-light/src/support_bot_light/messages.py b/apps/simplex-support-bot-light/src/support_bot_light/messages.py index cc58638841..17ee7d668f 100644 --- a/apps/simplex-support-bot-light/src/support_bot_light/messages.py +++ b/apps/simplex-support-bot-light/src/support_bot_light/messages.py @@ -73,7 +73,7 @@ def _section(title: str, label: str, entries: Sequence[RosterEntry]) -> list[str rather than silently dropped. """ lines = [f"{title} ({len(entries)}):"] - lines += [f" • {e.name}{_since(label, e.since)}" for e in entries[:MAX_LISTED]] + lines += [f" • {e.contact_id}:{e.name}{_since(label, e.since)}" for e in entries[:MAX_LISTED]] if len(entries) > MAX_LISTED: lines.append(f" … and {len(entries) - MAX_LISTED} more") return lines diff --git a/apps/simplex-support-bot-light/tests/test_boundaries.py b/apps/simplex-support-bot-light/tests/test_boundaries.py index 4d28326c2a..7c3e0f2345 100644 --- a/apps/simplex-support-bot-light/tests/test_boundaries.py +++ b/apps/simplex-support-bot-light/tests/test_boundaries.py @@ -59,7 +59,7 @@ def test_list_shows_forty_before_it_summarises(): def test_a_reply_at_the_byte_cap_is_not_truncated(): - room = messages.MAX_REPLY_BYTES - len("On the roster (1):\n • ") - len(" — since 2026-08-13") + room = messages.MAX_REPLY_BYTES - len("On the roster (1):\n • 1:") - len(" — since 2026-08-13") assert messages.render_roster([entry("a" * min(room, text.MAX_NAME))]).endswith("2026-08-13") over = [entry("漢" * text.MAX_NAME) for _ in range(messages.MAX_LISTED)] diff --git a/apps/simplex-support-bot-light/tests/test_messages.py b/apps/simplex-support-bot-light/tests/test_messages.py index 1342befb78..9443acfd9b 100644 --- a/apps/simplex-support-bot-light/tests/test_messages.py +++ b/apps/simplex-support-bot-light/tests/test_messages.py @@ -2,16 +2,20 @@ from support_bot_light import messages from support_bot_light.roster import RosterEntry -def entry(name, state, since="2026-08-13T09:00:00+00:00", reachable=True): - return RosterEntry(contact_id=1, name=name, state=state, since=since, reachable=reachable) +def entry(name, state, since="2026-08-13T09:00:00+00:00", reachable=True, contact_id=1): + return RosterEntry( + contact_id=contact_id, name=name, state=state, since=since, reachable=reachable + ) -def test_render_roster_lists_active_and_pending(): - out = messages.render_roster([entry("sh", "active"), entry("Alex", "pending")]) +def test_render_roster_lists_active_and_pending_with_contact_ids(): + out = messages.render_roster( + [entry("sh", "active", contact_id=142682), entry("Alex", "pending", contact_id=7)] + ) assert "On the roster (1):" in out - assert "• sh — since 2026-08-13" in out + assert "• 142682:sh — since 2026-08-13" in out assert "Contact request not accepted (1):" in out - assert "• Alex — asked 2026-08-13" in out + assert "• 7:Alex — asked 2026-08-13" in out def test_render_roster_empty(): @@ -25,13 +29,13 @@ def test_render_roster_omits_pending_section_when_none(): def test_render_roster_omits_date_suffix_when_since_is_empty(): out = messages.render_roster([entry("sh", "active", since="")]) - assert out == "On the roster (1):\n • sh" + assert out == "On the roster (1):\n • 1:sh" assert "since" not in out def test_render_roster_formats_date_suffix(): out = messages.render_roster([entry("sh", "active")]) - assert out == "On the roster (1):\n • sh — since 2026-08-13" + assert out == "On the roster (1):\n • 1:sh — since 2026-08-13" def test_invite_log_lists_added_names(): @@ -56,7 +60,7 @@ def test_render_roster_separates_unreachable_members(): ) assert "On the roster (1):" in out assert "Not reachable, not being added (1):" in out - assert "• dead" in out + assert "• 1:dead" in out def test_render_roster_caps_long_sections():