Skip to content
Draft
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
24 changes: 18 additions & 6 deletions apps/web/src/components/settings/ProviderInstanceCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from "lucide-react";
import * as Arr from "effect/Array";
import * as Result from "effect/Result";
import { useEffect, useState, type ReactNode } from "react";
import { useState, type ReactNode } from "react";
import {
isProviderDriverKind,
type ProviderInstanceConfig,
Expand Down Expand Up @@ -77,6 +77,19 @@ function makeEnvironmentDraftRow(
};
}

function getProviderEnvironmentSectionKey(
environment: ReadonlyArray<ProviderInstanceEnvironmentVariable>,
): string {
return JSON.stringify(
environment.map((variable) => [
variable.name,
variable.value,
variable.sensitive,
variable.valueRedacted ?? null,
]),
);
}

/**
* Read a string[] at `key` from the opaque config blob, filtering out
* non-string entries. Used for `customModels`, which is always typed as
Expand Down Expand Up @@ -161,10 +174,6 @@ function ProviderEnvironmentSection(props: {
props.environment.map(makeEnvironmentDraftRow),
);

useEffect(() => {
setRows(props.environment.map(makeEnvironmentDraftRow));
}, [props.environment]);

const publishRows = (nextRows: ReadonlyArray<EnvironmentDraftRow>) => {
const published: ProviderInstanceEnvironmentVariable[] = [];
for (const row of nextRows) {
Expand Down Expand Up @@ -448,6 +457,8 @@ export function ProviderInstanceCard({
: null;

const customModels = readConfigStringArray(instance.config, "customModels");
const environment = instance.environment ?? [];
const environmentSectionKey = getProviderEnvironmentSectionKey(environment);
// Server-returned models may lag behind settings writes. Treat probe
// models as the source for built-ins only; custom rows come directly
// from the current instance config so add/remove reflects immediately.
Expand Down Expand Up @@ -763,7 +774,8 @@ export function ProviderInstanceCard({

<div className="border-t border-border/60 px-4 py-3 sm:px-5">
<ProviderEnvironmentSection
environment={instance.environment ?? []}
key={environmentSectionKey}
environment={environment}
onChange={updateEnvironment}
/>
</div>
Expand Down
Loading