-
Notifications
You must be signed in to change notification settings - Fork 341
Add overview support and emitter display names to spec-dashboard #9891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
timotheeguerin
merged 3 commits into
microsoft:main
from
joheredi:feature/spec-dashboard-overview
Mar 4, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
.chronus/changes/spec-dashboard-overview-2026-03-03-23-31-23.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| changeKind: internal | ||
| packages: | ||
| - "@typespec/spec-dashboard" | ||
| --- | ||
|
|
||
| Add coverage overview component and emitter display name support |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
182 changes: 182 additions & 0 deletions
182
packages/spec-dashboard/src/components/coverage-overview.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,182 @@ | ||
| import { Card, Text, tokens } from "@fluentui/react-components"; | ||
| import { FunctionComponent, useMemo } from "react"; | ||
| import { CoverageSummary } from "../apis.js"; | ||
| import { GroupRatioColors, GroupRatios } from "../constants.js"; | ||
|
|
||
| interface EmitterOverview { | ||
| name: string; | ||
| displayName: string; | ||
| coverageRatio: number; | ||
| } | ||
|
|
||
| export interface CoverageOverviewProps { | ||
| coverageSummaries: CoverageSummary[]; | ||
| emitterDisplayNames?: Record<string, string>; | ||
| } | ||
|
|
||
| /** | ||
| * Extracts a display-friendly name from a full emitter package name. | ||
| * e.g. "@typespec/http-client-python" → "Python" | ||
| */ | ||
| function getEmitterDisplayName( | ||
| emitterName: string, | ||
| report: CoverageSummary["generatorReports"][string], | ||
| emitterDisplayNames?: Record<string, string>, | ||
| ): string { | ||
| if (emitterDisplayNames?.[emitterName]) { | ||
| return emitterDisplayNames[emitterName]; | ||
| } | ||
| if (report?.generatorMetadata?.name) { | ||
| return report.generatorMetadata.name; | ||
| } | ||
| // Strip common prefix patterns | ||
| const match = emitterName.match(/http-client-(\w+)$/); | ||
| if (match) { | ||
| return match[1].charAt(0).toUpperCase() + match[1].slice(1); | ||
| } | ||
| return emitterName; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the accent color for a coverage ratio using the same thresholds as the coverage tables. | ||
| */ | ||
| function getOverviewColor(ratio: number): string { | ||
| for (const [key, threshold] of Object.entries(GroupRatios)) { | ||
| if (ratio >= threshold) { | ||
| return GroupRatioColors[key as keyof typeof GroupRatios]; | ||
| } | ||
| } | ||
| return GroupRatioColors.zero; | ||
| } | ||
|
|
||
| /** | ||
| * Displays a section with a grid of cards showing per-emitter coverage overview. | ||
| */ | ||
| export const CoverageOverview: FunctionComponent<CoverageOverviewProps> = ({ | ||
| coverageSummaries, | ||
| emitterDisplayNames, | ||
| }) => { | ||
| const emitterOverviews = useMemo(() => { | ||
| // Aggregate scenarios per emitter across all summaries | ||
| const emitterMap = new Map< | ||
| string, | ||
| { | ||
| totalScenarios: number; | ||
| coveredScenarios: number; | ||
| report: CoverageSummary["generatorReports"][string]; | ||
| } | ||
| >(); | ||
|
|
||
| for (const summary of coverageSummaries) { | ||
| for (const [emitterName, report] of Object.entries(summary.generatorReports)) { | ||
| if (!emitterMap.has(emitterName)) { | ||
| emitterMap.set(emitterName, { totalScenarios: 0, coveredScenarios: 0, report }); | ||
| } | ||
| const entry = emitterMap.get(emitterName)!; | ||
| const scenarios = summary.manifest.scenarios; | ||
| entry.totalScenarios += scenarios.length; | ||
| if (report) { | ||
| for (const scenario of scenarios) { | ||
| const status = report.results[scenario.name]; | ||
| if (status === "pass" || status === "not-applicable" || status === "not-supported") { | ||
| entry.coveredScenarios++; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const overviews: EmitterOverview[] = []; | ||
| for (const [emitterName, data] of emitterMap) { | ||
| overviews.push({ | ||
| name: emitterName, | ||
| displayName: getEmitterDisplayName(emitterName, data.report, emitterDisplayNames), | ||
| coverageRatio: data.totalScenarios > 0 ? data.coveredScenarios / data.totalScenarios : 0, | ||
| }); | ||
| } | ||
|
|
||
| return overviews; | ||
| }, [coverageSummaries, emitterDisplayNames]); | ||
|
|
||
| if (emitterOverviews.length === 0) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <section | ||
| css={{ | ||
| marginBottom: 32, | ||
| padding: "20px 24px", | ||
| backgroundColor: tokens.colorNeutralBackground2, | ||
| borderRadius: tokens.borderRadiusXLarge, | ||
| border: `1px solid ${tokens.colorNeutralStroke2}`, | ||
| }} | ||
| > | ||
| <Text | ||
| as="h2" | ||
| weight="semibold" | ||
| size={500} | ||
| css={{ | ||
| display: "block", | ||
| marginBottom: 16, | ||
| color: tokens.colorNeutralForeground1, | ||
| }} | ||
| > | ||
| Coverage Overview | ||
| </Text> | ||
| <div | ||
| css={{ | ||
| display: "grid", | ||
| gridTemplateColumns: "repeat(auto-fill, minmax(200px, 1fr))", | ||
| gap: 16, | ||
| }} | ||
| > | ||
| {emitterOverviews.map((emitter) => ( | ||
| <EmitterOverviewCard key={emitter.name} emitter={emitter} /> | ||
| ))} | ||
| </div> | ||
| </section> | ||
| ); | ||
| }; | ||
|
|
||
| interface EmitterOverviewCardProps { | ||
| emitter: EmitterOverview; | ||
| } | ||
|
|
||
| const EmitterOverviewCard: FunctionComponent<EmitterOverviewCardProps> = ({ emitter }) => { | ||
| const accentColor = getOverviewColor(emitter.coverageRatio); | ||
| const percentage = Math.floor(emitter.coverageRatio * 100); | ||
|
|
||
| return ( | ||
| <Card | ||
| css={{ | ||
| backgroundColor: tokens.colorNeutralBackground1, | ||
| borderTop: `3px solid ${accentColor}`, | ||
| padding: "16px 16px 20px", | ||
| textAlign: "center", | ||
| display: "flex", | ||
| flexDirection: "column", | ||
| alignItems: "center", | ||
| gap: 4, | ||
| minHeight: 100, | ||
| }} | ||
| > | ||
| <Text | ||
| weight="semibold" | ||
| size={300} | ||
| css={{ | ||
| color: tokens.colorNeutralForeground2, | ||
| minHeight: `calc(${tokens.lineHeightBase300})`, | ||
| display: "flex", | ||
| alignItems: "center", | ||
| textAlign: "center", | ||
| }} | ||
| > | ||
| {emitter.displayName} | ||
| </Text> | ||
| <Text weight="bold" size={800} css={{ color: accentColor }}> | ||
| {percentage}% | ||
| </Text> | ||
| </Card> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.