Skip to content

The agent that grows with you

fix(desktop): New Group Chat offers only the bots groups.create will seat

Tekniumad5d16236bd4
diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-group-capabilities.ts b/apps/desktop/src/plugins/hermes-bots/canonical-group-capabilities.ts
index 5541e662b6c..b79b93ceaeb 100644
--- a/apps/desktop/src/plugins/hermes-bots/canonical-group-capabilities.ts
+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-capabilities.ts
@@ -31,6 +31,20 @@ export function groupExecutionMode(value: unknown): GroupExecutionMode {
return 'unavailable'
}
+/** The profiles `groups.create` will seat for THIS caller, as `groups.capabilities`
+ * reports them (the server's member rules: parked, retiring and unaddressable bots
+ * are out, and only a host-scoped socket seats served siblings). Null when the
+ * gateway predates the field, so callers keep their connection-only filter. */
+export function groupSeatableProfiles(value: unknown): null | Set<string> {
+ const seatable = value && typeof value === 'object' ? (value as Record<string, unknown>).seatable_profiles : undefined
+
+ if (!Array.isArray(seatable)) {
+ return null
+ }
+
+ return new Set(seatable.filter((name): name is string => typeof name === 'string'))
+}
+
/** Fence a group-creation flow to the source that approved it. Pass the epoch the
* capability was read under (default: now); the predicate turns false once the
* connection, profile, socket or activation epoch moves, so a late result is
diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-group-capability-gates.test.tsx b/apps/desktop/src/plugins/hermes-bots/canonical-group-capability-gates.test.tsx
index 6c804b7dbb4..7edb6351ae5 100644
--- a/apps/desktop/src/plugins/hermes-bots/canonical-group-capability-gates.test.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-capability-gates.test.tsx
@@ -221,6 +221,21 @@ it('canonical creation offers only members on the current connection before subm
expect(baseElement.querySelector('[data-bot-face="spoofed"]')).toBeNull()
})
+it('canonical creation offers only the bots the authority says this caller can seat (#141178)', async () => {
+ // `parked` is on this connection but not served (or a sibling this socket may
+ // not seat): groups.create would refuse it, so the picker must not offer it.
+ const withParked: RosterRow[] = [...roster, { name: 'parked', connectionId: 'local' }]
+ answer({ driver: true, persistent_process: true, seatable_profiles: ['alpha', 'beta', 'default'] })
+ const { baseElement } = render(<CreateGroupChatDialog onClose={vi.fn()} open roster={withParked} />)
+
+ await waitFor(() => {
+ expect(baseElement.querySelector('[data-bot-face="alpha"]')).not.toBeNull()
+ expect(baseElement.querySelector('[data-bot-face="beta"]')).not.toBeNull()
+ })
+ expect(baseElement.querySelector('[data-bot-face="parked"]')).toBeNull()
+ expect(screen.getAllByRole('checkbox')).toHaveLength(2)
+})
+
it('rechecks the current mode before creating after a mixed legacy selection', async () => {
let capabilityReads = 0
const onCreated = vi.fn()
diff --git a/apps/desktop/src/plugins/hermes-bots/create-dialog.tsx b/apps/desktop/src/plugins/hermes-bots/create-dialog.tsx
index 6b8964c4923..e2ea5bbb320 100644
--- a/apps/desktop/src/plugins/hermes-bots/create-dialog.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/create-dialog.tsx
@@ -45,7 +45,7 @@ import { isBackfilledFacePng } from './avatar-image'
import { AvatarPicker } from './avatar-picker'
import { $selectedBot } from './bot-state'
import { createCanonicalChat } from './canonical-chat'
-import { groupCreationSource, groupExecutionMode } from './canonical-group-capabilities'
+import { groupCreationSource, groupExecutionMode, groupSeatableProfiles } from './canonical-group-capabilities'
import { registerCanonicalGroup } from './canonical-group-registry'
import type { CanonicalGroupOrigin } from './canonical-group-registry'
import { canonicalGroupRequest, createCanonicalGroup } from './canonical-groups'
@@ -1209,6 +1209,7 @@ interface CreateGroupChatDialogProps {
type GroupCapabilityState = {
activationEpoch: number
mode: ReturnType<typeof groupExecutionMode>
+ seatable: null | Set<string>
source: string
}
@@ -1288,6 +1289,7 @@ export function CreateGroupChatDialog({ open, roster, onClose, onCreated }: Crea
setCapability({
activationEpoch,
mode: groupExecutionMode(result),
+ seatable: groupSeatableProfiles(result),
source
})
}
@@ -1297,6 +1299,7 @@ export function CreateGroupChatDialog({ open, roster, onClose, onCreated }: Crea
setCapability({
activationEpoch,
mode: 'unavailable',
+ seatable: null,
source
})
}
@@ -1306,6 +1309,7 @@ export function CreateGroupChatDialog({ open, roster, onClose, onCreated }: Crea
}, [activationEpoch, connectionId, gateway, open, profile, source])
const mode = capability?.source === source ? capability.mode : 'checking'
+ const seatable = capability?.source === source ? capability.seatable : null
const currentConnection = String(connectionId || '').trim()
@@ -1329,7 +1333,15 @@ export function CreateGroupChatDialog({ open, roster, onClose, onCreated }: Crea
return false
}
- return mode === 'legacy' || belongsToCurrentConnection(bot)
+ if (mode === 'legacy') {
+ return true
+ }
+
+ // Canonical: the authority's own seatable roster wins over connection
+ // membership, so a parked or unseatable bot is never offered (#141178).
+ // The profile is the one createCanonicalGroup will send.
+ return belongsToCurrentConnection(bot) &&
+ (!seatable || seatable.has(bot.route?.targetProfile ?? bot.targetProfile ?? bot.name))
})
const selected = selectableRoster.filter(bot => checked[botRosterKey(bot)])
diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.ts
index 5a3f082e551..3e678bed20e 100644
--- a/apps/shared/src/gateway-contract.generated.ts
+++ b/apps/shared/src/gateway-contract.generated.ts
@@ -1466,6 +1466,7 @@ export interface GroupsCapabilitiesResult {
features: string[]
methods: string[]
max_log_limit: number
+ seatable_profiles?: string[] | null
}
/** ``enabled`` with ``profile``/``catalog``/``endpoint``, or disabled with a ``reason``. */
export interface RoomLinkStatus {
diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.json
index bea828a5c28..d5fd22f4ad0 100644
--- a/apps/shared/src/gateway-contract.openrpc.json
+++ b/apps/shared/src/gateway-contract.openrpc.json
@@ -19236,6 +19236,21 @@
"max_log_limit": {
"title": "Max Log Limit",
"type": "integer"
+ },
+ "seatable_profiles": {
+ "anyOf": [
+ {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Seatable Profiles"
}
},
"required": [
diff --git a/gateway/session_group_controls.py b/gateway/session_group_controls.py
index 5b4e87caf3b..0f0b80d2082 100644
--- a/gateway/session_group_controls.py
+++ b/gateway/session_group_controls.py
@@ -124,11 +124,16 @@ def _group(authority, actor, method, params, *, host_scope=False):
return _execution_control(service, method, params)
def capabilities():
+ from gateway.session_hosted_members import member_roster
+ # The roster groups.create will accept from THIS caller, so a picker never offers a bot
+ # (parked, retiring, a sibling a profile-bound socket cannot seat) that create refuses.
+ homes, refused = member_roster(authority, siblings=host_scope)
return {'protocol_version': rooms.PROTOCOL_VERSION, 'driver': service is not None,
'persistent_process': True, 'authority_gateway_id': gateway_id,
'room_link': {'enabled': False, 'reason': 'canonical_driver_required'},
'features': ['room_identity', 'monotonic_log', 'replayable_disband'],
- 'methods': list(GROUP_METHODS), 'max_log_limit': rooms.MAX_LOG_LIMIT}
+ 'methods': list(GROUP_METHODS), 'max_log_limit': rooms.MAX_LOG_LIMIT,
+ 'seatable_profiles': sorted(name for name in homes if name not in refused)}
def listing():
limit, offset = params.get('limit', rooms.MAX_ROOM_LIST_LIMIT), params.get('offset', 0)
diff --git a/tests/gateway/test_hosted_group_members.py b/tests/gateway/test_hosted_group_members.py
index 7e154dcd5ae..c01f03b3b16 100644
--- a/tests/gateway/test_hosted_group_members.py
+++ b/tests/gateway/test_hosted_group_members.py
@@ -326,3 +326,21 @@ def test_a_linked_profile_is_refused_by_name_until_groups_support_it(tmp_path, m
# Its home never answers to another name: default still seats the rest.
seated = desktop('default', 'groups.create', room_id='crew', name='Crew', members=_members('default', 'alpha'))
assert 'result' in seated, seated
+
+
+def test_capabilities_name_exactly_the_profiles_this_caller_can_seat(tmp_path, monkeypatch):
+ """#141178: the New Group Chat picker offered every bot on the connection, and groups.create
+ then refused the ones the caller cannot seat. groups.capabilities now names that roster, and
+ each name it lists is one create accepts."""
+ with _gateway(tmp_path, monkeypatch, served=('alpha', 'beta'), unserved=('gamma',)) as (runner, homes, call):
+ host = _desktop(runner, call)
+ assert host('default', 'groups.capabilities')['result']['seatable_profiles'] == ['alpha', 'beta', 'default']
+ # A profile-bound socket seats only its own profile (plus its entries), as create rules.
+ bound = _desktop(runner, call, scope='profile')
+ assert bound('default', 'groups.capabilities')['result']['seatable_profiles'] == ['default']
+ # A sibling being torn down runs nothing, so it drops out before create would refuse it.
+ runner.session_authorities.require(homes['beta']).retiring = True
+ seatable = host('default', 'groups.capabilities')['result']['seatable_profiles']
+ assert seatable == ['alpha', 'default']
+ created = host('default', 'groups.create', room_id='crew', name='Crew', members=_members(*seatable))
+ assert 'result' in created, created
diff --git a/tui_gateway/contracts/groups_bot_relay.py b/tui_gateway/contracts/groups_bot_relay.py
index 1f9923b564f..be9aa07d2fb 100644
--- a/tui_gateway/contracts/groups_bot_relay.py
+++ b/tui_gateway/contracts/groups_bot_relay.py
@@ -154,6 +154,10 @@ class GroupsCapabilitiesResult(Result):
features: list[str]
methods: list[str]
max_log_limit: int
+ #: Local profiles THIS caller may seat in a new group (``gateway/session_hosted_members``): served
+ #: bots, minus retiring/unaddressable ones, plus usable ``hosted_rooms.profiles`` entries; only a
+ #: host-scoped caller gets served siblings. Absent on gateways that predate it.
+ seatable_profiles: list[str] | None = None
method("groups.capabilities", params=GroupsCapabilitiesParams, result=GroupsCapabilitiesResult,