@railtownai/railtracks-visualizer 0.0.55 → 0.0.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -114702,27 +114702,19 @@ const EvaluationDetailsDrawer = ({ evaluation, open, onClose, getEvaluatorResult
114702
114702
  })))));
114703
114703
  };
114704
114704
 
114705
- const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefresh, onRowClick, onCompare, compareIdsFromUrl, onCompareUrlChange, showFilters = true, showCompare = true, emptyMessage, title })=>{
114705
+ const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefresh, onRowClick, onCompare, compareIdsFromUrl, onCompareUrlChange, showFilters = true, showCompare = true, emptyMessage, title, pagination: serverPagination, onFiltersChange, onFetchEvaluationsByIds })=>{
114706
114706
  const { theme } = useTheme$1();
114707
114707
  const [selectedAgents, setSelectedAgents] = React.useState([]);
114708
114708
  const [selectedRowKeys, setSelectedRowKeys] = React.useState([]);
114709
114709
  const [compareDrawerOpen, setCompareDrawerOpen] = React.useState(false);
114710
114710
  const [evaluationId1, setEvaluationId1] = React.useState(null);
114711
114711
  const [evaluationId2, setEvaluationId2] = React.useState(null);
114712
- // Sync drawer when compare param comes from URL
114713
- React.useEffect(()=>{
114714
- if (compareIdsFromUrl) {
114715
- setEvaluationId1(compareIdsFromUrl[0]);
114716
- setEvaluationId2(compareIdsFromUrl[1]);
114717
- setCompareDrawerOpen(true);
114718
- }
114719
- }, [
114720
- compareIdsFromUrl
114721
- ]);
114722
114712
  const [selectedEvaluation, setSelectedEvaluation] = React.useState(null);
114723
114713
  const [detailsDrawerOpen, setDetailsDrawerOpen] = React.useState(false);
114724
114714
  const [pageSize, setPageSize] = React.useState(50);
114725
114715
  const [selectedMetricFilter, setSelectedMetricFilter] = React.useState(null);
114716
+ const [drawerEvaluations, setDrawerEvaluations] = React.useState([]);
114717
+ const isServerPagination = !!serverPagination;
114726
114718
  const normalized = React.useMemo(()=>evaluations.map((e)=>isEvaluationDto(e) ? transformEvaluation(e) : e), [
114727
114719
  evaluations
114728
114720
  ]);
@@ -114771,6 +114763,63 @@ const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefres
114771
114763
  selectedAgents,
114772
114764
  selectedMetricFilter
114773
114765
  ]);
114766
+ const tableDataSource = filteredEvaluations;
114767
+ const compareDrawerEvaluations = React.useMemo(()=>{
114768
+ if (drawerEvaluations.length === 0) return normalized;
114769
+ const byId = new Map(normalized.map((e)=>[
114770
+ e.evaluation_id,
114771
+ e
114772
+ ]));
114773
+ for (const e of drawerEvaluations){
114774
+ const id = e.evaluation_id ?? e.evaluation_id;
114775
+ if (id && !byId.has(id)) byId.set(id, e);
114776
+ }
114777
+ return Array.from(byId.values());
114778
+ }, [
114779
+ normalized,
114780
+ drawerEvaluations
114781
+ ]);
114782
+ // Sync drawer when compare param comes from URL
114783
+ React.useEffect(()=>{
114784
+ if (compareIdsFromUrl) {
114785
+ setEvaluationId1(compareIdsFromUrl[0]);
114786
+ setEvaluationId2(compareIdsFromUrl[1]);
114787
+ setCompareDrawerOpen(true);
114788
+ }
114789
+ }, [
114790
+ compareIdsFromUrl
114791
+ ]);
114792
+ // Fetch evaluations by ID for compare drawer when opened from URL (server pagination)
114793
+ React.useEffect(()=>{
114794
+ if (!compareDrawerOpen || !onFetchEvaluationsByIds || !evaluationId1 || !evaluationId2) {
114795
+ setDrawerEvaluations([]);
114796
+ return;
114797
+ }
114798
+ const ids = [
114799
+ evaluationId1,
114800
+ evaluationId2
114801
+ ];
114802
+ const inNormalized = ids.every((id)=>normalized.some((e)=>e.evaluation_id === id));
114803
+ if (inNormalized) {
114804
+ setDrawerEvaluations([]);
114805
+ return;
114806
+ }
114807
+ let cancelled = false;
114808
+ onFetchEvaluationsByIds(ids).then((fetched)=>{
114809
+ if (!cancelled) {
114810
+ setDrawerEvaluations(fetched);
114811
+ }
114812
+ });
114813
+ return ()=>{
114814
+ cancelled = true;
114815
+ };
114816
+ }, [
114817
+ compareDrawerOpen,
114818
+ evaluationId1,
114819
+ evaluationId2,
114820
+ normalized,
114821
+ onFetchEvaluationsByIds
114822
+ ]);
114774
114823
  // Handle row selection - limit to 2 rows
