Remove provider environment sync effect
Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
1 parent
d25090cf6d
commit
f65e38f3d1
1 file changed
+18
-6
@@ -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,
|
||||
@@ -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
|
||||
@@ -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) {
|
||||
@@ -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.
|
||||
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user