Skip to content
Closed
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
20 changes: 20 additions & 0 deletions frontend/src/views/RecallLab.table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<RecallLab />);
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)],
Expand Down
30 changes: 17 additions & 13 deletions frontend/src/views/RecallLab.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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 (
<Table
aria-label="Recall scores"
aria-busy={loading || undefined}
size="sm"
// Ask about this on every row; a role the assistant's route does not admit sees
// it unavailable, with the role it needs.
headers={ASK_HEADERS}
rows={rows.map((row, i) => 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}` : ""}`
Expand Down Expand Up @@ -593,17 +607,7 @@ export function RecallLab() {
)}
</div>
)}
{showResults && (
<Table
aria-label="Recall scores"
aria-busy={loading || undefined}
size="sm"
// Ask about this on every row; a role the assistant's route does not admit sees
// it unavailable, with the role it needs.
headers={ASK_HEADERS}
rows={rows.map((row, i) => scoreRow(row, i, topScore, open, rowsQuery))}
/>
)}
{scoresTable}
</>
)}
</Tabs.Content>
Expand Down
Loading