114775
114824
  const handleRowSelectionChange = (selectedKeys)=>{
114776
114825
  if (selectedKeys.length <= 2) {
@@ -114922,7 +114971,12 @@ const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefres
114922
114971
  placeholder: "Filter by Agent",
114923
114972
  allowClear: true,
114924
114973
  value: selectedAgents,
114925
- onChange: setSelectedAgents,
114974
+ onChange: (v)=>{
114975
+ setSelectedAgents(v);
114976
+ if (isServerPagination && onFiltersChange) {
114977
+ onFiltersChange(v, selectedMetricFilter);
114978
+ }
114979
+ },
114926
114980
  style: {
114927
114981
  width: 200
114928
114982
  },
@@ -114934,7 +114988,13 @@ const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefres
114934
114988
  placeholder: "Filter by Evaluator / Metric",
114935
114989
  allowClear: true,
114936
114990
  value: selectedMetricFilter ?? undefined,
114937
- onChange: (v)=>setSelectedMetricFilter(v ?? null),
114991
+ onChange: (v)=>{
114992
+ const next = v ?? null;
114993
+ setSelectedMetricFilter(next);
114994
+ if (isServerPagination && onFiltersChange) {
114995
+ onFiltersChange(selectedAgents, next);
114996
+ }
114997
+ },
114938
114998
  style: {
114939
114999
  width: 240
114940
115000
  },
@@ -114957,7 +115017,7 @@ const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefres
114957
115017
  }
114958
115018
  }, emptyMessage ?? defaultEmptyMessage) : /*#__PURE__*/ React.createElement(ForwardTable, {
114959
115019
  columns: columns,
114960
- dataSource: filteredEvaluations,
115020
+ dataSource: tableDataSource,
114961
115021
  loading: loading,
114962
115022
  rowKey: "evaluation_id",
114963
115023
  rowSelection: showCompare ? {
@@ -114968,7 +115028,20 @@ const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefres
114968
115028
  disabled: selectedRowKeys.length >= 2 && !selectedRowKeys.includes(record.evaluation_id)
114969
115029
  })
114970
115030
  } : undefined,
