diff --git a/ui-react/src/pages/modeling/thread/MintRuns.tsx b/ui-react/src/pages/modeling/thread/MintRuns.tsx index 84993e1d..60090704 100644 --- a/ui-react/src/pages/modeling/thread/MintRuns.tsx +++ b/ui-react/src/pages/modeling/thread/MintRuns.tsx @@ -1049,6 +1049,87 @@ interface MintRunsProps { const PAGE_SIZE = 100; +interface RunParam { + id?: string | null; + name?: string | null; + default?: string | null; +} + +function humanizeName(name?: string | null): string { + return (name ?? '').replace(/[-_]/g, ' '); +} + +/** The value a run shows for a parameter: its binding, else the default. */ +function runParamValue(param: RunParam, execution: Execution): string { + let value = execution.bindings[param.id ?? ''] as unknown; + if (value == null) value = param.default ?? null; + if (typeof value === 'string' && value.startsWith('__region_geojson')) { + return 'Region GeoJSON'; + } + if (value == null || value === '') return '—'; + return String(value); +} + +/** + * Split parameters into those that tell the listed runs apart (they get a + * column) and those every run shares (they are summarised above the table). + */ +function splitRunParams

( + params: P[], + executions: Execution[], +): { varying: P[]; common: Array<{ param: P; value: string }> } { + const varying: P[] = []; + const common: Array<{ param: P; value: string }> = []; + for (const param of params) { + const values = new Set(executions.map((e) => runParamValue(param, e))); + if (values.size > 1) { + varying.push(param); + } else { + const value = executions[0] ? runParamValue(param, executions[0]) : '—'; + if (value !== '—') common.push({ param, value }); + } + } + return { varying, common }; +} + +const SAME_FOR_EVERY_RUN_LIMIT = 6; + +function SameForEveryRun({ + items, + testId, +}: { + items: Array<{ param: RunParam; value: string }>; + testId: string; +}) { + const [showAll, setShowAll] = useState(false); + if (items.length === 0) return null; + const truncated = items.length > SAME_FOR_EVERY_RUN_LIMIT && !showAll; + const shown = truncated ? items.slice(0, SAME_FOR_EVERY_RUN_LIMIT) : items; + return ( +

+ Same for every run:{' '} + {shown.map(({ param, value }, i) => ( + + {i > 0 && ' · '} + {humanizeName(param.name)} {value} + + ))} + {items.length > SAME_FOR_EVERY_RUN_LIMIT && ( + <> + {' '} + + + )} +

+ ); +} + export function MintRuns({ threadId, threadData, @@ -1351,7 +1432,11 @@ export function MintRuns({ // ── adjustable inputs / params for column headers ───────────── const adjustableInputs = model.input_files.filter((f) => !f.value); - const adjustableParams = userParameters(model).filter((p) => !p.value); + const settableParams = userParameters(model).filter((p) => !p.value); + const { varying: adjustableParams, common: sameParams } = splitRunParams( + settableParams, + grouped.executions, + ); return (
  • @@ -1568,8 +1653,10 @@ export function MintRuns({ - {/* Runs table */} -
    + {/* Runs table: paged, so it grows with the step pane instead of + adding a scroll box of its own. */} + +
    {grouped.loading ? (
    @@ -1579,7 +1666,7 @@ export function MintRuns({ className="w-full border-collapse text-xs" data-testid={`runs-table-${mid}`} > - + Run @@ -1617,7 +1704,7 @@ export function MintRuns({ ))} {adjustableParams.map((p) => ( - {(p.name ?? '').replace(/[-_]/g, ' ')} + {humanizeName(p.name)} ))} @@ -1643,10 +1730,6 @@ export function MintRuns({ ) : ( grouped.executions.map((execution: Execution) => { - const paramDefaults: Record = {}; - userParameters(model).forEach( - (p) => (paramDefaults[p.id ?? ''] = p.default ?? null), - ); return ( @@ -1713,24 +1796,11 @@ export function MintRuns({ ); })} - {adjustableParams.map((param) => { - let pval = execution.bindings[param.id ?? ''] as - | string - | null - | undefined; - if (pval == null) pval = paramDefaults[param.id ?? '']; - if ( - typeof pval === 'string' && - pval.startsWith('__region_geojson') - ) { - pval = 'Region GeoJSON'; - } - return ( - - {pval ?? '—'} - - ); - })} + {adjustableParams.map((param) => ( + + {runParamValue(param, execution)} + + ))} ); }) diff --git a/ui-react/src/pages/modeling/thread/__tests__/MintRuns.test.tsx b/ui-react/src/pages/modeling/thread/__tests__/MintRuns.test.tsx index 73bf3ccc..af3984d0 100644 --- a/ui-react/src/pages/modeling/thread/__tests__/MintRuns.test.tsx +++ b/ui-react/src/pages/modeling/thread/__tests__/MintRuns.test.tsx @@ -2,7 +2,7 @@ * Tests for MintRuns — execution lifecycle step. */ import { afterEach, beforeEach, describe, expect, it, vi, type Mock } from 'vitest'; -import { screen, fireEvent, waitFor } from '@testing-library/react'; +import { screen, fireEvent, waitFor, within } from '@testing-library/react'; import { renderWithProviders } from '@/test/utils/render'; import { storeTokens } from '@/lib/auth/token-store'; import { MintRuns } from '../MintRuns'; @@ -943,3 +943,81 @@ describe('MintRuns archived files', () => { ); }); }); + +// A flow can expose a dozen settings; only the ones that tell runs apart earn +// a column, the rest are summarised once above the table. +describe('MintRuns runs table columns', () => { + const model = { + ...mockModel, + input_parameters: [ + { id: 'p-depth', name: 'flood_depth', type: 'float', default: '10' }, + { id: 'p-mode', name: 'match_mode', type: 'string', default: 'longest_match' }, + { id: 'p-max', name: 'max_files', type: 'int', default: '200' }, + ], + }; + const thread: ThreadExecutionData = { + ...mockThreadDataSubmitted, + models: { 'model-1': model }, + model_ensembles: { + 'model-1': { + id: 'ens-1', + bindings: { 'p-depth': ['15', '25'], 'p-mode': ['longest_match'], 'p-max': ['200'] }, + }, + }, + }; + const run = (id: string, bindings: Record) => ({ + id, + modelid: 'model-1', + status: 'SUCCESS', + run_progress: 1, + bindings, + results: {}, + }); + + function renderRuns(runs: ReturnType[]) { + return renderWithProviders( + , + ); + } + + it('shows no parameter columns for one run and lists every value as shared', () => { + renderRuns([run('exec-1', { 'p-depth': '15' })]); + const table = screen.getByTestId('runs-table-model-1'); + expect(within(table).queryByText('Parameters')).not.toBeInTheDocument(); + expect(within(table).queryByText('flood depth')).not.toBeInTheDocument(); + const line = screen.getByTestId('same-for-every-run-model-1'); + expect(line).toHaveTextContent('Same for every run:'); + expect(line).toHaveTextContent('flood depth 15'); + expect(line).toHaveTextContent('match mode longest_match'); + expect(line).toHaveTextContent('max files 200'); + }); + + it('gives only the parameter that differs a column', () => { + renderRuns([run('exec-1', { 'p-depth': '15' }), run('exec-2', { 'p-depth': '25' })]); + const table = screen.getByTestId('runs-table-model-1'); + expect(within(table).getByText('flood depth')).toBeInTheDocument(); + expect(within(table).queryByText('match mode')).not.toBeInTheDocument(); + expect(within(table).queryByText('max files')).not.toBeInTheDocument(); + expect(within(table).getByText('15')).toBeInTheDocument(); + expect(within(table).getByText('25')).toBeInTheDocument(); + const line = screen.getByTestId('same-for-every-run-model-1'); + expect(line).toHaveTextContent('match mode longest_match'); + expect(line).not.toHaveTextContent('flood depth'); + }); + + it('does not wrap the table in a vertically scrolling box', () => { + renderRuns([run('exec-1', {}), run('exec-2', {})]); + const wrapper = screen.getByTestId('runs-table-model-1').parentElement; + expect(wrapper?.className).not.toContain('max-h-96'); + expect(wrapper?.className).not.toMatch(/\boverflow-(auto|y-)/); + }); +});