@mastra/playground-ui 71.0.0-alpha.7 → 71.0.0-alpha.9

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.
Files changed (71) hide show
  1. package/dist/domains/agents/chat/stream-error-message.cjs.js +13 -6
  2. package/dist/domains/agents/chat/stream-error-message.cjs.js.map +1 -1
  3. package/dist/domains/agents/chat/stream-error-message.es.js +13 -6
  4. package/dist/domains/agents/chat/stream-error-message.es.js.map +1 -1
  5. package/dist/domains/agents/chat/use-chat-send-handler.cjs.js +4 -1
  6. package/dist/domains/agents/chat/use-chat-send-handler.cjs.js.map +1 -1
  7. package/dist/domains/agents/chat/use-chat-send-handler.es.js +4 -1
  8. package/dist/domains/agents/chat/use-chat-send-handler.es.js.map +1 -1
  9. package/dist/domains/dashboards/components/stateless-widget.cjs.js.map +1 -1
  10. package/dist/domains/dashboards/components/stateless-widget.es.js.map +1 -1
  11. package/dist/domains/dashboards/components/view-tabs.cjs.js +30 -0
  12. package/dist/domains/dashboards/components/view-tabs.cjs.js.map +1 -0
  13. package/dist/domains/dashboards/components/view-tabs.d.ts +1 -0
  14. package/dist/domains/dashboards/components/view-tabs.es.js +29 -0
  15. package/dist/domains/dashboards/components/view-tabs.es.js.map +1 -0
  16. package/dist/domains/dashboards/hooks/use-widget-views.cjs.js +24 -5
  17. package/dist/domains/dashboards/hooks/use-widget-views.cjs.js.map +1 -1
  18. package/dist/domains/dashboards/hooks/use-widget-views.es.js +24 -6
  19. package/dist/domains/dashboards/hooks/use-widget-views.es.js.map +1 -1
  20. package/dist/domains/dashboards/kinds/scores/scores-widget.cjs.js +2 -2
  21. package/dist/domains/dashboards/kinds/scores/scores-widget.cjs.js.map +1 -1
  22. package/dist/domains/dashboards/kinds/scores/scores-widget.es.js +1 -1
  23. package/dist/domains/dashboards/kinds/scores/scores-widget.es.js.map +1 -1
  24. package/dist/domains/dashboards/kinds/table/table-tabs.cjs.js +0 -11
  25. package/dist/domains/dashboards/kinds/table/table-tabs.cjs.js.map +1 -1
  26. package/dist/domains/dashboards/kinds/table/table-tabs.es.js +0 -11
  27. package/dist/domains/dashboards/kinds/table/table-tabs.es.js.map +1 -1
  28. package/dist/domains/dashboards/kinds/table/table-widget.cjs.js.map +1 -1
  29. package/dist/domains/dashboards/kinds/table/table-widget.es.js.map +1 -1
  30. package/dist/domains/dashboards/kinds/timeseries/timeseries-widget.cjs.js +1 -1
  31. package/dist/domains/dashboards/kinds/timeseries/timeseries-widget.cjs.js.map +1 -1
  32. package/dist/domains/dashboards/kinds/timeseries/timeseries-widget.es.js +1 -1
  33. package/dist/domains/dashboards/kinds/timeseries/timeseries-widget.es.js.map +1 -1
  34. package/dist/domains/dashboards/lib/chrome.cjs.js +1 -23
  35. package/dist/domains/dashboards/lib/chrome.cjs.js.map +1 -1
  36. package/dist/domains/dashboards/lib/chrome.es.js +2 -23
  37. package/dist/domains/dashboards/lib/chrome.es.js.map +1 -1
  38. package/dist/domains/dashboards/lib/view-labels.cjs.js +9 -7
  39. package/dist/domains/dashboards/lib/view-labels.cjs.js.map +1 -1
  40. package/dist/domains/dashboards/lib/view-labels.es.js +9 -7
  41. package/dist/domains/dashboards/lib/view-labels.es.js.map +1 -1
  42. package/dist/domains/dashboards/metrics-dashboard.cjs.js +1 -1
  43. package/dist/domains/dashboards/metrics-dashboard.cjs.js.map +1 -1
  44. package/dist/domains/dashboards/metrics-dashboard.es.js +1 -1
  45. package/dist/domains/dashboards/metrics-dashboard.es.js.map +1 -1
  46. package/dist/domains/dashboards/widget-kind.cjs.js.map +1 -1
  47. package/dist/domains/dashboards/widget-kind.es.js.map +1 -1
  48. package/dist/domains/dashboards.cjs.js +1 -1
  49. package/dist/domains/dashboards.es.js +1 -1
  50. package/dist/domains/metrics/components/breakdown/breakdown-table.cjs.js +2 -2
  51. package/dist/domains/metrics/components/breakdown/breakdown-table.cjs.js.map +1 -1
  52. package/dist/domains/metrics/components/breakdown/breakdown-table.es.js +2 -2
  53. package/dist/domains/metrics/components/breakdown/breakdown-table.es.js.map +1 -1
  54. package/dist/domains/metrics/components/distinct-ids/distinct-ids-chart.cjs.js +4 -2
  55. package/dist/domains/metrics/components/distinct-ids/distinct-ids-chart.cjs.js.map +1 -1
  56. package/dist/domains/metrics/components/distinct-ids/distinct-ids-chart.es.js +4 -2
  57. package/dist/domains/metrics/components/distinct-ids/distinct-ids-chart.es.js.map +1 -1
  58. package/dist/src/domains/agents/chat/stream-error-message.d.ts +16 -11
  59. package/dist/src/domains/dashboards/components/stateless-widget.d.ts +1 -2
  60. package/dist/src/domains/dashboards/components/view-tabs.d.ts +13 -0
  61. package/dist/src/domains/dashboards/hooks/use-widget-views.d.ts +11 -5
  62. package/dist/src/domains/dashboards/lib/chrome.d.ts +4 -13
  63. package/dist/src/domains/dashboards/lib/view-labels.d.ts +3 -3
  64. package/dist/src/domains/dashboards/widget-kind.d.ts +2 -3
  65. package/package.json +12 -11
  66. package/dist/domains/dashboards/kinds/table/table-view-tabs.cjs.js +0 -32
  67. package/dist/domains/dashboards/kinds/table/table-view-tabs.cjs.js.map +0 -1
  68. package/dist/domains/dashboards/kinds/table/table-view-tabs.d.ts +0 -1
  69. package/dist/domains/dashboards/kinds/table/table-view-tabs.es.js +0 -31
  70. package/dist/domains/dashboards/kinds/table/table-view-tabs.es.js.map +0 -1
  71. package/dist/src/domains/dashboards/kinds/table/table-view-tabs.d.ts +0 -14
