Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ import {
IconGauge,
IconTrendingUp,
IconTrendingDown,
IconMinus,
IconHelp,
IconTrophy,
IconShieldAlert,
IconCalendar,
Expand Down Expand Up @@ -154,6 +156,31 @@ function verdictPresentation(
}
}

// --- Practice Effectiveness direction presentation --------------------------
// Honest by construction: only 'regressed' earns danger styling. 'no_change'
// (metric held steady) and null (insufficient sample) read neutral — they were
// previously mislabeled as "Moved the wrong way" in red. (Issue #498)
interface EffectivenessPresentation {
label: string;
tone: 'success' | 'danger' | 'secondary';
/** Direction glyph for the badge. */
glyph: 'up' | 'down' | 'flat' | 'unknown';
}
function effectivenessPresentation(
direction: DecisionRoomEffectivenessReview['direction'],
): EffectivenessPresentation {
switch (direction) {
case 'improved':
return { label: 'Associated improvement', tone: 'success', glyph: 'up' };
case 'regressed':
return { label: 'Moved the wrong way', tone: 'danger', glyph: 'down' };
case 'no_change':
return { label: 'Held steady', tone: 'secondary', glyph: 'flat' };
default:
return { label: 'Not enough data', tone: 'secondary', glyph: 'unknown' };
}
}

/** Format a metric value honoring its unit (pct → %, else 1-dp number). */
function formatMetricValue(value: number | null, unit: string | null): string {
if (value == null) return '—';
Expand Down Expand Up @@ -1263,16 +1290,24 @@ function EffectivenessReviewRow({
}: {
review: DecisionRoomEffectivenessReview;
}) {
const improved = review.direction === 'improved';
const pres = effectivenessPresentation(review.direction);
return (
<Card variant="raised" padding="md">
<CardContent className="p-0">
<div className="mb-1 flex flex-wrap items-center gap-2">
<Badge variant={improved ? 'success' : 'danger'}>
<Badge variant={pres.tone}>
<span className="mr-1 inline-flex">
{improved ? <IconTrendingUp size={12} /> : <IconTrendingDown size={12} />}
{pres.glyph === 'up' ? (
<IconTrendingUp size={12} />
) : pres.glyph === 'down' ? (
<IconTrendingDown size={12} />
) : pres.glyph === 'flat' ? (
<IconMinus size={12} />
) : (
<IconHelp size={12} />
)}
</span>
{improved ? 'Associated improvement' : 'Moved the wrong way'}
{pres.label}
</Badge>
<span className="inline-flex items-center gap-1 text-xs text-warm-400">
<IconGauge size={12} />
Expand Down
Loading