Skip to content
Merged
Show file tree
Hide file tree
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 @@ -260,7 +260,7 @@ export function TeamPlayerPeekPanel({ player, onClose }: TeamPlayerPeekPanelProp
{insight.title}
</p>
<p className="text-xs text-primary-700 line-clamp-2">
{insight.description}
{insight.body ?? insight.description}
</p>
</div>
))}
Expand Down
10 changes: 6 additions & 4 deletions src/components/baseball/player-profile/PlayerInsightsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ export function PlayerInsightsPanel({ insights, expanded = false }: PlayerInsigh
const colors = priorityColors[insight.priority] || priorityColors.low;
const isExpanded = expandedInsights.has(insight.id) || expanded;
const panelId = `insight-panel-${insight.id}`;
// Engine rows persist detail copy in `body`; legacy/manual rows use `description`.
const detail = insight.body ?? insight.description;

return (
<li
Expand All @@ -116,9 +118,9 @@ export function PlayerInsightsPanel({ insights, expanded = false }: PlayerInsigh
<p className={`font-medium text-sm leading-snug ${colors?.text ?? ''}`}>
{insight.title}
</p>
{!isExpanded && insight.description && (
{!isExpanded && detail && (
<p className="text-xs text-warm-500 mt-0.5 line-clamp-1">
{insight.description}
{detail}
</p>
)}
</div>
Expand All @@ -143,9 +145,9 @@ export function PlayerInsightsPanel({ insights, expanded = false }: PlayerInsigh
className="overflow-hidden"
>
<div className="px-4 pb-4 pt-0">
{insight.description && (
{detail && (
<p className="text-sm text-warm-600 mb-3 leading-relaxed">
{insight.description}
{detail}
</p>
)}

Expand Down
1 change: 1 addition & 0 deletions src/lib/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ export interface BaseballCoachInsight {

title: string;
description: string;
body?: string | null; // Engine-persisted insight text (baseball_coach_insights.body); UI reads body ?? description
Comment on lines 264 to +266

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

1. Insight type not type-safe 🐞 Bug ⚙ Maintainability

BaseballCoachInsight still requires description: string even though persisted
baseball_coach_insights rows (including engine-generated rows) use body and do not include a
description column, so TypeScript will continue to allow insight.description reads without
null/undefined handling. This undercuts the PR’s “type-safe” goal and makes it easy for future UI
code to regress back to rendering blank insight detail.
Agent Prompt
## Issue description
`BaseballCoachInsight` currently models `description` as a required string, but persisted CoachHelm insights are stored in `baseball_coach_insights.body` (and the generated DB types/schema reflect `body` with no `description`). This means UI code can compile while still incorrectly assuming `description` exists.

## Issue Context
This PR updates UI code to render `body ?? description`, implicitly acknowledging that `description` may be absent on engine rows.

## Fix Focus Areas
- src/lib/types/index.ts[255-279]

## Suggested fix
- Update `BaseballCoachInsight` so `description` is `optional` and `nullable` (e.g. `description?: string | null`) to match the reality that many rows will not have it.
- Keep `body?: string | null` (or make it non-optional if you want the interface to represent a full DB row), and consider adding a small comment/docstring clarifying that `body` is the persisted detail field and `description` is legacy/compat.
- Re-run TypeScript checks and update any callers that relied on `description` being required.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

recommendation?: string;
recommended_action?: string; // Alias for recommendation

Expand Down
Loading