@@ -1 +1 @@
1
- {"version":3,"file":"breakdown-table.es.js","names":[],"sources":["../../../../../src/domains/metrics/components/breakdown/breakdown-table.tsx"],"sourcesContent":["import type { AggregateTracesResponse } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useState } from 'react';\nimport { useMetricsScope } from '../../hooks/use-metrics-scope';\nimport type { useMetricsUsageTotals } from '../../hooks/use-metrics-usage-totals';\nimport { buildBreakdownRows, hasErrors, previousFigures, rowChange, threadResources } from '../../lib/breakdown';\nimport type { BreakdownRow, BreakdownTab, ChangeMetric } from '../../lib/breakdown';\nimport {\n DASH,\n comparedLabel,\n countDescription,\n drilldownFor,\n isChangeMetric,\n showsProject,\n tableRows,\n volumeLabel,\n} from '../../lib/breakdown-table';\nimport { formatCount, formatDuration, formatPercent } from '../../lib/chart-format';\nimport { ChartArea } from '../chart-area';\nimport { ChartCardError } from '../chart-card-error';\nimport { BreakdownChangeCell } from './breakdown-change-cell';\nimport { BreakdownChangeDescription } from './breakdown-change-description';\nimport { BreakdownCostCell } from './breakdown-cost-cell';\nimport { BreakdownFigure } from './breakdown-figure';\nimport { BreakdownFrame } from './breakdown-frame';\nimport type { BreakdownFrameProps } from './breakdown-frame';\nimport { BreakdownRowName } from './breakdown-row-name';\nimport { BreakdownText } from './breakdown-text';\nimport { MetricsTable } from '@/ds/components/MetricsTable';\nimport type { MetricsTableColumn, MetricsTableSort } from '@/ds/components/MetricsTable';\nimport { Txt } from '@/ds/components/Txt';\n\ntype UsageTotals = ReturnType<typeof useMetricsUsageTotals>;\n\nconst PAGE_SIZE = 10;\n\n/** Busiest first; where a third click on a column's header returns to. */\nconst DEFAULT_SORT: MetricsTableSort = { column: 'count', direction: 'desc' };\n\n/** The first column's header: what each row is. */\nconst NAME_HEADER: Record<BreakdownTab, string> = {\n projects: 'Project',\n agents: 'Agent',\n workflows: 'Workflow',\n tools: 'Tool',\n models: 'Model',\n threads: 'Thread',\n environments: 'Environment',\n};\n\nconst EMPTY: Record<BreakdownTab, string> = {\n projects: 'No traces in this range.',\n agents: 'No agent runs in this range.',\n workflows: 'No workflow runs in this range.',\n tools: 'No tool calls in this range.',\n models: 'No model usage in this range.',\n threads: 'No traces with a thread in this range.',\n environments: 'No traces in this range.',\n};\n\nexport type BreakdownTableProps = BreakdownFrameProps & {\n tab: BreakdownTab;\n groupBy: string[];\n window: { start: Date; end: Date };\n aggregate?: UseQueryResult<AggregateTracesResponse>;\n /** Tokens and cost per row. */\n totals?: UsageTotals;\n /** Model spans per row (Models tab). */\n spans?: UsageTotals;\n /** Rows naming each thread's resource (Threads tab). */\n resources?: UseQueryResult<AggregateTracesResponse>;\n previousAggregate?: UseQueryResult<AggregateTracesResponse>;\n previousUsage?: UsageTotals;\n previousSpans?: UsageTotals;\n /** The server's row cap, named when it truncates. */\n limit: number;\n};\n\n/** One tab's sortable table, with % Change against the previous window. */\nexport function BreakdownTable({\n tab,\n groupBy,\n window,\n aggregate,\n totals,\n spans,\n resources,\n previousAggregate,\n previousUsage,\n previousSpans,\n limit,\n ...frame\n}: BreakdownTableProps) {\n const scope = useMetricsScope();\n const [sort, setSort] = useState<MetricsTableSort>(DEFAULT_SORT);\n const [metric, setMetric] = useState<ChangeMetric>('count');\n const onSortChange = (next = DEFAULT_SORT) => {\n setSort(next);\n if (isChangeMetric(next.column)) setMetric(next.column);\n };\n\n const current = [aggregate, totals, spans].filter(q => q !== undefined);\n if (current.some(q => q.isError)) {\n return (\n <BreakdownFrame {...frame} tab={tab}>\n <ChartCardError onRetry={() => current.forEach(q => q.isError && void q.refetch())} />\n </BreakdownFrame>\n );\n }\n\n const isLoading = current.some(q => q.isLoading);\n const errors = hasErrors(tab);\n const usage = totals !== undefined;\n const project = showsProject(tab, frame.byProject);\n const truncated = aggregate?.data?.truncated === true;\n const built = isLoading\n ? []\n : buildBreakdownRows({\n tab,\n groupBy,\n aggregateRows: aggregate?.data?.rows,\n usageGroups: totals?.data?.groups,\n spanGroups: spans?.data?.groups,\n // The resource is a nicety: the table doesn't wait for it, and shows a dash without it.\n resources: resources?.data ? threadResources(resources.data.rows) : undefined,\n });\n // The previous window never holds the table up: until it answers, or if it fails, Change shows a dash.\n const previousSettled = [previousAggregate, previousUsage, previousSpans].every(\n q => !q || (!q.isLoading && !q.isError),\n );\n const previous =\n previousSettled && !isLoading\n ? previousFigures({\n tab,\n groupBy,\n aggregateRows: previousAggregate?.data?.rows,\n usageGroups: previousUsage?.data?.groups,\n spanGroups: previousSpans?.data?.groups,\n })\n : undefined;\n const rows = tableRows({ tab, built, previous, truncated, groupBy, usage });\n const volume = volumeLabel(tab);\n\n const changeOf = (row: BreakdownRow) => (previous ? rowChange(row, previous.get(row.key), metric) : undefined);\n const projectName = (row: BreakdownRow) => {\n if (!row.projectId) return DASH;\n return scope.projectLabel?.(row.projectId) ?? row.projectId;\n };\n\n const nameColumn: MetricsTableColumn<BreakdownRow> = {\n id: 'name',\n header: NAME_HEADER[tab],\n width: 'minmax(12rem,3fr)',\n cell: row => <BreakdownRowName tab={tab} row={row} />,\n };\n const projectColumn: MetricsTableColumn<BreakdownRow> = {\n id: 'project',\n header: 'Project',\n width: 'minmax(8rem,2fr)',\n cell: row => <BreakdownText text={projectName(row)} />,\n };\n const resourceColumn: MetricsTableColumn<BreakdownRow> = {\n id: 'resource',\n header: 'Resource',\n width: 'minmax(6rem,1fr)',\n cell: row => <BreakdownText text={row.resource ?? DASH} />,\n };\n const errorColumns: MetricsTableColumn<BreakdownRow>[] = [\n {\n id: 'errorRate',\n header: 'Errors',\n align: 'end',\n sortValue: row => row.errorRate,\n cell: row => (\n <BreakdownFigure muted>{row.errorRate === undefined ? DASH : formatPercent(row.errorRate)}</BreakdownFigure>\n ),\n },\n {\n id: 'p95',\n header: 'P95 latency',\n align: 'end',\n sortValue: row => row.p95,\n cell: row => <BreakdownFigure muted>{row.p95 === undefined ? DASH : formatDuration(row.p95)}</BreakdownFigure>,\n },\n ];\n const usageColumns: MetricsTableColumn<BreakdownRow>[] = [\n {\n id: 'tokens',\n header: 'Tokens',\n align: 'end',\n sortValue: row => row.tokens,\n cell: row => <BreakdownFigure muted>{row.tokens === undefined ? DASH : formatCount(row.tokens)}</BreakdownFigure>,\n },\n {\n id: 'cost',\n header: 'Cost',\n align: 'end',\n sortValue: row => row.cost,\n cell: row => (\n <BreakdownFigure muted>\n <BreakdownCostCell row={row} />\n </BreakdownFigure>\n ),\n },\n ];\n const countColumn: MetricsTableColumn<BreakdownRow> = {\n id: 'count',\n header: volume,\n align: 'end',\n description: countDescription(tab),\n sortValue: row => row.count,\n cell: row => <BreakdownFigure>{formatCount(row.count)}</BreakdownFigure>,\n };\n const changeColumn: MetricsTableColumn<BreakdownRow> = {\n id: 'change',\n header: '% Change',\n align: 'end',\n description: <BreakdownChangeDescription window={window} label={comparedLabel(tab, metric)} />,\n // Sorted by the change shown: biggest rise first, biggest fall first the other way. New rows\n // have no change to rank, so they sort last.\n sortValue: row => changeOf(row)?.change,\n cell: row => (\n <BreakdownFigure>\n <BreakdownChangeCell change={changeOf(row)} metric={metric} />\n </BreakdownFigure>\n ),\n };\n const columns = [\n nameColumn,\n ...(project ? [projectColumn] : []),\n ...(tab === 'threads' ? [resourceColumn] : []),\n ...(errors ? errorColumns : []),\n ...(usage ? usageColumns : []),\n countColumn,\n changeColumn,\n ];\n\n return (\n <BreakdownFrame {...frame} tab={tab} isUpdating={aggregate?.isPlaceholderData}>\n <ChartArea>\n <MetricsTable\n key={tab}\n aria-label={`${NAME_HEADER[tab]} breakdown`}\n columns={columns}\n rows={rows}\n getRowKey={row => row.key}\n sort={sort}\n defaultSort={DEFAULT_SORT}\n onSortChange={onSortChange}\n onRowClick={frame.onRowClick && (row => frame.onRowClick?.(drilldownFor(tab, row)))}\n pageSize={PAGE_SIZE}\n isLoading={isLoading}\n empty={EMPTY[tab]}\n />\n {!isLoading && truncated && (\n <Txt variant=\"caption\" tone=\"muted\" className=\"pt-2\">\n Showing the {formatCount(limit)} busiest; sorting covers only these.\n </Txt>\n )}\n </ChartArea>\n </BreakdownFrame>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkCA,IAAM,YAAY;;AAGlB,IAAM,eAAiC;CAAE,QAAQ;CAAS,WAAW;AAAO;;AAG5E,IAAM,cAA4C;CAChD,UAAU;CACV,QAAQ;CACR,WAAW;CACX,OAAO;CACP,QAAQ;CACR,SAAS;CACT,cAAc;AAChB;AAEA,IAAM,QAAsC;CAC1C,UAAU;CACV,QAAQ;CACR,WAAW;CACX,OAAO;CACP,QAAQ;CACR,SAAS;CACT,cAAc;AAChB;;AAqBA,SAAgB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;GACC;GACX,OAAO,MAAM;EACd,GAZM,GAYN,GACA,CAAC,aAAa,aACb,qBAAC,KAAD;GAAK,SAAQ;GAAU,MAAK;GAAQ,WAAU;GAA9C,UAAA;IAAqD;IACtC,YAAY,KAAK;IAAE;GAC7B;EAEE,CAAA,CAAA,EAAA,CAAA;CACG,CAAA;AAEpB"}
1
+ {"version":3,"file":"breakdown-table.es.js","names":[],"sources":["../../../../../src/domains/metrics/components/breakdown/breakdown-table.tsx"],"sourcesContent":["import type { AggregateTracesResponse } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useState } from 'react';\nimport { useMetricsScope } from '../../hooks/use-metrics-scope';\nimport type { useMetricsUsageTotals } from '../../hooks/use-metrics-usage-totals';\nimport { buildBreakdownRows, hasErrors, previousFigures, rowChange, threadResources } from '../../lib/breakdown';\nimport type { BreakdownRow, BreakdownTab, ChangeMetric } from '../../lib/breakdown';\nimport {\n DASH,\n comparedLabel,\n countDescription,\n drilldownFor,\n isChangeMetric,\n showsProject,\n tableRows,\n volumeLabel,\n} from '../../lib/breakdown-table';\nimport { formatCount, formatDuration, formatPercent } from '../../lib/chart-format';\nimport { ChartArea } from '../chart-area';\nimport { ChartCardError } from '../chart-card-error';\nimport { BreakdownChangeCell } from './breakdown-change-cell';\nimport { BreakdownChangeDescription } from './breakdown-change-description';\nimport { BreakdownCostCell } from './breakdown-cost-cell';\nimport { BreakdownFigure } from './breakdown-figure';\nimport { BreakdownFrame } from './breakdown-frame';\nimport type { BreakdownFrameProps } from './breakdown-frame';\nimport { BreakdownRowName } from './breakdown-row-name';\nimport { BreakdownText } from './breakdown-text';\nimport { MetricsTable } from '@/ds/components/MetricsTable';\nimport type { MetricsTableColumn, MetricsTableSort } from '@/ds/components/MetricsTable';\nimport { Txt } from '@/ds/components/Txt';\n\ntype UsageTotals = ReturnType<typeof useMetricsUsageTotals>;\n\nconst PAGE_SIZE = 10;\n\n/** Busiest first; where a third click on a column's header returns to. */\nconst DEFAULT_SORT: MetricsTableSort = { column: 'count', direction: 'desc' };\n\n/** The first column's header: what each row is. */\nconst NAME_HEADER: Record<BreakdownTab, string> = {\n projects: 'Project',\n agents: 'Agent',\n workflows: 'Workflow',\n tools: 'Tool',\n models: 'Model',\n threads: 'Thread',\n environments: 'Environment',\n};\n\nconst EMPTY: Record<BreakdownTab, string> = {\n projects: 'No traces in this range.',\n agents: 'No agent runs in this range.',\n workflows: 'No workflow runs in this range.',\n tools: 'No tool calls in this range.',\n models: 'No model usage in this range.',\n threads: 'No traces with a thread in this range.',\n environments: 'No traces in this range.',\n};\n\nexport type BreakdownTableProps = BreakdownFrameProps & {\n tab: BreakdownTab;\n groupBy: string[];\n window: { start: Date; end: Date };\n aggregate?: UseQueryResult<AggregateTracesResponse>;\n /** Tokens and cost per row. */\n totals?: UsageTotals;\n /** Model spans per row (Models tab). */\n spans?: UsageTotals;\n /** Rows naming each thread's resource (Threads tab). */\n resources?: UseQueryResult<AggregateTracesResponse>;\n previousAggregate?: UseQueryResult<AggregateTracesResponse>;\n previousUsage?: UsageTotals;\n previousSpans?: UsageTotals;\n /** The server's row cap, named when it truncates. */\n limit: number;\n};\n\n/** One tab's sortable table, with % Change against the previous window. */\nexport function BreakdownTable({\n tab,\n groupBy,\n window,\n aggregate,\n totals,\n spans,\n resources,\n previousAggregate,\n previousUsage,\n previousSpans,\n limit,\n ...frame\n}: BreakdownTableProps) {\n const scope = useMetricsScope();\n const [sort, setSort] = useState<MetricsTableSort>(DEFAULT_SORT);\n const [metric, setMetric] = useState<ChangeMetric>('count');\n const onSortChange = (next = DEFAULT_SORT) => {\n setSort(next);\n if (isChangeMetric(next.column)) setMetric(next.column);\n };\n\n const current = [aggregate, totals, spans].filter(q => q !== undefined);\n const isLoading = current.some(q => q.isLoading);\n // One request failing says nothing about the others, which may still be running: report the\n // failure only once they have all settled, or Retry — which re-sends only the failed ones —\n // cannot recover a card whose remaining request is still in flight. A new scope keeps the\n // previous answer on screen, so `isLoading` is false there while `isFetching` is not.\n if (!current.some(q => q.isFetching) && current.some(q => q.isError)) {\n return (\n <BreakdownFrame {...frame} tab={tab}>\n <ChartCardError onRetry={() => current.forEach(q => q.isError && void q.refetch())} />\n </BreakdownFrame>\n );\n }\n\n const errors = hasErrors(tab);\n const usage = totals !== undefined;\n const project = showsProject(tab, frame.byProject);\n const truncated = aggregate?.data?.truncated === true;\n const built = isLoading\n ? []\n : buildBreakdownRows({\n tab,\n groupBy,\n aggregateRows: aggregate?.data?.rows,\n usageGroups: totals?.data?.groups,\n spanGroups: spans?.data?.groups,\n // The resource is a nicety: the table doesn't wait for it, and shows a dash without it.\n resources: resources?.data ? threadResources(resources.data.rows) : undefined,\n });\n // The previous window never holds the table up: until it answers, or if it fails, Change shows a dash.\n const previousSettled = [previousAggregate, previousUsage, previousSpans].every(\n q => !q || (!q.isLoading && !q.isError),\n );\n const previous =\n previousSettled && !isLoading\n ? previousFigures({\n tab,\n groupBy,\n aggregateRows: previousAggregate?.data?.rows,\n usageGroups: previousUsage?.data?.groups,\n spanGroups: previousSpans?.data?.groups,\n })\n : undefined;\n const rows = tableRows({ tab, built, previous, truncated, groupBy, usage });\n const volume = volumeLabel(tab);\n\n const changeOf = (row: BreakdownRow) => (previous ? rowChange(row, previous.get(row.key), metric) : undefined);\n const projectName = (row: BreakdownRow) => {\n if (!row.projectId) return DASH;\n return scope.projectLabel?.(row.projectId) ?? row.projectId;\n };\n\n const nameColumn: MetricsTableColumn<BreakdownRow> = {\n id: 'name',\n header: NAME_HEADER[tab],\n width: 'minmax(12rem,3fr)',\n cell: row => <BreakdownRowName tab={tab} row={row} />,\n };\n const projectColumn: MetricsTableColumn<BreakdownRow> = {\n id: 'project',\n header: 'Project',\n width: 'minmax(8rem,2fr)',\n cell: row => <BreakdownText text={projectName(row)} />,\n };\n const resourceColumn: MetricsTableColumn<BreakdownRow> = {\n id: 'resource',\n header: 'Resource',\n width: 'minmax(6rem,1fr)',\n cell: row => <BreakdownText text={row.resource ?? DASH} />,\n };\n const errorColumns: MetricsTableColumn<BreakdownRow>[] = [\n {\n id: 'errorRate',\n header: 'Errors',\n align: 'end',\n sortValue: row => row.errorRate,\n cell: row => (\n <BreakdownFigure muted>{row.errorRate === undefined ? DASH : formatPercent(row.errorRate)}</BreakdownFigure>\n ),\n },\n {\n id: 'p95',\n header: 'P95 latency',\n align: 'end',\n sortValue: row => row.p95,\n cell: row => <BreakdownFigure muted>{row.p95 === undefined ? DASH : formatDuration(row.p95)}</BreakdownFigure>,\n },\n ];\n const usageColumns: MetricsTableColumn<BreakdownRow>[] = [\n {\n id: 'tokens',\n header: 'Tokens',\n align: 'end',\n sortValue: row => row.tokens,\n cell: row => <BreakdownFigure muted>{row.tokens === undefined ? DASH : formatCount(row.tokens)}</BreakdownFigure>,\n },\n {\n id: 'cost',\n header: 'Cost',\n align: 'end',\n sortValue: row => row.cost,\n cell: row => (\n <BreakdownFigure muted>\n <BreakdownCostCell row={row} />\n </BreakdownFigure>\n ),\n },\n ];\n const countColumn: MetricsTableColumn<BreakdownRow> = {\n id: 'count',\n header: volume,\n align: 'end',\n description: countDescription(tab),\n sortValue: row => row.count,\n cell: row => <BreakdownFigure>{formatCount(row.count)}</BreakdownFigure>,\n };\n const changeColumn: MetricsTableColumn<BreakdownRow> = {\n id: 'change',\n header: '% Change',\n align: 'end',\n description: <BreakdownChangeDescription window={window} label={comparedLabel(tab, metric)} />,\n // Sorted by the change shown: biggest rise first, biggest fall first the other way. New rows\n // have no change to rank, so they sort last.\n sortValue: row => changeOf(row)?.change,\n cell: row => (\n <BreakdownFigure>\n <BreakdownChangeCell change={changeOf(row)} metric={metric} />\n </BreakdownFigure>\n ),\n };\n const columns = [\n nameColumn,\n ...(project ? [projectColumn] : []),\n ...(tab === 'threads' ? [resourceColumn] : []),\n ...(errors ? errorColumns : []),\n ...(usage ? usageColumns : []),\n countColumn,\n changeColumn,\n ];\n\n return (\n <BreakdownFrame {...frame} tab={tab} isUpdating={aggregate?.isPlaceholderData}>\n <ChartArea>\n <MetricsTable\n key={tab}\n aria-label={`${NAME_HEADER[tab]} breakdown`}\n columns={columns}\n rows={rows}\n getRowKey={row => row.key}\n sort={sort}\n defaultSort={DEFAULT_SORT}\n onSortChange={onSortChange}\n onRowClick={frame.onRowClick && (row => frame.onRowClick?.(drilldownFor(tab, row)))}\n pageSize={PAGE_SIZE}\n isLoading={isLoading}\n empty={EMPTY[tab]}\n />\n {!isLoading && truncated && (\n <Txt variant=\"caption\" tone=\"muted\" className=\"pt-2\">\n Showing the {formatCount(limit)} busiest; sorting covers only these.\n </Txt>\n )}\n </ChartArea>\n </BreakdownFrame>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkCA,IAAM,YAAY;;AAGlB,IAAM,eAAiC;CAAE,QAAQ;CAAS,WAAW;AAAO;;AAG5E,IAAM,cAA4C;CAChD,UAAU;CACV,QAAQ;CACR,WAAW;CACX,OAAO;CACP,QAAQ;CACR,SAAS;CACT,cAAc;AAChB;AAEA,IAAM,QAAsC;CAC1C,UAAU;CACV,QAAQ;CACR,WAAW;CACX,OAAO;CACP,QAAQ;CACR,SAAS;CACT,cAAc;AAChB;;AAqBA,SAAgB,eAAe,EAC7B,KACA,SACA,QACA,WACA,QACA,OACA,WACA,mBACA,eACA,eACA,OACA,GAAG,SACmB;CACtB,MAAM,QAAQ,gBAAgB;CAC9B,MAAM,CAAC,MAAM,WAAW,SAA2B,YAAY;CAC/D,MAAM,CAAC,QAAQ,aAAa,SAAuB,OAAO;CAC1D,MAAM,gBAAgB,OAAO,iBAAiB;EAC5C,QAAQ,IAAI;EACZ,IAAI,eAAe,KAAK,MAAM,GAAG,UAAU,KAAK,MAAM;CACxD;CAEA,MAAM,UAAU;EAAC;EAAW;EAAQ;CAAK,CAAC,CAAC,QAAO,MAAK,MAAM,KAAA,CAAS;CACtE,MAAM,YAAY,QAAQ,MAAK,MAAK,EAAE,SAAS;CAK/C,IAAI,CAAC,QAAQ,MAAK,MAAK,EAAE,UAAU,KAAK,QAAQ,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M,eAAiD;EACrD,IAAI;EACJ,QAAQ;EACR,OAAO;EACP,aAAa,oBAAC,4BAAD;GAAoC;GAAQ,OAAO,cAAc,KAAK,MAAM;EAAI,CAAA;EAG7F,YAAW,QAAO,SAAS,GAAG,CAAC,EAAE;EACjC,OAAM,QACJ,oBAAC,iBAAD,EAAA,UACE,oBAAC,qBAAD;GAAqB,QAAQ,SAAS,GAAG;GAAW;EAAS,CAAA,EAC9C,CAAA;CAErB;CACA,MAAM,UAAU;EACd;EACA,GAAI,UAAU,CAAC,aAAa,IAAI,CAAC;EACjC,GAAI,QAAQ,YAAY,CAAC,cAAc,IAAI,CAAC;EAC5C,GAAI,SAAS,eAAe,CAAC;EAC7B,GAAI,QAAQ,eAAe,CAAC;EAC5B;EACA;CACF;CAEA,OACE,oBAAC,gBAAD;EAAgB,GAAI;EAAY;EAAK,YAAY,WAAW;EAC1D,UAAA,qBAAC,WAAD,EAAA,UAAA,CACE,oBAAC,cAAD;GAEE,cAAY,GAAG,YAAY,KAAK;GACvB;GACH;GACN,YAAW,QAAO,IAAI;GAChB;GACN,aAAa;GACC;GACd,YAAY,MAAM,gBAAe,QAAO,MAAM,aAAa,aAAa,KAAK,GAAG,CAAC;GACjF,UAAU;GACC;GACX,OAAO,MAAM;EACd,GAZM,GAYN,GACA,CAAC,aAAa,aACb,qBAAC,KAAD;GAAK,SAAQ;GAAU,MAAK;GAAQ,WAAU;GAA9C,UAAA;IAAqD;IACtC,YAAY,KAAK;IAAE;GAC7B;EAEE,CAAA,CAAA,EAAA,CAAA;CACG,CAAA;AAEpB"}
@@ -73,6 +73,8 @@ function DistinctIdsChart({ scope, onTimeRangeClick }) {
73
73
  const step = require_domains_metrics_lib_metrics_buckets.intervalHours(scope.interval === "1d" ? "1d" : "1h");
74
74
  const error = series.error ?? totals.error;
75
75
  const isLoading = series.isLoading || totals.isLoading;
76
+ const isFetching = series.isFetching || totals.isFetching;
77
+ const hasFailed = Boolean(error) && !isFetching;
76
78
  const layout = {
77
79
  title: DISTINCT_IDS_TITLE,
78
80
  total: error ? void 0 : shown.length ? shown.map((id) => ({
@@ -83,7 +85,7 @@ function DistinctIdsChart({ scope, onTimeRangeClick }) {
83
85
  isLoading: totals.isLoading,
84
86
  toolbar: lines.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MetricsCard.MetricsCard.Toolbar, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MetricsLineChart.MetricsLineChartLegend, { series: lines }) })
85
87
  };
86
- if (error) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_domains_metrics_components_chart_card.ChartCard, {
88
+ if (hasFailed) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_domains_metrics_components_chart_card.ChartCard, {
87
89
  ...layout,
88
90
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_domains_metrics_components_chart_card_error.ChartCardError, {
89
91
  error,
@@ -97,7 +99,7 @@ function DistinctIdsChart({ scope, onTimeRangeClick }) {
97
99
  ...layout,
98
100
  isUpdating: series.isPlaceholderData || totals.isPlaceholderData,
99
101
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_domains_metrics_components_chart_area.ChartArea, {
100
- isEmpty: !isLoading && shown.length === 0,
102
+ isEmpty: !isLoading && !error && shown.length === 0,
101
103
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MetricsLineChart.MetricsLineChart, {
102
104
  lineStyle: "thin",
103
105
  data: chart,
@@ -1 +1 @@
1
- {"version":3,"file":"distinct-ids-chart.cjs.js","names":["CHART_COLORS","useMetricsTraceAggregate","bucketTraceAggregateRows","intervalHours","formatCount","MetricsCard","MetricsLineChartLegend","ChartCard","ChartCardError","ChartArea","MetricsLineChart","formatAxisCount","bucketWindow","EDGE_BUCKET_AXIS"],"sources":["../../../../../src/domains/metrics/components/distinct-ids/distinct-ids-chart.tsx"],"sourcesContent":["import type { AggregateTracesArgs } from '@mastra/client-js';\nimport type { DrilldownScope } from '../../drilldown';\nimport { useMetricsTraceAggregate } from '../../hooks/use-metrics-trace-aggregate';\nimport type { TraceAggregateScope } from '../../hooks/use-metrics-trace-aggregate';\nimport { EDGE_BUCKET_AXIS } from '../../lib/chart-axis';\nimport { CHART_COLORS } from '../../lib/chart-colors';\nimport { formatAxisCount, formatCount } from '../../lib/chart-format';\nimport { bucketWindow, intervalHours } from '../../lib/metrics-buckets';\nimport { bucketTraceAggregateRows, TRACE_AGGREGATE_SERIES_LIMIT } from '../../lib/trace-aggregate';\nimport type { TraceAggregateRow } from '../../lib/trace-aggregate';\nimport { ChartArea } from '../chart-area';\nimport { ChartCard } from '../chart-card';\nimport { ChartCardError } from '../chart-card-error';\nimport { MetricsCard } from '@/ds/components/MetricsCard';\nimport { MetricsLineChart, MetricsLineChartLegend } from '@/ds/components/MetricsLineChart';\nimport type { MetricsLineChartSeries } from '@/ds/components/MetricsLineChart';\n\n/** Most apps set resource and thread ids (through memory); few set user and session ids. */\nconst IDS = [\n { measure: 'countDistinct.resourceId', dataKey: 'resources', label: 'Resources', color: CHART_COLORS.sky },\n { measure: 'countDistinct.threadId', dataKey: 'threads', label: 'Threads', color: CHART_COLORS.green },\n { measure: 'countDistinct.userId', dataKey: 'users', label: 'Users', color: CHART_COLORS.violet },\n { measure: 'countDistinct.sessionId', dataKey: 'sessions', label: 'Sessions', color: CHART_COLORS.teal },\n] as const;\n\ntype Id = (typeof IDS)[number];\n\nconst MEASURES: AggregateTracesArgs['measures'] = IDS.map(id => id.measure);\n\nexport const DISTINCT_IDS_TITLE = 'Resources and threads';\n\nexport type DistinctIdsChartProps = {\n scope: TraceAggregateScope;\n /** Called with the time range of the clicked bucket. */\n onTimeRangeClick?: (scope: DrilldownScope) => void;\n};\n\nfunction count(row: TraceAggregateRow | undefined, id: Id) {\n return row?.measures[id.measure] ?? 0;\n}\n\n/** Distinct ids per bucket, with range totals from a second request. */\nexport function DistinctIdsChart({ scope, onTimeRangeClick }: DistinctIdsChartProps) {\n const series = useMetricsTraceAggregate({\n timeRange: scope.timeRange,\n where: scope.where,\n interval: scope.interval,\n measures: MEASURES,\n limit: TRACE_AGGREGATE_SERIES_LIMIT,\n });\n // Bucket counts can't be added up: an id active in two buckets would count twice.\n const totals = useMetricsTraceAggregate({ timeRange: scope.timeRange, where: scope.where, measures: MEASURES });\n\n const total = totals.data?.rows[0];\n // Only the ids this project sets get a line; the rest would sit flat at zero.\n const shown = IDS.filter(id => count(total, id) > 0);\n const lines: MetricsLineChartSeries[] = shown.map((id, i) => ({\n dataKey: id.dataKey,\n label: id.label,\n color: id.color,\n emphasis: i === 0,\n }));\n const chart = bucketTraceAggregateRows(series.data?.rows ?? [], scope.window).map(({ rows, ...labels }) => ({\n ...labels,\n ...Object.fromEntries(shown.map(id => [id.dataKey, count(rows[0], id)])),\n }));\n const step = intervalHours(scope.interval === '1d' ? '1d' : '1h');\n const error = series.error ?? totals.error;\n const isLoading = series.isLoading || totals.isLoading;\n\n const layout = {\n title: DISTINCT_IDS_TITLE,\n // Each id's range total, marked like its line: they count different things, so no one sum.\n // With no ids set, one plain 0, like any other empty card. None while a request failed, so no\n // total sits beside the error.\n total: error\n ? undefined\n : shown.length\n ? shown.map(id => ({ label: id.label, value: formatCount(count(total, id)), color: id.color }))\n : formatCount(0),\n isLoading: totals.isLoading,\n toolbar: lines.length > 0 && (\n <MetricsCard.Toolbar>\n <MetricsLineChartLegend series={lines} />\n </MetricsCard.Toolbar>\n ),\n };\n\n if (error) {\n return (\n <ChartCard {...layout}>\n <ChartCardError\n error={error}\n onRetry={() => {\n if (series.error) void series.refetch();\n if (totals.error) void totals.refetch();\n }}\n />\n </ChartCard>\n );\n }\n\n return (\n <ChartCard {...layout} isUpdating={series.isPlaceholderData || totals.isPlaceholderData}>\n <ChartArea isEmpty={!isLoading && shown.length === 0}>\n <MetricsLineChart\n lineStyle=\"thin\"\n data={chart}\n series={lines}\n height=\"fill\"\n xLabels=\"edges\"\n showLegend={false}\n valueFormatter={formatCount}\n axisFormatter={formatAxisCount}\n onBucketClick={onTimeRangeClick && (row => onTimeRangeClick({ window: bucketWindow(Number(row.ts), step) }))}\n isLoading={isLoading}\n {...EDGE_BUCKET_AXIS}\n />\n </ChartArea>\n </ChartCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,IAAM,MAAM;CACV;EAAE,SAAS;EAA4B,SAAS;EAAa,OAAO;EAAa,OAAOA,yCAAAA,aAAa;CAAI;CACzG;EAAE,SAAS;EAA0B,SAAS;EAAW,OAAO;EAAW,OAAOA,yCAAAA,aAAa;CAAM;CACrG;EAAE,SAAS;EAAwB,SAAS;EAAS,OAAO;EAAS,OAAOA,yCAAAA,aAAa;CAAO;CAChG;EAAE,SAAS;EAA2B,SAAS;EAAY,OAAO;EAAY,OAAOA,yCAAAA,aAAa;CAAK;AACzG;AAIA,IAAM,WAA4C,IAAI,KAAI,OAAM,GAAG,OAAO;AAE1E,IAAa,qBAAqB;AAQlC,SAAS,MAAM,KAAoC,IAAQ;CACzD,OAAO,KAAK,SAAS,GAAG,YAAY;AACtC;;AAGA,SAAgB,iBAAiB,EAAE,OAAO,oBAA2C;CACnF,MAAM,SAASC,0DAAAA,yBAAyB;EACtC,WAAW,MAAM;EACjB,OAAO,MAAM;EACb,UAAU,MAAM;EAChB,UAAU;EACV,OAAA;CACF,CAAC;CAED,MAAM,SAASA,0DAAAA,yBAAyB;EAAE,WAAW,MAAM;EAAW,OAAO,MAAM;EAAO,UAAU;CAAS,CAAC;CAE9G,MAAM,QAAQ,OAAO,MAAM,KAAK;CAEhC,MAAM,QAAQ,IAAI,QAAO,OAAM,MAAM,OAAO,EAAE,IAAI,CAAC;CACnD,MAAM,QAAkC,MAAM,KAAK,IAAI,OAAO;EAC5D,SAAS,GAAG;EACZ,OAAO,GAAG;EACV,OAAO,GAAG;EACV,UAAU,MAAM;CAClB,EAAE;CACF,MAAM,QAAQC,4CAAAA,yBAAyB,OAAO,MAAM,QAAQ,CAAC,GAAG,MAAM,MAAM,CAAC,CAAC,KAAK,E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AU;IACV,MAAM;IACN,QAAQ;IACR,QAAO;IACP,SAAQ;IACR,YAAY;IACZ,gBAAgBN,yCAAAA;IAChB,eAAeO,yCAAAA;IACf,eAAe,sBAAqB,QAAO,iBAAiB,EAAE,QAAQC,4CAAAA,aAAa,OAAO,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;IAC/F;IACX,GAAIC,uCAAAA;GACL,CAAA;EACQ,CAAA;CACF,CAAA;AAEf"}
1
+ {"version":3,"file":"distinct-ids-chart.cjs.js","names":["CHART_COLORS","useMetricsTraceAggregate","bucketTraceAggregateRows","intervalHours","formatCount","MetricsCard","MetricsLineChartLegend","ChartCard","ChartCardError","ChartArea","MetricsLineChart","formatAxisCount","bucketWindow","EDGE_BUCKET_AXIS"],"sources":["../../../../../src/domains/metrics/components/distinct-ids/distinct-ids-chart.tsx"],"sourcesContent":["import type { AggregateTracesArgs } from '@mastra/client-js';\nimport type { DrilldownScope } from '../../drilldown';\nimport { useMetricsTraceAggregate } from '../../hooks/use-metrics-trace-aggregate';\nimport type { TraceAggregateScope } from '../../hooks/use-metrics-trace-aggregate';\nimport { EDGE_BUCKET_AXIS } from '../../lib/chart-axis';\nimport { CHART_COLORS } from '../../lib/chart-colors';\nimport { formatAxisCount, formatCount } from '../../lib/chart-format';\nimport { bucketWindow, intervalHours } from '../../lib/metrics-buckets';\nimport { bucketTraceAggregateRows, TRACE_AGGREGATE_SERIES_LIMIT } from '../../lib/trace-aggregate';\nimport type { TraceAggregateRow } from '../../lib/trace-aggregate';\nimport { ChartArea } from '../chart-area';\nimport { ChartCard } from '../chart-card';\nimport { ChartCardError } from '../chart-card-error';\nimport { MetricsCard } from '@/ds/components/MetricsCard';\nimport { MetricsLineChart, MetricsLineChartLegend } from '@/ds/components/MetricsLineChart';\nimport type { MetricsLineChartSeries } from '@/ds/components/MetricsLineChart';\n\n/** Most apps set resource and thread ids (through memory); few set user and session ids. */\nconst IDS = [\n { measure: 'countDistinct.resourceId', dataKey: 'resources', label: 'Resources', color: CHART_COLORS.sky },\n { measure: 'countDistinct.threadId', dataKey: 'threads', label: 'Threads', color: CHART_COLORS.green },\n { measure: 'countDistinct.userId', dataKey: 'users', label: 'Users', color: CHART_COLORS.violet },\n { measure: 'countDistinct.sessionId', dataKey: 'sessions', label: 'Sessions', color: CHART_COLORS.teal },\n] as const;\n\ntype Id = (typeof IDS)[number];\n\nconst MEASURES: AggregateTracesArgs['measures'] = IDS.map(id => id.measure);\n\nexport const DISTINCT_IDS_TITLE = 'Resources and threads';\n\nexport type DistinctIdsChartProps = {\n scope: TraceAggregateScope;\n /** Called with the time range of the clicked bucket. */\n onTimeRangeClick?: (scope: DrilldownScope) => void;\n};\n\nfunction count(row: TraceAggregateRow | undefined, id: Id) {\n return row?.measures[id.measure] ?? 0;\n}\n\n/** Distinct ids per bucket, with range totals from a second request. */\nexport function DistinctIdsChart({ scope, onTimeRangeClick }: DistinctIdsChartProps) {\n const series = useMetricsTraceAggregate({\n timeRange: scope.timeRange,\n where: scope.where,\n interval: scope.interval,\n measures: MEASURES,\n limit: TRACE_AGGREGATE_SERIES_LIMIT,\n });\n // Bucket counts can't be added up: an id active in two buckets would count twice.\n const totals = useMetricsTraceAggregate({ timeRange: scope.timeRange, where: scope.where, measures: MEASURES });\n\n const total = totals.data?.rows[0];\n // Only the ids this project sets get a line; the rest would sit flat at zero.\n const shown = IDS.filter(id => count(total, id) > 0);\n const lines: MetricsLineChartSeries[] = shown.map((id, i) => ({\n dataKey: id.dataKey,\n label: id.label,\n color: id.color,\n emphasis: i === 0,\n }));\n const chart = bucketTraceAggregateRows(series.data?.rows ?? [], scope.window).map(({ rows, ...labels }) => ({\n ...labels,\n ...Object.fromEntries(shown.map(id => [id.dataKey, count(rows[0], id)])),\n }));\n const step = intervalHours(scope.interval === '1d' ? '1d' : '1h');\n const error = series.error ?? totals.error;\n const isLoading = series.isLoading || totals.isLoading;\n // One request failing says nothing about the other, which may still be running: report the\n // failure only once both have settled. A card that failed while a request it waits on is still\n // in flight cannot be recovered by Retry, which only re-sends the requests that failed. A new\n // scope keeps the previous answer on screen, so `isLoading` is false there while `isFetching`\n // is not.\n const isFetching = series.isFetching || totals.isFetching;\n const hasFailed = Boolean(error) && !isFetching;\n\n const layout = {\n title: DISTINCT_IDS_TITLE,\n // Each id's range total, marked like its line: they count different things, so no one sum.\n // With no ids set, one plain 0, like any other empty card. None while a request failed, so no\n // total sits beside the error.\n total: error\n ? undefined\n : shown.length\n ? shown.map(id => ({ label: id.label, value: formatCount(count(total, id)), color: id.color }))\n : formatCount(0),\n isLoading: totals.isLoading,\n toolbar: lines.length > 0 && (\n <MetricsCard.Toolbar>\n <MetricsLineChartLegend series={lines} />\n </MetricsCard.Toolbar>\n ),\n };\n\n if (hasFailed) {\n return (\n <ChartCard {...layout}>\n <ChartCardError\n error={error}\n onRetry={() => {\n if (series.error) void series.refetch();\n if (totals.error) void totals.refetch();\n }}\n />\n </ChartCard>\n );\n }\n\n return (\n <ChartCard {...layout} isUpdating={series.isPlaceholderData || totals.isPlaceholderData}>\n <ChartArea isEmpty={!isLoading && !error && shown.length === 0}>\n <MetricsLineChart\n lineStyle=\"thin\"\n data={chart}\n series={lines}\n height=\"fill\"\n xLabels=\"edges\"\n showLegend={false}\n valueFormatter={formatCount}\n axisFormatter={formatAxisCount}\n onBucketClick={onTimeRangeClick && (row => onTimeRangeClick({ window: bucketWindow(Number(row.ts), step) }))}\n isLoading={isLoading}\n {...EDGE_BUCKET_AXIS}\n />\n </ChartArea>\n </ChartCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,IAAM,MAAM;CACV;EAAE,SAAS;EAA4B,SAAS;EAAa,OAAO;EAAa,OAAOA,yCAAAA,aAAa;CAAI;CACzG;EAAE,SAAS;EAA0B,SAAS;EAAW,OAAO;EAAW,OAAOA,yCAAAA,aAAa;CAAM;CACrG;EAAE,SAAS;EAAwB,SAAS;EAAS,OAAO;EAAS,OAAOA,yCAAAA,aAAa;CAAO;CAChG;EAAE,SAAS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
  const step = intervalHours(scope.interval === "1d" ? "1d" : "1h");
73
73
  const error = series.error ?? totals.error;
74
74
  const isLoading = series.isLoading || totals.isLoading;
75
+ const isFetching = series.isFetching || totals.isFetching;
76
+ const hasFailed = Boolean(error) && !isFetching;
75
77
  const layout = {
76
78
  title: DISTINCT_IDS_TITLE,
77
79
  total: error ? void 0 : shown.length ? shown.map((id) => ({
@@ -82,7 +84,7 @@ function DistinctIdsChart({ scope, onTimeRangeClick }) {
82
84
  isLoading: totals.isLoading,
83
85
  toolbar: lines.length > 0 && /* @__PURE__ */ jsx(MetricsCard.Toolbar, { children: /* @__PURE__ */ jsx(MetricsLineChartLegend, { series: lines }) })
84
86
  };
85
- if (error) return /* @__PURE__ */ jsx(ChartCard, {
87
+ if (hasFailed) return /* @__PURE__ */ jsx(ChartCard, {
86
88
  ...layout,
87
89
  children: /* @__PURE__ */ jsx(ChartCardError, {
88
90
  error,
@@ -96,7 +98,7 @@ function DistinctIdsChart({ scope, onTimeRangeClick }) {
96
98
  ...layout,
97
99
  isUpdating: series.isPlaceholderData || totals.isPlaceholderData,
98
100
  children: /* @__PURE__ */ jsx(ChartArea, {
99
- isEmpty: !isLoading && shown.length === 0,
101
+ isEmpty: !isLoading && !error && shown.length === 0,
100
102
  children: /* @__PURE__ */ jsx(MetricsLineChart, {
101
103
  lineStyle: "thin",
102
104
  data: chart,
@@ -1 +1 @@
1
- {"version":3,"file":"distinct-ids-chart.es.js","names":[],"sources":["../../../../../src/domains/metrics/components/distinct-ids/distinct-ids-chart.tsx"],"sourcesContent":["import type { AggregateTracesArgs } from '@mastra/client-js';\nimport type { DrilldownScope } from '../../drilldown';\nimport { useMetricsTraceAggregate } from '../../hooks/use-metrics-trace-aggregate';\nimport type { TraceAggregateScope } from '../../hooks/use-metrics-trace-aggregate';\nimport { EDGE_BUCKET_AXIS } from '../../lib/chart-axis';\nimport { CHART_COLORS } from '../../lib/chart-colors';\nimport { formatAxisCount, formatCount } from '../../lib/chart-format';\nimport { bucketWindow, intervalHours } from '../../lib/metrics-buckets';\nimport { bucketTraceAggregateRows, TRACE_AGGREGATE_SERIES_LIMIT } from '../../lib/trace-aggregate';\nimport type { TraceAggregateRow } from '../../lib/trace-aggregate';\nimport { ChartArea } from '../chart-area';\nimport { ChartCard } from '../chart-card';\nimport { ChartCardError } from '../chart-card-error';\nimport { MetricsCard } from '@/ds/components/MetricsCard';\nimport { MetricsLineChart, MetricsLineChartLegend } from '@/ds/components/MetricsLineChart';\nimport type { MetricsLineChartSeries } from '@/ds/components/MetricsLineChart';\n\n/** Most apps set resource and thread ids (through memory); few set user and session ids. */\nconst IDS = [\n { measure: 'countDistinct.resourceId', dataKey: 'resources', label: 'Resources', color: CHART_COLORS.sky },\n { measure: 'countDistinct.threadId', dataKey: 'threads', label: 'Threads', color: CHART_COLORS.green },\n { measure: 'countDistinct.userId', dataKey: 'users', label: 'Users', color: CHART_COLORS.violet },\n { measure: 'countDistinct.sessionId', dataKey: 'sessions', label: 'Sessions', color: CHART_COLORS.teal },\n] as const;\n\ntype Id = (typeof IDS)[number];\n\nconst MEASURES: AggregateTracesArgs['measures'] = IDS.map(id => id.measure);\n\nexport const DISTINCT_IDS_TITLE = 'Resources and threads';\n\nexport type DistinctIdsChartProps = {\n scope: TraceAggregateScope;\n /** Called with the time range of the clicked bucket. */\n onTimeRangeClick?: (scope: DrilldownScope) => void;\n};\n\nfunction count(row: TraceAggregateRow | undefined, id: Id) {\n return row?.measures[id.measure] ?? 0;\n}\n\n/** Distinct ids per bucket, with range totals from a second request. */\nexport function DistinctIdsChart({ scope, onTimeRangeClick }: DistinctIdsChartProps) {\n const series = useMetricsTraceAggregate({\n timeRange: scope.timeRange,\n where: scope.where,\n interval: scope.interval,\n measures: MEASURES,\n limit: TRACE_AGGREGATE_SERIES_LIMIT,\n });\n // Bucket counts can't be added up: an id active in two buckets would count twice.\n const totals = useMetricsTraceAggregate({ timeRange: scope.timeRange, where: scope.where, measures: MEASURES });\n\n const total = totals.data?.rows[0];\n // Only the ids this project sets get a line; the rest would sit flat at zero.\n const shown = IDS.filter(id => count(total, id) > 0);\n const lines: MetricsLineChartSeries[] = shown.map((id, i) => ({\n dataKey: id.dataKey,\n label: id.label,\n color: id.color,\n emphasis: i === 0,\n }));\n const chart = bucketTraceAggregateRows(series.data?.rows ?? [], scope.window).map(({ rows, ...labels }) => ({\n ...labels,\n ...Object.fromEntries(shown.map(id => [id.dataKey, count(rows[0], id)])),\n }));\n const step = intervalHours(scope.interval === '1d' ? '1d' : '1h');\n const error = series.error ?? totals.error;\n const isLoading = series.isLoading || totals.isLoading;\n\n const layout = {\n title: DISTINCT_IDS_TITLE,\n // Each id's range total, marked like its line: they count different things, so no one sum.\n // With no ids set, one plain 0, like any other empty card. None while a request failed, so no\n // total sits beside the error.\n total: error\n ? undefined\n : shown.length\n ? shown.map(id => ({ label: id.label, value: formatCount(count(total, id)), color: id.color }))\n : formatCount(0),\n isLoading: totals.isLoading,\n toolbar: lines.length > 0 && (\n <MetricsCard.Toolbar>\n <MetricsLineChartLegend series={lines} />\n </MetricsCard.Toolbar>\n ),\n };\n\n if (error) {\n return (\n <ChartCard {...layout}>\n <ChartCardError\n error={error}\n onRetry={() => {\n if (series.error) void series.refetch();\n if (totals.error) void totals.refetch();\n }}\n />\n </ChartCard>\n );\n }\n\n return (\n <ChartCard {...layout} isUpdating={series.isPlaceholderData || totals.isPlaceholderData}>\n <ChartArea isEmpty={!isLoading && shown.length === 0}>\n <MetricsLineChart\n lineStyle=\"thin\"\n data={chart}\n series={lines}\n height=\"fill\"\n xLabels=\"edges\"\n showLegend={false}\n valueFormatter={formatCount}\n axisFormatter={formatAxisCount}\n onBucketClick={onTimeRangeClick && (row => onTimeRangeClick({ window: bucketWindow(Number(row.ts), step) }))}\n isLoading={isLoading}\n {...EDGE_BUCKET_AXIS}\n />\n </ChartArea>\n </ChartCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAkBA,IAAM,MAAM;CACV;EAAE,SAAS;EAA4B,SAAS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CAE7C,MAAM,SAAS;EACb,OAAO;EAIP,OAAO,QACH,KAAA,IACA,MAAM,SACJ,MAAM,KAAI,QAAO;GAAE,OAAO,GAAG;GAAO,OAAO,YAAY,MAAM,OAAO,EAAE,CAAC;GAAG,OAAO,GAAG;EAAM,EAAE,IAC5F,YAAY,CAAC;EACnB,WAAW,OAAO;EAClB,SAAS,MAAM,SAAS,KACtB,oBAAC,YAAY,SAAb,EAAA,UACE,oBAAC,wBAAD,EAAwB,QAAQ,MAAQ,CAAA,EACrB,CAAA;CAEzB;CAEA,IAAI,OACF,OACE,oBAAC,WAAD;EAAW,GAAI;EACb,UAAA,oBAAC,gBAAD;GACS;GACP,eAAe;IACb,IAAI,OAAO,OAAO,OAAY,QAAQ;IACtC,IAAI,OAAO,OAAO,OAAY,QAAQ;GACxC;EACD,CAAA;CACQ,CAAA;CAIf,OACE,oBAAC,WAAD;EAAW,GAAI;EAAQ,YAAY,OAAO,qBAAqB,OAAO;EACpE,UAAA,oBAAC,WAAD;GAAW,SAAS,CAAC,aAAa,MAAM,WAAW;GACjD,UAAA,oBAAC,kBAAD;IACE,WAAU;IACV,MAAM;IACN,QAAQ;IACR,QAAO;IACP,SAAQ;IACR,YAAY;IACZ,gBAAgB;IAChB,eAAe;IACf,eAAe,sBAAqB,QAAO,iBAAiB,EAAE,QAAQ,aAAa,OAAO,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;IAC/F;IACX,GAAI;GACL,CAAA;EACQ,CAAA;CACF,CAAA;AAEf"}
1
+ {"version":3,"file":"distinct-ids-chart.es.js","names":[],"sources":["../../../../../src/domains/metrics/components/distinct-ids/distinct-ids-chart.tsx"],"sourcesContent":["import type { AggregateTracesArgs } from '@mastra/client-js';\nimport type { DrilldownScope } from '../../drilldown';\nimport { useMetricsTraceAggregate } from '../../hooks/use-metrics-trace-aggregate';\nimport type { TraceAggregateScope } from '../../hooks/use-metrics-trace-aggregate';\nimport { EDGE_BUCKET_AXIS } from '../../lib/chart-axis';\nimport { CHART_COLORS } from '../../lib/chart-colors';\nimport { formatAxisCount, formatCount } from '../../lib/chart-format';\nimport { bucketWindow, intervalHours } from '../../lib/metrics-buckets';\nimport { bucketTraceAggregateRows, TRACE_AGGREGATE_SERIES_LIMIT } from '../../lib/trace-aggregate';\nimport type { TraceAggregateRow } from '../../lib/trace-aggregate';\nimport { ChartArea } from '../chart-area';\nimport { ChartCard } from '../chart-card';\nimport { ChartCardError } from '../chart-card-error';\nimport { MetricsCard } from '@/ds/components/MetricsCard';\nimport { MetricsLineChart, MetricsLineChartLegend } from '@/ds/components/MetricsLineChart';\nimport type { MetricsLineChartSeries } from '@/ds/components/MetricsLineChart';\n\n/** Most apps set resource and thread ids (through memory); few set user and session ids. */\nconst IDS = [\n { measure: 'countDistinct.resourceId', dataKey: 'resources', label: 'Resources', color: CHART_COLORS.sky },\n { measure: 'countDistinct.threadId', dataKey: 'threads', label: 'Threads', color: CHART_COLORS.green },\n { measure: 'countDistinct.userId', dataKey: 'users', label: 'Users', color: CHART_COLORS.violet },\n { measure: 'countDistinct.sessionId', dataKey: 'sessions', label: 'Sessions', color: CHART_COLORS.teal },\n] as const;\n\ntype Id = (typeof IDS)[number];\n\nconst MEASURES: AggregateTracesArgs['measures'] = IDS.map(id => id.measure);\n\nexport const DISTINCT_IDS_TITLE = 'Resources and threads';\n\nexport type DistinctIdsChartProps = {\n scope: TraceAggregateScope;\n /** Called with the time range of the clicked bucket. */\n onTimeRangeClick?: (scope: DrilldownScope) => void;\n};\n\nfunction count(row: TraceAggregateRow | undefined, id: Id) {\n return row?.measures[id.measure] ?? 0;\n}\n\n/** Distinct ids per bucket, with range totals from a second request. */\nexport function DistinctIdsChart({ scope, onTimeRangeClick }: DistinctIdsChartProps) {\n const series = useMetricsTraceAggregate({\n timeRange: scope.timeRange,\n where: scope.where,\n interval: scope.interval,\n measures: MEASURES,\n limit: TRACE_AGGREGATE_SERIES_LIMIT,\n });\n // Bucket counts can't be added up: an id active in two buckets would count twice.\n const totals = useMetricsTraceAggregate({ timeRange: scope.timeRange, where: scope.where, measures: MEASURES });\n\n const total = totals.data?.rows[0];\n // Only the ids this project sets get a line; the rest would sit flat at zero.\n const shown = IDS.filter(id => count(total, id) > 0);\n const lines: MetricsLineChartSeries[] = shown.map((id, i) => ({\n dataKey: id.dataKey,\n label: id.label,\n color: id.color,\n emphasis: i === 0,\n }));\n const chart = bucketTraceAggregateRows(series.data?.rows ?? [], scope.window).map(({ rows, ...labels }) => ({\n ...labels,\n ...Object.fromEntries(shown.map(id => [id.dataKey, count(rows[0], id)])),\n }));\n const step = intervalHours(scope.interval === '1d' ? '1d' : '1h');\n const error = series.error ?? totals.error;\n const isLoading = series.isLoading || totals.isLoading;\n // One request failing says nothing about the other, which may still be running: report the\n // failure only once both have settled. A card that failed while a request it waits on is still\n // in flight cannot be recovered by Retry, which only re-sends the requests that failed. A new\n // scope keeps the previous answer on screen, so `isLoading` is false there while `isFetching`\n // is not.\n const isFetching = series.isFetching || totals.isFetching;\n const hasFailed = Boolean(error) && !isFetching;\n\n const layout = {\n title: DISTINCT_IDS_TITLE,\n // Each id's range total, marked like its line: they count different things, so no one sum.\n // With no ids set, one plain 0, like any other empty card. None while a request failed, so no\n // total sits beside the error.\n total: error\n ? undefined\n : shown.length\n ? shown.map(id => ({ label: id.label, value: formatCount(count(total, id)), color: id.color }))\n : formatCount(0),\n isLoading: totals.isLoading,\n toolbar: lines.length > 0 && (\n <MetricsCard.Toolbar>\n <MetricsLineChartLegend series={lines} />\n </MetricsCard.Toolbar>\n ),\n };\n\n if (hasFailed) {\n return (\n <ChartCard {...layout}>\n <ChartCardError\n error={error}\n onRetry={() => {\n if (series.error) void series.refetch();\n if (totals.error) void totals.refetch();\n }}\n />\n </ChartCard>\n );\n }\n\n return (\n <ChartCard {...layout} isUpdating={series.isPlaceholderData || totals.isPlaceholderData}>\n <ChartArea isEmpty={!isLoading && !error && shown.length === 0}>\n <MetricsLineChart\n lineStyle=\"thin\"\n data={chart}\n series={lines}\n height=\"fill\"\n xLabels=\"edges\"\n showLegend={false}\n valueFormatter={formatCount}\n axisFormatter={formatAxisCount}\n onBucketClick={onTimeRangeClick && (row => onTimeRangeClick({ window: bucketWindow(Number(row.ts), step) }))}\n isLoading={isLoading}\n {...EDGE_BUCKET_AXIS}\n />\n </ChartArea>\n </ChartCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAkBA,IAAM,MAAM;CACV;EAAE,SAAS;EAA4B,SAAS;EAAa,OAAO;EAAa,OAAO,aAAa;CAAI;CACzG;EAAE,SAAS;EAA0B,SAAS;EAAW,OAAO;EAAW,OAAO,aAAa;CAAM;CACrG;EAAE,SAAS;EAAwB,SAAS;EAAS,OAAO;EAAS,OAAO,aAAa;CAAO;CAChG;EAAE,SAAS;EAA2B,SAAS;EAAY,OAAO;EAAY,OAAO,aAAa;CAAK;AACzG;AAIA,IAAM,WAA4C,IAAI,KAAI,OAAM,GAAG,OAAO;AAE1E,IAAa,qBAAqB;AAQlC,SAAS,MAAM,KAAoC,IAAQ;CACzD,OAAO,KAAK,SAAS,GAAG,YAAY;AACtC;;AAGA,SAAgB,iBAAiB,EAAE,OAAO,oBAA2C;CACnF,MAAM,SAAS,yBAAyB;EACtC,WAAW,MAAM;EACjB,OAAO,MAAM;EACb,UAAU,MAAM;EAChB,UAAU;EACV,OAAA;CACF,CAAC;CAED,MAAM,SAAS,yBAAyB;EAAE,WAAW,MAAM;EAAW,OAAO,MAAM;EAAO,UAAU;CAAS,CAAC;CAE9G,MAAM,QAAQ,OAAO,MAAM,KAAK;CAEhC,MAAM,QAAQ,IAAI,QAAO,OAAM,MAAM,OAAO,EAAE,IAAI,CAAC;CACnD,MAAM,QAAkC,MAAM,KAAK,IAAI,OAAO;EAC5D,SAAS,GAAG;EACZ,OAAO,GAAG;EACV,OAAO,GAAG;EACV,UAAU,MAAM;CAClB,EAAE;CACF,MAAM,QAAQ,yBAAyB,OAAO,MAAM,QAAQ,CAAC,GAAG,MAAM,MAAM,CAAC,CAAC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,IAAI,EAAE,CAAC;IAC/F;IACX,GAAI;GACL,CAAA;EACQ,CAAA;CACF,CAAA;AAEf"}
@@ -1,20 +1,25 @@
1
1
  import type { MastraDBMessage } from '@mastra/core/agent/message-list';
2
+ import type { ChunkType } from '@mastra/core/stream';
2
3
  type StreamErrorChunk = {
3
4
  runId?: string;
4
5
  payload?: {
5
6
  error?: unknown;
6
7
  };
7
8
  };
8
- type FinishChunkLike = {
9
- type?: string;
10
- runId?: string;
11
- payload?: {
12
- stepResult?: {
13
- reason?: unknown;
14
- };
15
- };
16
- };
17
- export declare const isMaxStepsFinishChunk: (chunk: FinishChunkLike) => boolean;
9
+ /**
10
+ * True when a run stopped because it used its whole step budget while the model
11
+ * still wanted to call tools. A `'tool-calls'` finish reason alone only says the
12
+ * last step called a tool: a `stopWhen` match, a client tool or an
13
+ * `onIterationComplete` stop end a run the same way, even on the last allowed
14
+ * step (#29612). Core reports why its loop stopped as `stopCause`, on both the
15
+ * agent stream and thread subscription copies. When `stopCause` is absent (for
16
+ * example from an older `@mastra/core` server), do not infer exhaustion from
17
+ * step count, because intentional boundary stops look identical.
18
+ */
19
+ export declare const isMaxStepsFinishChunk: ({ chunk }: {
20
+ chunk: ChunkType;
21
+ maxSteps?: number | undefined;
22
+ }) => boolean;
18
23
  /**
19
24
  * Build a `MastraDBMessage` representing a stream `error` chunk so it can be
20
25
  * rendered by `error-aware-text`. Prefer the human-readable `message` field on
@@ -22,5 +27,5 @@ export declare const isMaxStepsFinishChunk: (chunk: FinishChunkLike) => boolean;
22
27
  * silently swallow an error.
23
28
  */
24
29
  export declare const buildStreamErrorMessage: (chunk: StreamErrorChunk) => MastraDBMessage;
25
- export declare const buildMaxStepsStreamErrorMessage: (chunk: FinishChunkLike, maxSteps?: number) => MastraDBMessage;
30
+ export declare const buildMaxStepsStreamErrorMessage: (chunk: Pick<ChunkType, 'runId'>, maxSteps?: number) => MastraDBMessage;
26
31
  export {};
@@ -26,8 +26,7 @@ export type StatelessWidgetProps = {
26
26
  /**
27
27
  * Makes the card's title editable in place, and is called with the trimmed new title when the
28
28
  * user changes it (Enter or blur; Escape reverts). The host stores it and passes the widget back
29
- * with its new `title`. Only a plain title is editable, not one that picks between several views.
30
- * KPI groups have no title.
29
+ * with its new `title`. KPI groups have no title.
31
30
  */
32
31
  onTitleChange?: (title: string) => void;
33
32
  /** The card's Create alert button; see `DashboardAlert`. */
@@ -0,0 +1,13 @@
1
+ type ViewTabsProps = {
2
+ /** Every view's full name, in order; the tabs show them without their shared words. */
3
+ labels: readonly string[];
4
+ /** The open view. */
5
+ index: number;
6
+ onChoose: (index: number) => void;
7
+ };
8
+ /**
9
+ * A widget's views as pill tabs under its title, each one click away; what doesn't fit folds into a
10
+ * "+N" menu. Picking one swaps at once: the pill doesn't slide, as the body under it doesn't fade.
11
+ */
12
+ export declare function ViewTabs({ labels, index, onChoose }: ViewTabsProps): import("react").JSX.Element;
13
+ export {};
@@ -1,23 +1,29 @@
1
1
  import type { DashboardWidget, DashboardWidgetView } from '@mastra/client-js';
2
2
  import type { DrilldownScope } from '../../metrics/drilldown';
3
+ import type { ViewHeading } from '../lib/chrome';
3
4
  import type { OnDashboardDrilldown } from '../lib/definition';
4
5
  import type { DashboardExpand, ResolvedView } from '../widget-kind';
6
+ /**
7
+ * The card heading for the open view: the widget's title, with several views as tabs under it
8
+ * (`toolbar`). With somewhere to expand to, the title stays alone instead, and `ExpandAction` links there.
9
+ */
10
+ export declare function viewTitle(widget: DashboardWidget, views: readonly DashboardWidgetView[], index: number, onChoose: (index: number) => void, expand?: DashboardExpand): ViewHeading;
5
11
  export type Views<Options> = readonly [ResolvedView<Options>, ...ResolvedView<Options>[]];
6
12
  /**
7
- * The open view of a widget, `wanted` when it has one (else the first), and the card title for it
8
- * (`title`, and `titleMenu` with several views unless the widget has somewhere to `expand` to) to
9
- * spread into `ChartCard`; picking a view calls `onChoose`.
13
+ * The open view of a widget, `wanted` when it has one (else the first), and the card heading for it
14
+ * (`title`, and with several views their tabs as `toolbar`, unless the widget has somewhere to
15
+ * `expand` to) to spread into `ChartCard`; picking a view calls `onChoose`.
10
16
  */
11
17
  export declare function viewMenu<Options>(widget: DashboardWidget, views: Views<Options>, wanted: number, onChoose: (index: number) => void, expand?: DashboardExpand): {
12
18
  view: ResolvedView<Options>;
13
19
  index: number;
14
- heading: import("../lib/chrome").ViewHeading;
20
+ heading: ViewHeading;
15
21
  };
16
22
  /** `viewMenu` with the open view held here: `defaultIndex` until one is picked. */
17
23
  export declare function useViewMenu<Options>(widget: DashboardWidget, views: Views<Options>, defaultIndex?: number, expand?: DashboardExpand): {
18
24
  view: ResolvedView<Options>;
19
25
  index: number;
20
- heading: import("../lib/chrome").ViewHeading;
26
+ heading: ViewHeading;
21
27
  };
22
28
  /** What clicking a bucket or row opens, with what was clicked; `undefined` when the view has no click target. */
23
29
  export declare function useDrilldown(widget: DashboardWidget, view: DashboardWidgetView, onDrilldown: OnDashboardDrilldown | undefined): ((clicked: DrilldownScope) => void) | undefined;
@@ -1,20 +1,11 @@
1
- import type { DashboardWidget, DashboardWidgetView } from '@mastra/client-js';
2
1
  import type { ChartCardProps } from '../../metrics/components/chart-card';
3
- import type { DashboardExpand } from '../widget-kind';
4
2
  /**
5
- * What a widget's card shows in its top bar: `title`, and `titleMenu` with several views, plus its
6
- * actions: the drilldown, the alert, the expand link, then the host's. A table's several views are
7
- * tabs in its `toolbar` instead.
3
+ * What a widget's card shows in its top bar: `title`, plus its actions: the drilldown, the alert,
4
+ * the expand link, then the host's. Several views are tabs in its `toolbar`, under the title.
8
5
  */
9
- export type ViewHeading = Pick<ChartCardProps, 'title' | 'titleMenu' | 'dragHandle' | 'onTitleChange' | 'actions' | 'toolbar'>;
6
+ export type ViewHeading = Pick<ChartCardProps, 'title' | 'dragHandle' | 'onTitleChange' | 'actions' | 'toolbar'>;
10
7
  export declare const unsupportedMessage: (fields: string[], names?: Record<string, string>) => string;
11
- /** A view's value in the card's menu: its label in kebab case (`Token usage` → `token-usage`), or its position when unlabelled or blank. */
8
+ /** A view's value in the widget's state: its label in kebab case (`Token usage` → `token-usage`), or its position when unlabelled or blank. */
12
9
  export declare const viewValue: (label: string | undefined, index: number) => string;
13
10
  /** A view's visible name: its label, or `View n` when unlabelled or blank, so every option has an accessible name. */
14
11
  export declare const viewLabel: (label: string | undefined, index: number) => string;
15
- /**
16
- * The card title for the open view: the widget's title for a single view; with several, the open
17
- * view's label, as a menu of every view (as the metrics cards switch views). With somewhere to
18
- * expand to, the widget's title stays plain instead, and `ExpandAction` links there.
19
- */
20
- export declare function viewTitle(widget: DashboardWidget, views: readonly DashboardWidgetView[], index: number, onChoose: (index: number) => void, expand?: DashboardExpand): ViewHeading;
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Short tab names for a card's views: their labels without the words they all start with,
2
+ * Short tab names for a card's views: their labels without the words they all start or end with,
3
3
  * capitalised ("Breakdown by agent", "Breakdown by tool" → "Agents", "Tools"; after "by", the
4
- * rest names what each row is, so it reads as a plural). Labels that share nothing, or that would
5
- * shorten to the same name, stay as they are.
4
+ * rest names what each row is, so it reads as a plural. "Agent latency", "Tool latency" → "Agent",
5
+ * "Tool"). Labels that share nothing, or that would shorten to the same name, stay as they are.
6
6
  */
7
7
  export declare function shortViewLabels(labels: readonly string[]): string[];
@@ -115,9 +115,8 @@ export type WidgetPlanContext<Options> = {
115
115
  export type WidgetRequests = (DashboardRequest | undefined)[];
116
116
  /**
117
117
  * Where a chart widget expands to (a host's query page), as the Gateway Overview's cards do: the card
118
- * gets an expand action linking there, and shows its first view under its plain title, in place of
119
- * its views menu, so the title stays editable with `onTitleChange`. `href` returns `undefined` for a
120
- * widget with nowhere to go; that card keeps its menu.
118
+ * gets an expand action linking there, and shows its first view under its title, without its view
119
+ * tabs. `href` returns `undefined` for a widget with nowhere to go; that card keeps its tabs.
121
120
  */
122
121
  export type DashboardExpand = {
123
122
  href: (widget: DashboardWidget) => string | undefined;
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@mastra/playground-ui",
3
3
  "type": "module",
4
- "version": "71.0.0-alpha.7",
4
+ "version": "71.0.0-alpha.9",
5
5
  "description": "Mastra Playground components",
6
6
  "sideEffects": [
7
7
  "**/*.css"
8
8
  ],
9
9
  "files": [
10
10
  "dist",
11
+ "!dist/**/*.d.*ts.map",
11
12
  "theme.css",
12
13
  "components.css",
13
14
  "sources.css",
@@ -220,7 +221,7 @@
220
221
  "tw-animate-css": "^1.4.0",
221
222
  "use-debounce": "^10.1.1",
222
223
  "zod": "^4.6.7",
223
- "@mastra/json-render": "^0.2.0-alpha.0"
224
+ "@mastra/json-render": "^0.2.0-alpha.1"
224
225
  },
225
226
  "peerDependencies": {
226
227
  "@mastra/core": ">=1.83.0-0 <2.0.0-0",
@@ -230,9 +231,9 @@
230
231
  "react": ">=19.0.0",
231
232
  "react-dom": ">=19.0.0",
232
233
  "tailwindcss": "^4.0.0",
233
- "@mastra/ai-sdk": "^1.12.0",
234
- "@mastra/client-js": "^1.61.2-alpha.4",
235
- "@mastra/react": "1.16.0-alpha.4"
234
+ "@mastra/ai-sdk": "^1.12.1-alpha.0",
235
+ "@mastra/client-js": "^1.61.2-alpha.6",
236
+ "@mastra/react": "1.16.0-alpha.6"
236
237
  },
237
238
  "devDependencies": {
238
239
  "@modelcontextprotocol/client": "2.4.0",
@@ -278,14 +279,14 @@
278
279
  "vite": "^8.3.5",
279
280
  "vite-plugin-lib-inject-css": "^2.2.2",
280
281
  "vitest": "5.1.0",
281
- "@mastra/ai-sdk": "1.12.0",
282
- "@mastra/client-js": "^1.61.2-alpha.4",
283
- "@mastra/core": "1.86.0-alpha.4",
284
- "@mastra/memory": "1.41.3-alpha.0",
285
- "@mastra/react": "1.16.0-alpha.4",
286
282
  "@internal/ai-sdk-v5": "0.0.98",
287
283
  "@internal/lint": "0.0.151",
288
- "@mastra/schema-compat": "1.4.0"
284
+ "@mastra/ai-sdk": "1.12.1-alpha.0",
285
+ "@mastra/client-js": "^1.61.2-alpha.6",
286
+ "@mastra/core": "1.86.0-alpha.6",
287
+ "@mastra/memory": "1.41.3-alpha.2",
288
+ "@mastra/react": "1.16.0-alpha.6",
289
+ "@mastra/schema-compat": "1.4.1-alpha.0"
289
290
  },
290
291
  "homepage": "https://mastra.ai",
291
292
  "repository": {
@@ -1,32 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_domains_dashboards_lib_chrome = require("../../lib/chrome.cjs.js");
3
- const require_domains_dashboards_lib_view_labels = require("../../lib/view-labels.cjs.js");
4
- const require_tabs_tab = require("../../../../tabs-tab-DX3gEvH2.cjs");
5
- let react_jsx_runtime = require("react/jsx-runtime");
6
- // src/domains/dashboards/kinds/table/table-view-tabs.tsx
7
- /**
8
- * A table's views as pill tabs under its title, each one click away; what doesn't fit folds into a
9
- * "+N" menu. Picking one swaps at once: the pill doesn't slide, as the table under it doesn't fade.
10
- */
11
- function TableViewTabs({ views, index, onChoose }) {
12
- const labels = require_domains_dashboards_lib_view_labels.shortViewLabels(views.map((view, i) => require_domains_dashboards_lib_chrome.viewLabel(view.label, i)));
13
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_tabs_tab.Tabs, {
14
- value: String(index),
15
- defaultTab: String(index),
16
- onValueChange: (value) => onChoose(Number(value)),
17
- className: "overflow-visible",
18
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_tabs_tab.TabList, {
19
- variant: "pill",
20
- size: "sm",
21
- overflow: "menu",
22
- className: "[&_[data-slot=tabs-indicator]]:transition-none",
23
- children: labels.map((label, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_tabs_tab.Tab, {
24
- value: String(i),
25
- children: label
26
- }, i))
27
- })
28
- });
29
- }
30
- exports.TableViewTabs = TableViewTabs;
31
-
32
- //# sourceMappingURL=table-view-tabs.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table-view-tabs.cjs.js","names":["shortViewLabels","viewLabel","Tabs","TabList","Tab"],"sources":["../../../../../src/domains/dashboards/kinds/table/table-view-tabs.tsx"],"sourcesContent":["import { viewLabel } from '../../lib/chrome';\nimport type { TableOptions } from '../../lib/table';\nimport { shortViewLabels } from '../../lib/view-labels';\nimport type { WidgetKindProps } from '../../widget-kind';\nimport { Tab, TabList, Tabs } from '@/ds/components/Tabs';\n\ntype TableViewTabsProps = {\n views: WidgetKindProps<TableOptions>['views'];\n /** The open view. */\n index: number;\n onChoose: (index: number) => void;\n};\n\n/**\n * A table's views as pill tabs under its title, each one click away; what doesn't fit folds into a\n * \"+N\" menu. Picking one swaps at once: the pill doesn't slide, as the table under it doesn't fade.\n */\nexport function TableViewTabs({ views, index, onChoose }: TableViewTabsProps) {\n const labels = shortViewLabels(views.map((view, i) => viewLabel(view.label, i)));\n return (\n <Tabs\n value={String(index)}\n defaultTab={String(index)}\n onValueChange={value => onChoose(Number(value))}\n className=\"overflow-visible\"\n >\n <TabList variant=\"pill\" size=\"sm\" overflow=\"menu\" className=\"[&_[data-slot=tabs-indicator]]:transition-none\">\n {labels.map((label, i) => (\n <Tab key={i} value={String(i)}>\n {label}\n </Tab>\n ))}\n </TabList>\n </Tabs>\n );\n}\n"],"mappings":";;;;;;;;;;AAiBA,SAAgB,cAAc,EAAE,OAAO,OAAO,YAAgC;CAC5E,MAAM,SAASA,2CAAAA,gBAAgB,MAAM,KAAK,MAAM,MAAMC,sCAAAA,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC;CAC/E,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,iBAAAA,MAAD;EACE,OAAO,OAAO,KAAK;EACnB,YAAY,OAAO,KAAK;EACxB,gBAAe,UAAS,SAAS,OAAO,KAAK,CAAC;EAC9C,WAAU;EAEV,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,iBAAAA,SAAD;GAAS,SAAQ;GAAO,MAAK;GAAK,UAAS;GAAO,WAAU;GACzD,UAAA,OAAO,KAAK,OAAO,MAClB,iBAAA,GAAA,kBAAA,IAAA,CAACC,iBAAAA,KAAD;IAAa,OAAO,OAAO,CAAC;IACzB,UAAA;GACE,GAFK,CAEL,CACN;EACM,CAAA;CACL,CAAA;AAEV"}
@@ -1 +0,0 @@
1
- export * from '../../../../src/domains/dashboards/kinds/table/table-view-tabs';
@@ -1,31 +0,0 @@
1
- import { viewLabel } from "../../lib/chrome.es.js";
2
- import { shortViewLabels } from "../../lib/view-labels.es.js";
3
- import { n as Tabs, r as TabList, t as Tab } from "../../../../tabs-tab-BbkJy1dq.js";
4
- import { jsx } from "react/jsx-runtime";
5
- // src/domains/dashboards/kinds/table/table-view-tabs.tsx
6
- /**
7
- * A table's views as pill tabs under its title, each one click away; what doesn't fit folds into a
8
- * "+N" menu. Picking one swaps at once: the pill doesn't slide, as the table under it doesn't fade.
9
- */
10
- function TableViewTabs({ views, index, onChoose }) {
11
- const labels = shortViewLabels(views.map((view, i) => viewLabel(view.label, i)));
12
- return /* @__PURE__ */ jsx(Tabs, {
13
- value: String(index),
14
- defaultTab: String(index),
15
- onValueChange: (value) => onChoose(Number(value)),
16
- className: "overflow-visible",
17
- children: /* @__PURE__ */ jsx(TabList, {
18
- variant: "pill",
19
- size: "sm",
20
- overflow: "menu",
21
- className: "[&_[data-slot=tabs-indicator]]:transition-none",
22
- children: labels.map((label, i) => /* @__PURE__ */ jsx(Tab, {
23
- value: String(i),
24
- children: label
25
- }, i))
26
- })
27
- });
28
- }
29
- export { TableViewTabs };
30
-
31
- //# sourceMappingURL=table-view-tabs.es.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table-view-tabs.es.js","names":[],"sources":["../../../../../src/domains/dashboards/kinds/table/table-view-tabs.tsx"],"sourcesContent":["import { viewLabel } from '../../lib/chrome';\nimport type { TableOptions } from '../../lib/table';\nimport { shortViewLabels } from '../../lib/view-labels';\nimport type { WidgetKindProps } from '../../widget-kind';\nimport { Tab, TabList, Tabs } from '@/ds/components/Tabs';\n\ntype TableViewTabsProps = {\n views: WidgetKindProps<TableOptions>['views'];\n /** The open view. */\n index: number;\n onChoose: (index: number) => void;\n};\n\n/**\n * A table's views as pill tabs under its title, each one click away; what doesn't fit folds into a\n * \"+N\" menu. Picking one swaps at once: the pill doesn't slide, as the table under it doesn't fade.\n */\nexport function TableViewTabs({ views, index, onChoose }: TableViewTabsProps) {\n const labels = shortViewLabels(views.map((view, i) => viewLabel(view.label, i)));\n return (\n <Tabs\n value={String(index)}\n defaultTab={String(index)}\n onValueChange={value => onChoose(Number(value))}\n className=\"overflow-visible\"\n >\n <TabList variant=\"pill\" size=\"sm\" overflow=\"menu\" className=\"[&_[data-slot=tabs-indicator]]:transition-none\">\n {labels.map((label, i) => (\n <Tab key={i} value={String(i)}>\n {label}\n </Tab>\n ))}\n </TabList>\n </Tabs>\n );\n}\n"],"mappings":";;;;;;;;;AAiBA,SAAgB,cAAc,EAAE,OAAO,OAAO,YAAgC;CAC5E,MAAM,SAAS,gBAAgB,MAAM,KAAK,MAAM,MAAM,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC;CAC/E,OACE,oBAAC,MAAD;EACE,OAAO,OAAO,KAAK;EACnB,YAAY,OAAO,KAAK;EACxB,gBAAe,UAAS,SAAS,OAAO,KAAK,CAAC;EAC9C,WAAU;EAEV,UAAA,oBAAC,SAAD;GAAS,SAAQ;GAAO,MAAK;GAAK,UAAS;GAAO,WAAU;GACzD,UAAA,OAAO,KAAK,OAAO,MAClB,oBAAC,KAAD;IAAa,OAAO,OAAO,CAAC;IACzB,UAAA;GACE,GAFK,CAEL,CACN;EACM,CAAA;CACL,CAAA;AAEV"}
@@ -1,14 +0,0 @@
1
- import type { TableOptions } from '../../lib/table';
2
- import type { WidgetKindProps } from '../../widget-kind';
3
- type TableViewTabsProps = {
4
- views: WidgetKindProps<TableOptions>['views'];
5
- /** The open view. */
6
- index: number;
7
- onChoose: (index: number) => void;
8
- };
9
- /**
10
- * A table's views as pill tabs under its title, each one click away; what doesn't fit folds into a
11
- * "+N" menu. Picking one swaps at once: the pill doesn't slide, as the table under it doesn't fade.
12
- */
13
- export declare function TableViewTabs({ views, index, onChoose }: TableViewTabsProps): import("react").JSX.Element;
14
- export {};