@@ -20,6 +20,7 @@ import {
2020 isModelCostUnknown ,
2121 type DailyTotals ,
2222 type HourlyTotals ,
23+ type MergedUsage ,
2324} from "@t3tools/shared/usageMerge" ;
2425
2526import { isElectron } from "../../env" ;
@@ -40,6 +41,7 @@ import {
4041 formatHourShort ,
4142 formatPercent ,
4243 formatTokens ,
44+ formatUsageContractMismatch ,
4345 formatUsd ,
4446 makeWindow ,
4547} from "@t3tools/shared/usageFormat" ;
@@ -314,7 +316,7 @@ export function UsagePage() {
314316 showUsageStatus = { ! showingLimits }
315317 isPartial = { isPartial }
316318 duplicateSources = { merged . duplicateSources }
317- staleEnvironments = { merged . staleEnvironments }
319+ contractMismatches = { merged . contractMismatches }
318320 />
319321 </ WorkspaceBreadcrumbItem >
320322 </ WorkspaceBreadcrumb >
@@ -899,17 +901,21 @@ function Metric({ label, value }: { readonly label: string; readonly value: stri
899901function UsageCoverageNotice ( {
900902 environments,
901903 duplicateSources,
902- staleEnvironments ,
904+ contractMismatches ,
903905} : {
904906 readonly environments : readonly EnvironmentUsageStatus [ ] ;
905907 readonly duplicateSources : readonly string [ ] ;
906- readonly staleEnvironments : readonly string [ ] ;
908+ readonly contractMismatches : MergedUsage [ "contractMismatches" ] ;
907909} ) {
908910 const failed = environments . filter ( ( environment ) => environment . error !== null ) ;
909- const stale = environments . filter ( ( environment ) =>
910- staleEnvironments . includes ( environment . environmentId ) ,
911+ const mismatchByEnvironment = new Map (
912+ contractMismatches . map ( ( mismatch ) => [ mismatch . environmentId , mismatch ] ) ,
911913 ) ;
912- if ( failed . length === 0 && stale . length === 0 && duplicateSources . length === 0 ) {
914+ const incompatible = environments . flatMap ( ( environment ) => {
915+ const mismatch = mismatchByEnvironment . get ( environment . environmentId ) ;
916+ return mismatch === undefined ? [ ] : [ { environment, mismatch } ] ;
917+ } ) ;
918+ if ( failed . length === 0 && incompatible . length === 0 && duplicateSources . length === 0 ) {
913919 return null ;
914920 }
915921
@@ -918,9 +924,9 @@ function UsageCoverageNotice({
918924 { failed . map ( ( environment ) => (
919925 < span key = { environment . label } > { environment . label } could not report usage.</ span >
920926 ) ) }
921- { stale . map ( ( environment ) => (
922- < span key = { environment . label } >
923- { environment . label } runs an older server version and is excluded from totals.
927+ { incompatible . map ( ( { environment, mismatch } ) => (
928+ < span key = { environment . environmentId } >
929+ { formatUsageContractMismatch ( environment . label , mismatch ) }
924930 </ span >
925931 ) ) }
926932 { duplicateSources . length > 0 ? (
@@ -942,7 +948,7 @@ function UsageEnvironmentFilter({
942948 showUsageStatus,
943949 isPartial,
944950 duplicateSources,
945- staleEnvironments ,
951+ contractMismatches ,
946952} : {
947953 readonly environments : readonly EnvironmentUsageStatus [ ] ;
948954 readonly selectedEnvironments : readonly EnvironmentUsageStatus [ ] ;
@@ -951,7 +957,7 @@ function UsageEnvironmentFilter({
951957 readonly showUsageStatus : boolean ;
952958 readonly isPartial : boolean ;
953959 readonly duplicateSources : readonly string [ ] ;
954- readonly staleEnvironments : readonly string [ ] ;
960+ readonly contractMismatches : MergedUsage [ "contractMismatches" ] ;
955961} ) {
956962 const [ modelPricesOpen , setModelPricesOpen ] = useState ( false ) ;
957963 const allSelected = selectedEnvironmentIds === null ;
@@ -966,7 +972,7 @@ function UsageEnvironmentFilter({
966972 ) . length ;
967973 const hasIssue =
968974 selectedEnvironments . some ( ( environment ) => environment . error !== null ) ||
969- staleEnvironments . length > 0 ;
975+ contractMismatches . length > 0 ;
970976
971977 return (
972978 < >
@@ -1066,7 +1072,7 @@ function UsageEnvironmentFilter({
10661072 < UsageCoverageNotice
10671073 environments = { selectedEnvironments }
10681074 duplicateSources = { duplicateSources }
1069- staleEnvironments = { staleEnvironments }
1075+ contractMismatches = { contractMismatches }
10701076 />
10711077 ) : null }
10721078 < MenuSeparator />
0 commit comments