fix(app): finish custom model saves when the daemon confirms them (#10432)

The daemon already schedules catalog discovery when provider configuration changes. Waiting on a second discovery kept the Add sheet open after the model was saved.

Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
This commit is contained in:
paseo-bot[bot]
2026-11-21 18:33:44 +00:00
committed by GitHub
parent 0c02cfdfb1
commit 2445adecdf
4 changed files with 27 additions and 25 deletions
@@ -1,3 +1,5 @@
import { mkdir, rm, writeFile } from "node:fs/promises";
import { dirname } from "node:path";
import { expect, test } from "../support/fixtures";
import { gotoAppShell, openSettings } from "../support/helpers/app";
import {
@@ -49,8 +51,10 @@ interface ProviderConfigClient {
}): Promise<unknown>;
}
test("adds and removes a custom model while the provider fails", async ({ page }) => {
test("adds and removes a custom model while the provider fails", async ({ page }, testInfo) => {
test.setTimeout(120_000);
const discoveryGate = testInfo.outputPath("hold-provider-discovery");
await mkdir(dirname(discoveryGate), { recursive: true });
const client = await connectDaemonClient<ProviderConfigClient>({
clientIdPrefix: "custom-model-failing-e2e",
});
@@ -60,7 +64,14 @@ test("adds and removes a custom model while the provider fails", async ({ page }
[FAILING_PROVIDER.id]: {
extends: "acp",
label: FAILING_PROVIDER.name,
command: ["node", "-e", "process.exit(1)"],
command: [
"node",
"-e",
'const { existsSync } = require("node:fs");' +
"const exitIfReleased = () => { if (!existsSync(process.argv[1])) process.exit(1); };" +
"exitIfReleased(); setInterval(exitIfReleased, 25);",
discoveryGate,
],
},
},
});
@@ -76,9 +87,15 @@ test("adds and removes a custom model while the provider fails", async ({ page }
await expect(page.getByRole("textbox", { name: "Search models" })).toHaveCount(0);
});
await addCustomModel(page, shortModelId);
await test.step("saving closes the Add sheet while provider discovery is still pending", async () => {
await writeFile(discoveryGate, "");
await addCustomModel(page, shortModelId);
});
await rm(discoveryGate);
await expect(page.getByTestId("provider-error")).toBeVisible({ timeout: 30_000 });
await removeListedCustomModel(page, shortModelId);
} finally {
await rm(discoveryGate, { force: true });
await client
.patchDaemonConfig({ removeProviders: [FAILING_PROVIDER.id] })
.catch(() => undefined);
@@ -19,8 +19,6 @@ export async function addCustomModel(page: Page, id: string): Promise<void> {
.getByRole("button", { name: "Add", exact: true })
.click();
await expect(page.getByRole("button", { name: `Remove ${id}`, exact: true })).toHaveCount(1);
// Config updates before provider refresh finishes and dismisses the add sheet.
// Resizing or interacting with the model list must wait for that save to finish.
await expect(page.getByTestId("add-custom-model-sheet")).toBeHidden();
}
@@ -117,12 +117,7 @@ export function ProviderDetail({
action={installation.action}
/>
{sections.models ? (
<ProviderModels
serverId={serverId}
entry={entry}
discovered={sections.models === "all"}
refresh={refresh}
/>
<ProviderModels serverId={serverId} entry={entry} discovered={sections.models === "all"} />
) : null}
<Troubleshooting
serverId={serverId}
@@ -3,7 +3,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { Text, View } from "react-native";
import { StyleSheet, withUnistyles } from "react-native-unistyles";
import type { AgentModelDefinition, AgentProvider } from "@getpaseo/protocol/agent-types";
import type { AgentModelDefinition } from "@getpaseo/protocol/agent-types";
import type { ProviderProfileModel } from "@getpaseo/protocol/provider-config";
import { compareMatchScores, scoreTextFields } from "@getpaseo/protocol/search/text-match";
import {
@@ -52,13 +52,11 @@ export function ProviderModels({
serverId,
entry,
discovered,
refresh,
}: {
serverId: string;
entry: ProviderEntry;
/** List the models the provider reports, with search. Only a running provider reports them. */
discovered: boolean;
refresh: (providers?: AgentProvider[]) => Promise<void>;
}) {
const { t } = useTranslation();
const provider = entry.provider;
@@ -105,13 +103,11 @@ export function ProviderModels({
additionalModels: additionalModels.filter((model) => model.id !== modelId),
},
},
})
.then(() => refresh([provider]))
.finally(() => {
setDeletingModelId((current) => (current === modelId ? null : current));
});
}).finally(() => {
setDeletingModelId((current) => (current === modelId ? null : current));
});
},
[additionalModels, patchConfig, provider, refresh],
[additionalModels, patchConfig, provider],
);
const customTrailing = useMemo(
@@ -204,7 +200,6 @@ export function ProviderModels({
additionalModels={additionalModels}
visible={addSheetOpen}
onClose={handleCloseAddSheet}
refresh={refresh}
/>
</View>
);
@@ -286,14 +281,12 @@ function AddCustomModelSheet({
additionalModels,
visible,
onClose,
refresh,
}: {
serverId: string;
provider: string;
additionalModels: ProviderProfileModel[];
visible: boolean;
onClose: () => void;
refresh: (providers?: AgentProvider[]) => Promise<void>;
}) {
const { t } = useTranslation();
const { patchConfig } = useDaemonConfig(serverId);
@@ -322,13 +315,12 @@ function AddCustomModelSheet({
},
},
})
.then(() => refresh([provider]))
.then(() => onClose())
.catch((err: unknown) => {
setError(err instanceof Error ? err.message : t("settings.providers.models.failedToSave"));
})
.finally(() => setSaving(false));
}, [additionalModels, canAdd, onClose, patchConfig, provider, refresh, t, trimmed]);
}, [additionalModels, canAdd, onClose, patchConfig, provider, t, trimmed]);
const header = useMemo<SheetHeader>(
() => ({ title: t("settings.providers.models.addCustomTitle") }),