114971
- pagination: filteredEvaluations.length <= pageSize ? false : {
115031
+ pagination: isServerPagination && serverPagination ? {
115032
+ total: serverPagination.total,
115033
+ current: serverPagination.current,
115034
+ pageSize: serverPagination.pageSize,
115035
+ showSizeChanger: true,
115036
+ showTotal: (total)=>`Total ${total} evaluations`,
115037
+ pageSizeOptions: [
115038
+ "10",
115039
+ "20",
115040
+ "50",
115041
+ "100"
115042
+ ],
115043
+ onChange: (page, size)=>serverPagination.onPageChange(page, size ?? serverPagination.pageSize)
115044
+ } : tableDataSource.length <= pageSize ? false : {
114972
115045
  pageSize,
114973
115046
  showSizeChanger: true,
114974
115047
  showTotal: (total)=>`Total ${total} evaluations`,
@@ -115004,7 +115077,7 @@ const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefres
115004
115077
  onClose: handleDrawerClose,
115005
115078
  evaluationId1: evaluationId1,
115006
115079
  evaluationId2: evaluationId2,
115007
- evaluations: normalized,
115080
+ evaluations: compareDrawerEvaluations,
115008
115081
  onEvaluationId1Change: onCompareUrlChange ? handleEvaluationId1Change : setEvaluationId1,
115009
115082
  onEvaluationId2Change: onCompareUrlChange ? handleEvaluationId2Change : setEvaluationId2
115010
115083
  }), !onRowClick && /*#__PURE__*/ React.createElement(EvaluationDetailsDrawer, {
package/dist/esm/index.js CHANGED
@@ -114682,27 +114682,19 @@ const EvaluationDetailsDrawer = ({ evaluation, open, onClose, getEvaluatorResult
114682
114682
  })))));
114683
114683
  };
114684
114684
 
114685
- const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefresh, onRowClick, onCompare, compareIdsFromUrl, onCompareUrlChange, showFilters = true, showCompare = true, emptyMessage, title })=>{
114685
+ const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefresh, onRowClick, onCompare, compareIdsFromUrl, onCompareUrlChange, showFilters = true, showCompare = true, emptyMessage, title, pagination: serverPagination, onFiltersChange, onFetchEvaluationsByIds })=>{
114686
114686
  const { theme } = useTheme$1();
114687
114687
  const [selectedAgents, setSelectedAgents] = useState([]);
114688
114688
  const [selectedRowKeys, setSelectedRowKeys] = useState([]);
114689
114689
  const [compareDrawerOpen, setCompareDrawerOpen] = useState(false);
114690
114690
  const [evaluationId1, setEvaluationId1] = useState(null);
114691
114691
  const [evaluationId2, setEvaluationId2] = useState(null);
114692
- // Sync drawer when compare param comes from URL
114693
- useEffect(()=>{
114694
- if (compareIdsFromUrl) {
114695
- setEvaluationId1(compareIdsFromUrl[0]);
114696
- setEvaluationId2(compareIdsFromUrl[1]);
114697
- setCompareDrawerOpen(true);
114698
- }
114699
- }, [
114700
- compareIdsFromUrl
114701
- ]);
114702
114692
  const [selectedEvaluation, setSelectedEvaluation] = useState(null);
114703
114693
  const [detailsDrawerOpen, setDetailsDrawerOpen] = useState(false);
114704
114694
  const [pageSize, setPageSize] = useState(50);
114705
114695
  const [selectedMetricFilter, setSelectedMetricFilter] = useState(null);
114696
+ const [drawerEvaluations, setDrawerEvaluations] = useState([]);
114697
+ const isServerPagination = !!serverPagination;
114706
114698
  const normalized = useMemo(()=>evaluations.map((e)=>isEvaluationDto(e) ? transformEvaluation(e) : e), [
114707
114699
  evaluations
114708
114700
  ]);
@@ -114751,6 +114743,63 @@ const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefres
114751
114743
  selectedAgents,
114752
114744
  selectedMetricFilter
114753
114745
  ]);
