fix(bot-mode): accept both host.connections() shapes in the Create-on picker normalize

The SDK now returns the registry rows per its documented contract
(salvaged #89893), while desktops predating the SDK unwrap resolve the
raw registry envelope. The plugin normalize accepts both, so the picker
works across the transition; regression test updated to pin the
dual-shape normalize.
This commit is contained in:
Teknium
2026-08-19 15:14:01 -07:00
parent a46fe01251
commit 271e49a8ff
3 changed files with 13 additions and 11 deletions
@@ -6189,7 +6189,10 @@ function CreateAgentDialog({ open, onClose, roster }) {
host
.connections()
.then(value => setConnections(Array.isArray(value?.connections) ? value.connections : []))
// host.connections() returns the registry ROWS on current SDKs, but the
// envelope object ({version, primary, connections: [...]}) on desktops
// that predate the SDK-side unwrap — accept both shapes.
.then(value => setConnections(Array.isArray(value) ? value : Array.isArray(value?.connections) ? value.connections : []))
.catch(() => setConnections([]))
}, [open, connections])
@@ -163,17 +163,15 @@ test('source contract: group chat turns route through requestForBot on the membe
assert.match(pluginSource, /members: Array\.isArray\(room\.members\) \? room\.members : \[\]/)
})
test('regression: host.connections() registry object is unwrapped before the picker gate', () => {
// host.connections() resolves the IPC handler hermes:connections:list, which
// returns the registry OBJECT ({version, primary, connections: [...]}) — not
// a bare array. The picker gate (Array.isArray(connections) && length > 1)
// never fired, so the "Create on" picker stayed hidden on multi-connection
// desktops. The plugin must unwrap .connections before storing.
test('regression: host.connections() result is normalized for BOTH SDK shapes before the picker gate', () => {
// Current SDKs return the registry ROWS from host.connections() (the
// documented contract); desktops that predate the SDK-side unwrap resolve
// the raw IPC payload — the registry OBJECT ({version, primary,
// connections: [...]}). The picker gate (Array.isArray(connections) &&
// length > 1) needs rows either way, so the plugin must accept both
// shapes. Pinning one shape only reopens #89823 on the other.
assert.match(
pluginSource,
/setConnections\(Array\.isArray\(value\?\.connections\) \? value\.connections : \[\]\)/
/setConnections\(Array\.isArray\(value\) \? value : Array\.isArray\(value\?\.connections\) \? value\.connections : \[\]\)/
)
// The built-in Connections UI consumes the registry object, so the IPC
// handler contract must NOT change to a bare array.
assert.doesNotMatch(pluginSource, /setConnections\(Array\.isArray\(value\) \? value : \[\]\)/)
})
+1
View File
@@ -0,0 +1 @@
huklaa