From f44ee37ed6697303f4f7623e598e8105c2258c7a Mon Sep 17 00:00:00 2001 From: chihumyum Date: Sat, 24 Oct 2026 02:23:42 +0800 Subject: [PATCH] fix(desktop): keep connection detail sibling keys distinct Opening any connection's detail logged "Encountered two children with the same key": ConnectionDefaultAction (keyed per connection in #5866 so its state resets when the selection changes) and ConnectionDetail both used the connection id as their key under the same level. Prefix the default action's key so both still remount per connection without colliding, and cover it in the providers-panel render test. Generated-by: Claude Code --- .../connection-settings-locale-render.test.ts | 16 ++++++++++++++++ .../src/renderer/settings/providers-panel.tsx | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src/main/__tests__/connection-settings-locale-render.test.ts b/apps/desktop/src/main/__tests__/connection-settings-locale-render.test.ts index 370684c4c04..630713a79b6 100644 --- a/apps/desktop/src/main/__tests__/connection-settings-locale-render.test.ts +++ b/apps/desktop/src/main/__tests__/connection-settings-locale-render.test.ts @@ -559,6 +559,22 @@ function deferred() { return { promise, resolve: resolvePromise, reject: rejectPromise }; } +test('connection detail keys its default action apart from the detail it sits beside', async (context) => { + const errorLog = context.mock.method(console, 'error', () => undefined); + const harness = installRenderer(); + const connection = relayConnection(); + const bridge = connectionDetailBridge({ + hasSecret: async () => true, + getSnapshot: async () => ({ connections: [connection], defaultConnection: 'relay-a', chatModelChoices: [] }), + }); + await harness.render('zh-CN', providersPanel(bridge, connection.slug)); + assert.ok(harness.document.querySelector('[data-maka-contract="connection-detail"]')); + const duplicateKeys = errorLog.mock.calls + .map((call) => call.arguments.map(String).join(' ')) + .filter((message) => message.includes('same key')); + assert.deepEqual(duplicateKeys, []); +}); + test('setting a default with one enabled model commits directly', async () => { const harness = installRenderer(); const connection = { ...relayConnection(), defaultModel: '' }; diff --git a/apps/desktop/src/renderer/settings/providers-panel.tsx b/apps/desktop/src/renderer/settings/providers-panel.tsx index fbd0e841dbf..9441ed464b8 100644 --- a/apps/desktop/src/renderer/settings/providers-panel.tsx +++ b/apps/desktop/src/renderer/settings/providers-panel.tsx @@ -358,7 +358,9 @@ function ProvidersPanelContent({ bridge, apiKeyOnboardingBridge, initialPage = ' // swaps", and it draws no ring. ( { await reload(); }}