114746
+ const tableDataSource = filteredEvaluations;
114747
+ const compareDrawerEvaluations = useMemo(()=>{
114748
+ if (drawerEvaluations.length === 0) return normalized;
114749
+ const byId = new Map(normalized.map((e)=>[
114750
+ e.evaluation_id,
114751
+ e
114752
+ ]));
114753
+ for (const e of drawerEvaluations){
114754
+ const id = e.evaluation_id ?? e.evaluation_id;
114755
+ if (id && !byId.has(id)) byId.set(id, e);
114756
+ }
114757
+ return Array.from(byId.values());
114758
+ }, [
114759
+ normalized,
114760
+ drawerEvaluations
114761
+ ]);
114762
+ // Sync drawer when compare param comes from URL
114763
+ useEffect(()=>{
114764
+ if (compareIdsFromUrl) {
114765
+ setEvaluationId1(compareIdsFromUrl[0]);
114766
+ setEvaluationId2(compareIdsFromUrl[1]);
114767
+ setCompareDrawerOpen(true);
114768
+ }
114769
+ }, [
114770
+ compareIdsFromUrl
114771
+ ]);
114772
+ // Fetch evaluations by ID for compare drawer when opened from URL (server pagination)
114773
+ useEffect(()=>{
114774
+ if (!compareDrawerOpen || !onFetchEvaluationsByIds || !evaluationId1 || !evaluationId2) {
114775
+ setDrawerEvaluations([]);
114776
+ return;
114777
+ }
114778
+ const ids = [
114779
+ evaluationId1,
114780
+ evaluationId2
114781
+ ];
114782
+ const inNormalized = ids.every((id)=>normalized.some((e)=>e.evaluation_id === id));
114783
+ if (inNormalized) {
114784
+ setDrawerEvaluations([]);
114785
+ return;
114786
+ }
114787
+ let cancelled = false;
114788
+ onFetchEvaluationsByIds(ids).then((fetched)=>{
114789
+ if (!cancelled) {
114790
+ setDrawerEvaluations(fetched);
114791
+ }
114792
+ });
114793
+ return ()=>{
114794
+ cancelled = true;
114795
+ };
114796
+ }, [
114797
+ compareDrawerOpen,
114798
+ evaluationId1,
114799
+ evaluationId2,
114800
+ normalized,
114801
+ onFetchEvaluationsByIds
114802
+ ]);
114754
114803
  // Handle row selection - limit to 2 rows
114755
114804
  const handleRowSelectionChange = (selectedKeys)=>{
114756
114805
  if (selectedKeys.length <= 2) {
@@ -114902,7 +114951,12 @@ const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefres
114902
114951
  placeholder: "Filter by Agent",
114903
114952
  allowClear: true,
114904
114953
  value: selectedAgents,
114905
- onChange: setSelectedAgents,
114954
+ onChange: (v)=>{
114955
+ setSelectedAgents(v);
114956
+ if (isServerPagination && onFiltersChange) {
114957
+ onFiltersChange(v, selectedMetricFilter);
114958
+ }
114959
+ },
114906
114960
  style: {
114907
114961
  width: 200
114908
114962
  },
@@ -114914,7 +114968,13 @@ const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefres
114914
114968
  placeholder: "Filter by Evaluator / Metric",
114915
114969
  allowClear: true,
114916
114970
  value: selectedMetricFilter ?? undefined,
114917
- onChange: (v)=>setSelectedMetricFilter(v ?? null),
114971
+ onChange: (v)=>{
114972
+ const next = v ?? null;
114973
+ setSelectedMetricFilter(next);
114974
+ if (isServerPagination && onFiltersChange) {
114975
+ onFiltersChange(selectedAgents, next);
114976
+ }
114977
+ },
114918
114978
  style: {
114919
114979
  width: 240
114920
114980
  },
@@ -114937,7 +114997,7 @@ const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefres
114937
114997
  }
114938
114998
  }, emptyMessage ?? defaultEmptyMessage) : /*#__PURE__*/ React__default.createElement(ForwardTable, {
114939
114999
  columns: columns,
114940
- dataSource: filteredEvaluations,
115000
+ dataSource: tableDataSource,
114941
115001
  loading: loading,
114942
115002
  rowKey: "evaluation_id",
114943
115003
  rowSelection: showCompare ? {
@@ -114948,7 +115008,20 @@ const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefres
114948
115008
  disabled: selectedRowKeys.length >= 2 && !selectedRowKeys.includes(record.evaluation_id)
114949
115009
  })
114950
115010
  } : undefined,
