From 4545a219297d59563f1fb0b3eae694288d6d6986 Mon Sep 17 00:00:00 2001 From: zlareb1 Date: Wed, 18 Nov 2026 09:02:30 +0000 Subject: [PATCH] Recall Lab reuses settled scores while editing a query Draft query edits rebuilt the score table before the debounced search ran. Reuse the table until its result, loading or opening context changes, while keeping query cancellation and immediate clearing unchanged. Signed-off-by: zlareb1 --- frontend/src/views/RecallLab.table.test.tsx | 20 ++++++++++++++ frontend/src/views/RecallLab.tsx | 30 ++++++++++++--------- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/frontend/src/views/RecallLab.table.test.tsx b/frontend/src/views/RecallLab.table.test.tsx index d7383be8fb..f2391d721e 100644 --- a/frontend/src/views/RecallLab.table.test.tsx +++ b/frontend/src/views/RecallLab.table.test.tsx @@ -106,6 +106,26 @@ describe("Recall Lab: the scores table", () => { expect(screen.queryByRole("button", { name: "deploy_note" })).toBeNull(); }); + it("keeps settled scores out of draft query edits and clears them with the query", async () => { + const result = hit("deploy_note", 0.9); + const readTerms = vi.fn(() => ({ semantic: 0.6, entity_ann_boost_effective: 0.06 })); + Object.defineProperty(result, "score_components", { get: readTerms }); + searchMemory.mockResolvedValue({ results: [result], embedding_model: "m" }); + render(); + const table = await score(); + expect(readTerms).toHaveBeenCalled(); + readTerms.mockClear(); + + fireEvent.change(screen.getByLabelText("Recall query"), { target: { value: "deploy lane" } }); + expect(screen.getByLabelText("Recall query")).toHaveValue("deploy lane"); + expect(within(table).getByText("excerpt of deploy_note")).toBeInTheDocument(); + expect(readTerms).not.toHaveBeenCalled(); + expect(searchMemory).toHaveBeenCalledTimes(1); + + fireEvent.change(screen.getByLabelText("Recall query"), { target: { value: "" } }); + expect(screen.queryByRole("table", { name: "Recall scores" })).toBeNull(); + }); + it("draws the score as Click UI's table bar, relative to the top score", async () => { searchMemory.mockResolvedValue({ results: [hit("deploy_note", 0.8), hit("rollback_runbook", 0.4)], diff --git a/frontend/src/views/RecallLab.tsx b/frontend/src/views/RecallLab.tsx index 3398a2b133..03a6f977eb 100644 --- a/frontend/src/views/RecallLab.tsx +++ b/frontend/src/views/RecallLab.tsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useState } from "react"; +import { useCallback, useEffect, useMemo, useState } from "react"; import { Badge } from "@clickhouse/click-ui/Badge"; import { Button } from "@clickhouse/click-ui/Button"; import { Icon } from "@clickhouse/click-ui/Icon"; @@ -509,7 +509,21 @@ export function RecallLab() { }, [query, identity, attempt]); const showResults = !abstain || showWeak; - const topScore = Math.max(0, ...(rows ?? []).map((row) => row.hit?.rank_score ?? 0)); + const scoresTable = useMemo(() => { + if (rows == null || rows.length === 0 || !showResults) return null; + const topScore = Math.max(0, ...rows.map((row) => row.hit?.rank_score ?? 0)); + return ( + scoreRow(row, i, topScore, open, rowsQuery))} + /> + ); + }, [rows, rowsQuery, open, loading, showResults]); const count = rows != null && rows.length > 0 && showResults && error == null ? `${rows.length} row${rows.length === 1 ? "" : "s"}${model ? ` ยท ${model}` : ""}` @@ -593,17 +607,7 @@ export function RecallLab() { )} )} - {showResults && ( -
scoreRow(row, i, topScore, open, rowsQuery))} - /> - )} + {scoresTable} )}