You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by zh...@apache.org on 2026/10/19 06:33:09 UTC

(maka) branch codex/fix-model-selection-draft updated: fix(desktop): test the saved model selection

This is an automated email from the ASF dual-hosted git repository.

me2seeks pushed a commit to branch codex/fix-model-selection-draft
in repository https://gitbox.apache.org/repos/asf/maka.git


The following commit(s) were added to refs/heads/codex/fix-model-selection-draft by this push:
     new 916a2f8fec fix(desktop): test the saved model selection
916a2f8fec is described below

commit 916a2f8feca1e762fe3591a5cdff99a713a1af08
Author: me2seeks <me...@gmail.com>
AuthorDate: Mon Oct 19 14:33:00 2026 +0800

    fix(desktop): test the saved model selection
    
    Compare connection-test results with persisted model choices while an unsaved selection draft is visible. Add a regression that fails when the successful saved model is incorrectly reported as a fallback.
    
    Generated-by: Codex
---
 .../connection-settings-locale-render.test.ts      | 22 +++++++++++++++++++++-
 .../src/renderer/settings/use-connection-detail.ts |  9 ++++++---
 2 files changed, 27 insertions(+), 4 deletions(-)

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 85c7b35fb0..9f481d14a8 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
@@ -40,6 +40,7 @@ interface DetailController {
   enabledModelIds: string[];
   hasEnabledModelChanges: boolean;
   savingEnabledModels: boolean;
+  runTest(): Promise<void>;
   updateEnabledModels(id: string): void;
   saveEnabledModels(): Promise<boolean>;
   cancelEnabledModels(): void;
@@ -687,11 +688,12 @@ async function clickText(container: ParentNode, label: string) {
 async function modelDraftHarness(options: {
   update: ConnectionsBridge['update'];
   onChanged?: () => Promise<void>;
+  testConnection?: ConnectionsBridge['test'];
 }) {
   const renderer = installRenderer();
   let connection = relayConnection();
   let controller!: DetailController;
-  const bridge = connectionDetailBridge({ hasSecret: async () => true, update: options.update });
+  const bridge = connectionDetailBridge({ hasSecret: async () => true, update: options.update, ...(options.testConnection ? { test: options.testConnection } : {}) });
   function Probe() {
     controller = components.useConnectionDetail({
       bridge, connection, isDefault: true,
@@ -704,6 +706,7 @@ async function modelDraftHarness(options: {
   }));
   await render();
   return {
+    document: renderer.document,
     get controller() { return controller; },
     async refresh(next: ProjectedLlmConnection) { connection = next; await render(); },
   };
@@ -792,6 +795,23 @@ test('toggling a model back restores the clean selection and a connection switch
   assert.equal(harness.controller.hasEnabledModelChanges, false);
 });
 
+test('testing a connection uses the saved selection when a different model is only drafted', async () => {
+  const original = relayConnection();
+  const harness = await modelDraftHarness({
+    update: unexpectedCall,
+    testConnection: async () => ({ ok: true, modelTested: original.defaultModel, latencyMs: 5 }),
+  });
+  await act(async () => {
+    harness.controller.updateEnabledModels(original.defaultModel);
+    harness.controller.updateEnabledModels('unsaved-model');
+  });
+  await act(async () => { await harness.controller.runTest(); });
+  assert.ok(harness.document.body.textContent.includes(`Connected · ${original.name}`));
+  assert.ok(!harness.document.body.textContent.includes(`Connection works · ${original.name}`));
+  assert.deepEqual(harness.controller.enabledModelIds, ['unsaved-model']);
+  assert.equal(harness.controller.hasEnabledModelChanges, true);
+});
+
 test('adding a custom model preserves an existing selection draft without persisting it', async () => {
   const original = relayConnection();
   const confirmed = { ...original, enabledModelIds: [original.defaultModel, 'custom-model'] };
diff --git a/apps/desktop/src/renderer/settings/use-connection-detail.ts b/apps/desktop/src/renderer/settings/use-connection-detail.ts
index 56dc27efce..7c466fac5e 100644
--- a/apps/desktop/src/renderer/settings/use-connection-detail.ts
+++ b/apps/desktop/src/renderer/settings/use-connection-detail.ts
@@ -535,6 +535,9 @@ export function useConnectionDetail(props: ConnectionDetailProps) {
     const releaseTest = connectionDetailActionGuard.beginExclusive('test');
     if (!releaseTest) return;
     const lifecycle = connectionDetailLifecycleRef.current;
+    // The Host tests persisted configuration, not the selection still being edited.
+    const savedSelection = enabledModelsDraft?.connectionId === connection.connectionId
+      ? enabledModelsDraft.saved : connectionEnabledModelIds(connection);
     setTesting(true);
     try {
       // No model argument: `resolveConnectionTestModel` already picks one from
@@ -563,12 +566,12 @@ export function useConnectionDetail(props: ConnectionDetailProps) {
         // string for `modelLabel(testedId)` below.
         if (
           testedId !== undefined &&
-          enabledModelIds.length > 0 &&
-          !enabledModelIds.includes(testedId)
+          savedSelection.length > 0 &&
+          !savedSelection.includes(testedId)
         ) {
           toast.warning(
             copy.connectionFallbackTitle(connection.name),
-            copy.connectionFallbackDetail(enabledModelIds.map(modelLabel), modelLabel(testedId)),
+            copy.connectionFallbackDetail(savedSelection.map(modelLabel), modelLabel(testedId)),
           );
         } else {
           toast.success(


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org