Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion apps/web/src/components/settings/ProviderInstanceCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { Button } from "../ui/button";
import { DraftInput } from "../ui/draft-input";
import { SecretSourceInput, type SecretSource } from "./SecretSourceInput";
import { Popover, PopoverPopup, PopoverTrigger } from "../ui/popover";
import { RefreshIcon } from "../ui/refresh-icon";
import { Switch } from "../ui/switch";
import { ManagedControl, ManagedNotice } from "../ManagedPolicy";
import { managedInstanceLocks, useManagedPolicy } from "../../state/managedPolicy";
Expand Down Expand Up @@ -731,6 +732,8 @@ interface ProviderInstanceCardProps {
readonly onRunUpdate?: (() => void) | undefined;
readonly onInstallRecommended?: (() => void) | undefined;
readonly isUpdating?: boolean | undefined;
readonly onRefreshModels?: (() => void) | undefined;
readonly isRefreshingModels?: boolean | undefined;
readonly onAcceptUrlAuth?: ((action: AcpRegistryUrlAuthAction) => void) | undefined;
readonly environmentId?: EnvironmentId | undefined;
readonly secretSources?: ReadonlyArray<SecretSource>;
Expand Down Expand Up @@ -802,6 +805,8 @@ export function ProviderInstanceCard({
onRunUpdate,
onInstallRecommended,
isUpdating = false,
onRefreshModels,
isRefreshingModels = false,
onAcceptUrlAuth,
environmentId,
acpProjects = EMPTY_ACP_PROJECTS,
Expand Down Expand Up @@ -1485,7 +1490,25 @@ export function ProviderInstanceCard({
) : null}

{driverOption !== undefined ? (
<SettingsSection title={gt("Models")}>
<SettingsSection
title={gt("Models")}
headerAction={
onRefreshModels !== undefined ? (
<Button
type="button"
size="xs"
variant="ghost-muted"
className="-me-2"
disabled={!enabled || isRefreshingModels}
aria-busy={isRefreshingModels}
onClick={onRefreshModels}
>
<RefreshIcon refreshing={isRefreshingModels} />
{isRefreshingModels ? <T>Refreshing models</T> : <T>Refresh models</T>}
</Button>
) : undefined
}
>
<div className="px-3 py-3 sm:px-4">
<p className="mb-3 text-xs text-muted-foreground">
<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,21 @@ describe("EnvironmentProviderSettings instance removal", () => {
}),
);
});

it("refreshes models for the selected provider instance", async () => {
await setup();
await setProviders([provider()]);
await using _screen = await render(panel({ targetInstanceId: codexId }));

await userEvent.click(page.getByRole("button", { name: "Refresh models" }));

await vi.waitFor(() =>
expect(state.refresh).toHaveBeenCalledWith({
environmentId,
input: { instanceId: codexId, refreshModels: true },
}),
);
});
});

