-
-
Notifications
You must be signed in to change notification settings - Fork 219
[SDK] Add group filtering #1595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,11 @@ | ||
| import { EvalCase, EvalIteration, EvalSuite, SuiteAggregate } from "./types"; | ||
| import { | ||
| EvalCase, | ||
| EvalIteration, | ||
| EvalSuite, | ||
| EvalSuiteOverviewEntry, | ||
| SuiteAggregate, | ||
| TagGroupAggregate, | ||
| } from "./types"; | ||
| import { computeIterationResult } from "./pass-criteria"; | ||
| import { toast } from "sonner"; | ||
| import { RESULT_STATUS } from "./constants"; | ||
|
|
@@ -226,3 +233,54 @@ export const formatters = { | |
| percentage: formatPercentage, | ||
| tokens: formatTokens, | ||
| } as const; | ||
|
|
||
| /** | ||
| * Group overview entries by tag and compute aggregated stats per tag. | ||
| */ | ||
| export function groupSuitesByTag( | ||
| overview: EvalSuiteOverviewEntry[], | ||
| ): TagGroupAggregate[] { | ||
| const buckets = new Map<string, EvalSuiteOverviewEntry[]>(); | ||
|
|
||
| for (const entry of overview) { | ||
| const tags = entry.suite.tags; | ||
| if (!tags || tags.length === 0) { | ||
| const bucket = buckets.get("Untagged") ?? []; | ||
| bucket.push(entry); | ||
| buckets.set("Untagged", bucket); | ||
| } else { | ||
| for (const tag of tags) { | ||
| const bucket = buckets.get(tag) ?? []; | ||
| bucket.push(entry); | ||
| buckets.set(tag, bucket); | ||
|
Comment on lines
+252
to
+255
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deduplicate per-suite tags before bucketing to prevent inflated aggregates. At Line 252, iterating raw 🩹 Minimal fix- for (const tag of tags) {
+ for (const tag of new Set(tags)) {
const bucket = buckets.get(tag) ?? [];
bucket.push(entry);
buckets.set(tag, bucket);
}Also applies to: 271-273 🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
| } | ||
|
|
||
| const groups: TagGroupAggregate[] = []; | ||
| for (const [tag, entries] of buckets) { | ||
| const totals = { passed: 0, failed: 0, runs: 0 }; | ||
| for (const e of entries) { | ||
| totals.passed += e.totals.passed; | ||
| totals.failed += e.totals.failed; | ||
| totals.runs += e.totals.runs; | ||
| } | ||
| const total = totals.passed + totals.failed; | ||
| groups.push({ | ||
| tag, | ||
| suiteCount: entries.length, | ||
| totals, | ||
| passRate: total > 0 ? Math.round((totals.passed / total) * 100) : 0, | ||
| entries, | ||
| }); | ||
| } | ||
|
|
||
| // Sort alphabetically, "Untagged" last | ||
| groups.sort((a, b) => { | ||
| if (a.tag === "Untagged") return 1; | ||
| if (b.tag === "Untagged") return -1; | ||
| return a.tag.localeCompare(b.tag); | ||
| }); | ||
|
|
||
| return groups; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,7 @@ import type { ModelDefinition } from "@/shared/types"; | |
| import { isMCPJamProvidedModel } from "@/shared/types"; | ||
| import { ProviderLogo } from "@/components/chat-v2/chat-input/model/provider-logo"; | ||
| import { CiMetadataDisplay } from "./ci-metadata-display"; | ||
| import { TagEditor, TagBadges } from "./tag-editor"; | ||
|
|
||
| interface ModelInfo { | ||
| model: string; | ||
|
|
@@ -530,6 +531,25 @@ export function SuiteHeader({ | |
| </ChartContainer> | ||
| </div> | ||
| )} | ||
| {!readOnlyConfig && ( | ||
| <TagEditor | ||
| tags={suite.tags ?? []} | ||
| onTagsChange={async (newTags) => { | ||
| try { | ||
| await updateSuite({ | ||
| suiteId: suite._id, | ||
| tags: newTags, | ||
| }); | ||
| } catch (error) { | ||
| toast.error("Failed to update tags"); | ||
| console.error("Failed to update tags:", error); | ||
| } | ||
| }} | ||
| /> | ||
| )} | ||
|
Comment on lines
+534
to
+549
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Serialize tag updates or keep an optimistic local copy.
🤖 Prompt for AI Agents |
||
| {readOnlyConfig && suite.tags && suite.tags.length > 0 && ( | ||
| <TagBadges tags={suite.tags} /> | ||
| )} | ||
| </div> | ||
| <div className="flex items-center gap-2 shrink-0"> | ||
| {/* Models picker - compact dropdown */} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clear stale tag filters when the available tags change.
filterTagsurvives workspace switches and tag edits, but it is never reconciled withallTags. If the selected tag disappears, the sidebar keeps filtering by a value the UI no longer exposes, and whenhasTagsflips false the user is left with an empty list and no control to recover.🩹 Minimal fix
const allTags = useMemo( () => Array.from(new Set(sdkSuites.flatMap((e) => e.suite.tags ?? []))).sort(), [sdkSuites], ); + + useEffect(() => { + if (filterTag && !allTags.includes(filterTag)) { + setFilterTag(null); + } + }, [filterTag, allTags]);Also applies to: 89-95
🤖 Prompt for AI Agents