114951
- pagination: filteredEvaluations.length <= pageSize ? false : {
115011
+ pagination: isServerPagination && serverPagination ? {
115012
+ total: serverPagination.total,
115013
+ current: serverPagination.current,
115014
+ pageSize: serverPagination.pageSize,
115015
+ showSizeChanger: true,
115016
+ showTotal: (total)=>`Total ${total} evaluations`,
115017
+ pageSizeOptions: [
115018
+ "10",
115019
+ "20",
115020
+ "50",
115021
+ "100"
115022
+ ],
115023
+ onChange: (page, size)=>serverPagination.onPageChange(page, size ?? serverPagination.pageSize)
115024
+ } : tableDataSource.length <= pageSize ? false : {
114952
115025
  pageSize,
114953
115026
  showSizeChanger: true,
114954
115027
  showTotal: (total)=>`Total ${total} evaluations`,
@@ -114984,7 +115057,7 @@ const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefres
114984
115057
  onClose: handleDrawerClose,
114985
115058
  evaluationId1: evaluationId1,
114986
115059
  evaluationId2: evaluationId2,
114987
- evaluations: normalized,
115060
+ evaluations: compareDrawerEvaluations,
114988
115061
  onEvaluationId1Change: onCompareUrlChange ? handleEvaluationId1Change : setEvaluationId1,
114989
115062
  onEvaluationId2Change: onCompareUrlChange ? handleEvaluationId2Change : setEvaluationId2
114990
115063
  }), !onRowClick && /*#__PURE__*/ React__default.createElement(EvaluationDetailsDrawer, {
@@ -14,6 +14,13 @@
14
14
  import React from "react";
15
15
  import type { Evaluation } from "../pages/evaluations.types";
16
16
  import type { Evaluation as EvaluationDto } from "../../dto/Evaluation";
17
+ /** Server-side pagination config. When provided, table uses server pagination instead of client. */
18
+ export interface EvaluationsTablePagination {
19
+ total: number;
20
+ current: number;
21
+ pageSize: number;
22
+ onPageChange: (page: number, pageSize: number) => void;
23
+ }
17
24
  export interface EvaluationsTableProps {
18
25
  /** Evaluation DTOs from your API. Pre-transformed data is also accepted. */
19
26
  evaluations: (Evaluation | EvaluationDto)[];
@@ -31,5 +38,11 @@ export interface EvaluationsTableProps {
31
38
  emptyMessage?: React.ReactNode;
32
39
  /** Optional title rendered to the left of the toolbar (e.g. "Evaluations") */
33
40
  title?: React.ReactNode;
41
+ /** Server-side pagination. When provided, table uses server pagination instead of client. */
42
+ pagination?: EvaluationsTablePagination;
43
+ /** When server pagination, filter changes are passed up for platform to refetch. */
44
+ onFiltersChange?: (agents: string[], metricFilter: string | null) => void;
45
+ /** When server pagination, fetch evaluations by ID for compare drawer (e.g. from URL). */
46
+ onFetchEvaluationsByIds?: (ids: string[]) => Promise<(Evaluation | EvaluationDto)[]>;
34
47
  }
35
48
  export declare const EvaluationsTable: React.FC<EvaluationsTableProps>;
@@ -2,6 +2,7 @@ export { default as AgenticFlowVisualizer } from "./components/AgenticFlowVisual
2
2
  export { default as Visualizer } from "./components/Visualizer";
3
3
  export { SessionDetails } from "./agenthub/pages/session-details";
4
4
  export { EvaluationsTable } from "./agenthub/components/EvaluationsTable";
5
+ export type { EvaluationsTableProps, EvaluationsTablePagination } from "./agenthub/components/EvaluationsTable";
5
6
  export { EvaluationsCompareView } from "./agenthub/components/EvaluationsCompareView";
6
7
  export type { EvaluationsCompareViewProps } from "./agenthub/components/EvaluationsCompareView";
7
8
  export { EvaluationsCompareDrawer } from "./agenthub/pages/evaluations-compare-drawer";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@railtownai/railtracks-visualizer",
3
- "version": "0.0.55",
3
+ "version": "0.0.56",
4
4
  "license": "MIT",
5
5
  "author": "Railtown AI",
6
6
  "description": "A visualizer for Railtracks agentic flows",