describe("EnvironmentProviderSettings health check interval", () => {
Expand Down
60 changes: 60 additions & 0 deletions apps/web/src/components/settings/ProviderSettingsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,12 @@ export function EnvironmentProviderSettings({
const [updatingProviderInstanceIds, setUpdatingProviderInstanceIds] = useState<
ReadonlySet<ProviderInstanceId>
>(() => new Set());
const [refreshingModelInstanceIds, setRefreshingModelInstanceIds] = useState<
ReadonlySet<ProviderInstanceId>
>(() => new Set());
const refreshingRef = useRef(false);
const updatingInstanceIdsRef = useRef<Set<ProviderInstanceId>>(new Set());
const refreshingModelInstanceIdsRef = useRef<Set<ProviderInstanceId>>(new Set());

const acceptUrlAuthentication = useStableCallback(
(instanceId: ProviderInstanceId, action: AcpRegistryUrlAuthAction) => {
Expand Down Expand Up @@ -706,6 +710,48 @@ export function EnvironmentProviderSettings({
})();
};

const refreshProviderModels = useStableCallback(async (instanceId: ProviderInstanceId) => {
if (
refreshingModelInstanceIdsRef.current.has(instanceId) ||
!readEnvironmentScope(environmentId, AuthOrchestrationReadScope)
)
return;
refreshingModelInstanceIdsRef.current.add(instanceId);
setRefreshingModelInstanceIds((previous) => new Set(previous).add(instanceId));
const result = await refreshServerProviders({
environmentId,
input: { instanceId, refreshModels: true },
});
if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
const error = squashAtomCommandFailure(result);
console.warn("Failed to refresh provider models", {
operation: "refresh-provider-models",
environmentId,
instanceId,
...safeErrorLogAttributes(error),
});
toastManager.add(
stackedThreadToast({
type: "error",
title: gt("Could not refresh models"),
description:
error instanceof Error
? (errorDisplayMessage(error, resolveNow) ?? error.message)
: gt("The provider model list could not be refreshed."),
}),
);
}
refreshingModelInstanceIdsRef.current.delete(instanceId);
setRefreshingModelInstanceIds((previous) => {
if (!previous.has(instanceId)) {
return previous;
}
const next = new Set(previous);
next.delete(instanceId);
return next;
});
});

const runProviderUpdate = useStableCallback(
async (
candidate: Pick<ProviderSettingsUpdateCandidate, "driver" | "instanceId">,
Expand Down Expand Up @@ -1086,6 +1132,7 @@ export function EnvironmentProviderSettings({
const stableToggleModelFavorite = useStableCallback(toggleModelFavorite);
const actions: ProviderInstanceRowActions = {
acceptUrlAuthentication,
refreshProviderModels,
runProviderUpdate,
updateInstance,
enableInstance,
Expand Down Expand Up @@ -1117,8 +1164,10 @@ export function EnvironmentProviderSettings({
selected={mode === "list" && selectedRow?.instanceId === row.instanceId}
readOnly={readOnly}
canWriteSettings={canWriteSettings}
canRefreshModels={canRefreshProviders}
liveProvider={serverProviders.find((candidate) => candidate.instanceId === row.instanceId)}
isUpdateDispatching={updatingProviderInstanceIds.has(row.instanceId)}
isRefreshingModels={isRefreshingProviders || refreshingModelInstanceIds.has(row.instanceId)}
showProjectOverride={showProjectOverride}
projectOverrideValue={
showProjectOverride
Expand Down Expand Up @@ -1391,6 +1440,7 @@ interface ProviderInstanceRowActions {
instanceId: ProviderInstanceId,
action: AcpRegistryUrlAuthAction,
) => void;
readonly refreshProviderModels: (instanceId: ProviderInstanceId) => Promise<void>;
readonly runProviderUpdate: (
candidate: Pick<ProviderSettingsUpdateCandidate, "driver" | "instanceId">,
targetVersion?: string,
Expand Down Expand Up @@ -1433,8 +1483,10 @@ function ProviderInstanceRow({
selected,
readOnly,
canWriteSettings,
canRefreshModels,
liveProvider,
isUpdateDispatching,
isRefreshingModels,
showProjectOverride,
projectOverrideValue,
projectOverrideEffectiveEnabled,
Expand All @@ -1453,8 +1505,10 @@ function ProviderInstanceRow({
readonly selected: boolean;
readonly readOnly: boolean;
readonly canWriteSettings: boolean;
readonly canRefreshModels: boolean;
readonly liveProvider: ServerProvider | undefined;
readonly isUpdateDispatching: boolean;
readonly isRefreshingModels: boolean;
readonly showProjectOverride: boolean;
readonly projectOverrideValue: boolean | undefined;
readonly projectOverrideEffectiveEnabled: boolean;
Expand Down Expand Up @@ -1511,6 +1565,12 @@ function ProviderInstanceRow({
onAcceptUrlAuth={
readOnly ? undefined : (action) => actions.acceptUrlAuthentication(instanceId, action)
}
onRefreshModels={
mode === "editor" && canRefreshModels
? () => void actions.refreshProviderModels(instanceId)
: undefined
}
isRefreshingModels={isRefreshingModels}
instanceId={instanceId}
instance={instance}
driverOption={driverOption}
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -9025,6 +9025,8 @@
},
", das in diesem Build nicht verfügbar ist. Die Konfiguration bleibt erhalten."
],
"a9b5d2852719fddc": "Modelle werden aktualisiert",
"4811262c294ce7d5": "Modelle aktualisieren",
"b534d4cd528ede39": "Modelleinstellungen und benutzerdefinierte Modelle werden in der ausgewählten Umgebung gespeichert und mit verbundenen Geräten geteilt.",
"caaef21e8722857d": "Schnellmodus",
"a860db2b1bb3aa31": "Kein Reasoning",
Expand Down Expand Up @@ -9136,6 +9138,8 @@
"9cd6647baae39b79": "Aktualisiere den Anbieter und starte die Authentifizierung erneut.",
"34e971a4cd3cfdf3": "Authentifizierung konnte nicht fortgesetzt werden",
"25617239c4886378": "Die Authentifizierungsanfrage ist abgelaufen.",
"254dc4b4151094ef": "Modelle konnten nicht aktualisiert werden",
"114f22c0e3900fad": "Die Modellliste des Anbieters konnte nicht aktualisiert werden.",
"1bc94053b36b3f40": "{provider} konnte nicht aktualisiert werden",
"5b39dc5c8173ee94": "Der Update-Befehl des Anbieters konnte nicht gestartet werden.",
"53e1e3591fc1abc9": "Anbieterinstanz konnte nicht aktualisiert werden",
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9033,6 +9033,8 @@
},
", which is not available in this build. Its configuration is preserved."
],
"a9b5d2852719fddc": "Refreshing models",
"4811262c294ce7d5": "Refresh models",
"b534d4cd528ede39": "Model preferences and custom models are saved on the selected environment and shared across connected devices.",
"caaef21e8722857d": "Fast mode",
"a860db2b1bb3aa31": "No reasoning",
Expand Down Expand Up @@ -9144,6 +9146,8 @@
"9cd6647baae39b79": "Refresh the provider and start the authentication flow again.",
"34e971a4cd3cfdf3": "Could not continue authentication",
"25617239c4886378": "The authentication request expired.",
"254dc4b4151094ef": "Could not refresh models",
"114f22c0e3900fad": "The provider model list could not be refreshed.",
"1bc94053b36b3f40": "Could not update {provider}",
"5b39dc5c8173ee94": "The provider update command could not be started.",
"53e1e3591fc1abc9": "Could not update provider instance",
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/i18n/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -9023,6 +9023,8 @@
},
", que no está disponible en esta compilación. Se conserva su configuración."
],
"a9b5d2852719fddc": "Actualizando modelos",
"4811262c294ce7d5": "Actualizar modelos",
"b534d4cd528ede39": "Las preferencias de modelos y los modelos personalizados se guardan en el entorno seleccionado y se comparten entre los dispositivos conectados.",
"caaef21e8722857d": "Modo rápido",
"a860db2b1bb3aa31": "Sin razonamiento",
Expand Down Expand Up @@ -9134,6 +9136,8 @@
"9cd6647baae39b79": "Actualiza el proveedor y vuelve a iniciar el flujo de autenticación.",
"34e971a4cd3cfdf3": "No se pudo continuar la autenticación",
"25617239c4886378": "La solicitud de autenticación caducó.",
"254dc4b4151094ef": "No se pudieron actualizar los modelos",
"114f22c0e3900fad": "No se pudo actualizar la lista de modelos del proveedor.",
"1bc94053b36b3f40": "No se pudo actualizar {provider}",
"5b39dc5c8173ee94": "No se pudo iniciar el comando de actualización del proveedor.",
"53e1e3591fc1abc9": "No se pudo actualizar la instancia del proveedor",
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/i18n/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -9025,6 +9025,8 @@
},
", qui n’est pas disponible dans cette version. Sa configuration est conservée."
],
"a9b5d2852719fddc": "Actualisation des modèles",
"4811262c294ce7d5": "Actualiser les modèles",
"b534d4cd528ede39": "Les préférences de modèle et les modèles personnalisés sont enregistrés dans l’environnement sélectionné et partagés entre les appareils connectés.",
"caaef21e8722857d": "Mode rapide",
"a860db2b1bb3aa31": "Sans raisonnement",
Expand Down Expand Up @@ -9136,6 +9138,8 @@
"9cd6647baae39b79": "Actualisez le fournisseur et relancez l’authentification.",
"34e971a4cd3cfdf3": "Impossible de continuer l’authentification",
"25617239c4886378": "La demande d’authentification a expiré.",
"254dc4b4151094ef": "Impossible d’actualiser les modèles",
"114f22c0e3900fad": "Impossible d’actualiser la liste des modèles du fournisseur.",
"1bc94053b36b3f40": "Impossible de mettre à jour {provider}",
"5b39dc5c8173ee94": "La commande de mise à jour du fournisseur n’a pas pu démarrer.",
"53e1e3591fc1abc9": "Impossible de mettre à jour l’instance du fournisseur",
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/i18n/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -8980,6 +8980,8 @@
},
" を使用していますが、このビルドでは利用できません。設定は保持されます。"
],
"a9b5d2852719fddc": "モデルを更新中",
"4811262c294ce7d5": "モデルを更新",
"b534d4cd528ede39": "モデルの設定とカスタムモデルは選択した環境に保存され、接続されているデバイス間で共有されます。",
"caaef21e8722857d": "高速モード",
"a860db2b1bb3aa31": "推論なし",
Expand Down Expand Up @@ -9091,6 +9093,8 @@
"9cd6647baae39b79": "プロバイダーを更新して、認証フローをもう一度開始してください。",
"34e971a4cd3cfdf3": "認証を続行できませんでした",
"25617239c4886378": "認証リクエストの期限が切れました。",
"254dc4b4151094ef": "モデルを更新できませんでした",
"114f22c0e3900fad": "プロバイダーのモデル一覧を更新できませんでした。",
"1bc94053b36b3f40": "{provider} を更新できませんでした",
"5b39dc5c8173ee94": "プロバイダーの更新コマンドを開始できませんでした。",
"53e1e3591fc1abc9": "プロバイダーのインスタンスを更新できませんでした",
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/i18n/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -8982,6 +8982,8 @@
},
"을(를) 사용하지만 이 빌드에서는 사용할 수 없습니다. 구성은 보존됩니다."
],
"a9b5d2852719fddc": "모델 새로고침 중",
"4811262c294ce7d5": "모델 새로고침",
"b534d4cd528ede39": "모델 기본 설정과 사용자 지정 모델은 선택한 환경에 저장되며 연결된 기기 간에 공유됩니다.",
"caaef21e8722857d": "빠른 모드",
"a860db2b1bb3aa31": "추론 없음",
Expand Down Expand Up @@ -9093,6 +9095,8 @@
"9cd6647baae39b79": "제공자를 새로 고치고 인증 절차를 다시 시작하세요.",
"34e971a4cd3cfdf3": "인증을 계속할 수 없습니다",
"25617239c4886378": "인증 요청이 만료되었습니다.",
"254dc4b4151094ef": "모델을 새로고침하지 못했습니다",
"114f22c0e3900fad": "공급자 모델 목록을 새로고침하지 못했습니다.",
"1bc94053b36b3f40": "{provider}을(를) 업데이트할 수 없습니다",
"5b39dc5c8173ee94": "제공자 업데이트 명령을 시작할 수 없습니다.",
"53e1e3591fc1abc9": "제공자 인스턴스를 업데이트할 수 없습니다",
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/i18n/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -9024,6 +9024,8 @@
},
", que não está disponível nesta build. A configuração dela é preservada."
],
"a9b5d2852719fddc": "Atualizando modelos",
"4811262c294ce7d5": "Atualizar modelos",
"b534d4cd528ede39": "As preferências de modelo e os modelos personalizados são salvos no ambiente selecionado e compartilhados entre os dispositivos conectados.",
"caaef21e8722857d": "Modo rápido",
"a860db2b1bb3aa31": "Sem raciocínio",
Expand Down Expand Up @@ -9135,6 +9137,8 @@
"9cd6647baae39b79": "Atualize o provedor e inicie o fluxo de autenticação novamente.",
"34e971a4cd3cfdf3": "Não foi possível continuar a autenticação",
"25617239c4886378": "A solicitação de autenticação expirou.",
"254dc4b4151094ef": "Não foi possível atualizar os modelos",
"114f22c0e3900fad": "Não foi possível atualizar a lista de modelos do provedor.",
"1bc94053b36b3f40": "Não foi possível atualizar o {provider}",
"5b39dc5c8173ee94": "Não foi possível iniciar o comando de atualização do provedor.",
"53e1e3591fc1abc9": "Não foi possível atualizar a instância do provedor",
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/i18n/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -9025,6 +9025,8 @@
},
", который недоступен в этой сборке. Его конфигурация сохранена."
],
"a9b5d2852719fddc": "Обновление моделей",
"4811262c294ce7d5": "Обновить модели",
"b534d4cd528ede39": "Настройки моделей и свои модели сохраняются в выбранном окружении и доступны на всех подключённых устройствах.",
"caaef21e8722857d": "Быстрый режим",
"a860db2b1bb3aa31": "Без рассуждений",
Expand Down Expand Up @@ -9136,6 +9138,8 @@
"9cd6647baae39b79": "Обновите провайдера и начните аутентификацию заново.",
"34e971a4cd3cfdf3": "Не удалось продолжить аутентификацию",
"25617239c4886378": "Срок запроса аутентификации истёк.",
"254dc4b4151094ef": "Не удалось обновить модели",
"114f22c0e3900fad": "Не удалось обновить список моделей провайдера.",
"1bc94053b36b3f40": "Не удалось обновить {provider}",
"5b39dc5c8173ee94": "Не удалось запустить команду обновления провайдера.",
"53e1e3591fc1abc9": "Не удалось обновить экземпляр провайдера",
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/i18n/translations/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -9031,6 +9031,8 @@
},
", som inte finns i den här versionen. Dess konfiguration bevaras."
],
"a9b5d2852719fddc": "Uppdaterar modeller",
"4811262c294ce7d5": "Uppdatera modeller",
"b534d4cd528ede39": "Modellinställningar och anpassade modeller sparas i den valda miljön och delas mellan anslutna enheter.",
"caaef21e8722857d": "Snabbläge",
"a860db2b1bb3aa31": "Inget resonerande",
Expand Down Expand Up @@ -9142,6 +9144,8 @@
"9cd6647baae39b79": "Uppdatera leverantören och starta autentiseringen igen.",
"34e971a4cd3cfdf3": "Kunde inte fortsätta autentiseringen",
"25617239c4886378": "Autentiseringsbegäran har gått ut.",
"254dc4b4151094ef": "Kunde inte uppdatera modeller",
"114f22c0e3900fad": "Leverantörens modellista kunde inte uppdateras.",
"1bc94053b36b3f40": "Kunde inte uppdatera {provider}",
"5b39dc5c8173ee94": "Leverantörens uppdateringskommando kunde inte startas.",
"53e1e3591fc1abc9": "Kunde inte uppdatera leverantörsinstansen",
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/i18n/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -9041,6 +9041,8 @@
},
",当前版本不支持。其配置会保留。"
],
"a9b5d2852719fddc": "正在刷新模型",
"4811262c294ce7d5": "刷新模型",
"b534d4cd528ede39": "模型偏好和自定义模型保存在所选环境中,并在已连接的设备间共享。",
"caaef21e8722857d": "快速模式",
"a860db2b1bb3aa31": "无推理",
Expand Down Expand Up @@ -9152,6 +9154,8 @@
"9cd6647baae39b79": "请刷新提供方并重新开始认证。",
"34e971a4cd3cfdf3": "无法继续认证",
"25617239c4886378": "认证请求已过期。",
"254dc4b4151094ef": "无法刷新模型",
"114f22c0e3900fad": "无法刷新此提供商的模型列表。",
"1bc94053b36b3f40": "无法更新 {provider}",
"5b39dc5c8173ee94": "无法启动提供方更新命令。",
"53e1e3591fc1abc9": "无法更新提供方实例",
Expand Down
Loading
Loading