Skip to content

Commit ca77634

Browse files
authored
fix(benchmark): scenario status in run view and some additional tweaks (#98)
## Description <!-- Provide a brief description of your changes --> Summary of Pending Changes (3 files modified) 1. src/components/StatusBadge.tsx (Minor change) - Changed "COMPLETED" to "COMPLETE" for consistency - Updated label from "Completed" to "Complete" 2. src/screens/BenchmarkJobDetailScreen.tsx (+59 lines) Main feature: Fetch actual benchmark run names instead of showing IDs - Added import for getBenchmarkRun service - Added runNames state to cache fetched run names - Added React effect that: - Collects all run IDs from outcomes and in-progress runs - Fetches full run details in parallel using getBenchmarkRun() - Extracts names (falls back to ID if name is null) - Stores in a Map for fast lookup - Updated run display logic to use fetched names instead of: - Old: agent names or "Unknown Agent" - New: actual benchmark run names from API 3. src/screens/BenchmarkRunDetailScreen.tsx (+263 lines, -53 lines) Major feature: Display scenario runs within benchmark run details Added features: - Scenario runs state and loading - Overall status section that calculates aggregate status from scenario runs - Shows "Failed", "Complete", "In Progress", or "Not Started" - Displays scenario count - Scenario runs table with columns: - ID - Name - Status (with colors) - Score - Auto-refresh scenario runs every 5 seconds when run is active - Polling integration to refresh scenario runs alongside run details Removed: - Environment Variables section (removed from both detail view and polling display) **Note:** PR titles should follow [Conventional Commits](https://www.conventionalcommits.org/) format (e.g., `feat(devbox): add support for custom env vars` or `fix(snapshot): resolve pagination issue`) as they are used for automatic release notes generation. ## Type of Change <!-- Mark the relevant option with an 'x' --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update - [ ] Code refactoring - [ ] Performance improvement - [ ] Test updates ## Related Issues <!-- Link to related issues using #issue-number --> Closes # ## Changes Made <!-- Describe the changes in detail --> ## Testing <!-- Describe how you tested your changes --> - [ ] I have tested locally - [ ] I have added/updated tests - [ ] All existing tests pass ## Checklist - [ ] My code follows the code style of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have updated the documentation accordingly - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published ## Screenshots (if applicable) <!-- Add screenshots to help explain your changes --> ## Additional Notes <!-- Any additional information that reviewers should know -->
1 parent a3c1b7a commit ca77634

3 files changed

Lines changed: 287 additions & 53 deletions

File tree

src/components/StatusBadge.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ export const getStatusDisplay = (status: string): StatusDisplay => {
140140
return {
141141
icon: figures.tick,
142142
color: colors.success,
143-
text: "COMPLETED ",
144-
label: "Completed",
143+
text: "COMPLETE ",
144+
label: "Complete",
145145
};
146146
case "canceled":
147147
return {

src/screens/BenchmarkJobDetailScreen.tsx

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
type ResourceOperation,
1818
} from "../components/ResourceDetailPage.js";
1919
import { getBenchmarkJob } from "../services/benchmarkJobService.js";
20+
import { getBenchmarkRun } from "../services/benchmarkService.js";
2021
import { SpinnerComponent } from "../components/Spinner.js";
2122
import { ErrorMessage } from "../components/ErrorMessage.js";
2223
import { Breadcrumb } from "../components/Breadcrumb.js";
@@ -35,6 +36,9 @@ export function BenchmarkJobDetailScreen({
3536
const [loading, setLoading] = React.useState(false);
3637
const [error, setError] = React.useState<Error | null>(null);
3738
const [fetchedJob, setFetchedJob] = React.useState<BenchmarkJob | null>(null);
39+
const [runNames, setRunNames] = React.useState<Map<string, string>>(
40+
new Map(),
41+
);
3842

3943
// Find job in store first
4044
const jobFromStore = benchmarkJobs.find((j) => j.id === benchmarkJobId);
@@ -66,6 +70,47 @@ export function BenchmarkJobDetailScreen({
6670
// Use fetched job for full details, fall back to store for basic display
6771
const job = fetchedJob || jobFromStore;
6872

73+
// Fetch run names when job is loaded
74+
React.useEffect(() => {
75+
if (!job) return;
76+
77+
const runIds: string[] = [];
78+
79+
// Collect run IDs from outcomes
80+
if (job.benchmark_outcomes) {
81+
job.benchmark_outcomes.forEach((outcome) => {
82+
runIds.push(outcome.benchmark_run_id);
83+
});
84+
}
85+
86+
// Collect run IDs from in-progress runs
87+
if (job.in_progress_runs) {
88+
job.in_progress_runs.forEach((run) => {
89+
if (!runIds.includes(run.benchmark_run_id)) {
90+
runIds.push(run.benchmark_run_id);
91+
}
92+
});
93+
}
94+
95+
// Fetch run details for each run ID
96+
Promise.all(
97+
runIds.map(async (runId) => {
98+
try {
99+
const run = await getBenchmarkRun(runId);
100+
return { id: runId, name: run.name || runId };
101+
} catch {
102+
return { id: runId, name: runId };
103+
}
104+
}),
105+
).then((results) => {
106+
const namesMap = new Map<string, string>();
107+
results.forEach((result) => {
108+
namesMap.set(result.id, result.name);
109+
});
110+
setRunNames(namesMap);
111+
});
112+
}, [job]);
113+
69114
// Show loading state
70115
if (!job && benchmarkJobId && !error) {
71116
return (
@@ -496,24 +541,26 @@ export function BenchmarkJobDetailScreen({
496541
}
497542

498543
// Collect benchmark run IDs for operations
499-
const benchmarkRunIds: { id: string; agentName: string }[] = [];
544+
const benchmarkRunIds: { id: string; name: string }[] = [];
500545
if (job.benchmark_outcomes) {
501546
job.benchmark_outcomes.forEach((outcome) => {
547+
// Use fetched run name from state, fallback to run ID
548+
const runName =
549+
runNames.get(outcome.benchmark_run_id) || outcome.benchmark_run_id;
502550
benchmarkRunIds.push({
503551
id: outcome.benchmark_run_id,
504-
agentName: outcome.agent_name,
552+
name: runName,
505553
});
506554
});
507555
}
508556
if (job.in_progress_runs) {
509557
job.in_progress_runs.forEach((run) => {
510-
let agentName = "Unknown Agent";
511-
if (run.agent_config && "name" in run.agent_config) {
512-
agentName = (run.agent_config as any).name;
513-
}
514558
// Avoid duplicates
515559
if (!benchmarkRunIds.find((r) => r.id === run.benchmark_run_id)) {
516-
benchmarkRunIds.push({ id: run.benchmark_run_id, agentName });
560+
// Use fetched run name from state, fallback to run ID
561+
const runName =
562+
runNames.get(run.benchmark_run_id) || run.benchmark_run_id;
563+
benchmarkRunIds.push({ id: run.benchmark_run_id, name: runName });
517564
}
518565
});
519566
}
@@ -525,7 +572,7 @@ export function BenchmarkJobDetailScreen({
525572
benchmarkRunIds.slice(0, 9).forEach((run, idx) => {
526573
operations.push({
527574
key: `view-run-${idx}`,
528-
label: `View Run: ${run.agentName}`,
575+
label: `View Run: ${run.name}`,
529576
color: colors.info,
530577
icon: figures.arrowRight,
531578
shortcut: String(idx + 1),

0 commit comments

Comments
 (0)