fix: derive semantic state correctly from null semantic values

This commit is contained in:
Rehan Sanjay 2026-07-10 04:48:37 +05:30
parent 38369930bd
commit 5abd7d469e
2 changed files with 10 additions and 2 deletions

View file

@ -77,6 +77,14 @@ describe("CacheSettings", () => {
expect(await screen.findByText("Similarity Threshold")).toBeInTheDocument();
expect(screen.getByText("Embedding Model")).toBeInTheDocument();
});
it("should NOT reveal the semantic fields when similarity_threshold is null", async () => {
getCacheSettingsCall.mockResolvedValue({ current_values: { similarity_threshold: null } });
renderSettings();
expect(await screen.findByText("Connection Settings")).toBeInTheDocument();
expect(screen.queryByText("Similarity Threshold")).not.toBeInTheDocument();
expect(screen.queryByText("Embedding Model")).not.toBeInTheDocument();
});
});
describe("when a field fails inline validation", () => {

View file

@ -39,8 +39,8 @@ const CacheSettings: React.FC<CacheSettingsProps> = ({ accessToken }) => {
// Detect if existing config uses semantic caching
if (
currentValues.redis_type === "semantic" ||
currentValues.similarity_threshold !== undefined ||
currentValues.redis_semantic_cache_embedding_model !== undefined
currentValues.similarity_threshold != null ||
currentValues.redis_semantic_cache_embedding_model != null
) {
setSemanticEnabled(true);
}