import { relative } from 'path'; import React from 'react'; import { Box, Text } from '@anthropic/ink'; import { DiagnosticTrackingService } from '../services/diagnosticTracking.js'; import type { Attachment } from '../utils/attachments.js'; import { getCwd } from '../utils/cwd.js'; import { CtrlOToExpand } from './CtrlOToExpand.js'; import { MessageResponse } from './MessageResponse.js'; type DiagnosticsAttachment = Extract; type DiagnosticsDisplayProps = { attachment: DiagnosticsAttachment; verbose: boolean; }; export function DiagnosticsDisplay({ attachment, verbose }: DiagnosticsDisplayProps): React.ReactNode { // Only show if there are diagnostics to report if (attachment.files.length === 0) return null; // Count total issues const totalIssues = attachment.files.reduce((sum, file) => sum + file.diagnostics.length, 0); const fileCount = attachment.files.length; if (verbose) { // Show all diagnostics in verbose mode (ctrl+o) return ( {attachment.files.map((file, fileIndex) => ( {relative(getCwd(), file.uri.replace('file://', '').replace('_claude_fs_right:', ''))}{' '} {file.uri.startsWith('file://') ? '(file://)' : file.uri.startsWith('_claude_fs_right:') ? '(claude_fs_right)' : `(${file.uri.split(':')[0]})`} : {file.diagnostics.map((diagnostic, diagIndex) => ( {' '} {DiagnosticTrackingService.getSeveritySymbol(diagnostic.severity)} {' [Line '} {diagnostic.range.start.line + 1}:{diagnostic.range.start.character + 1} {'] '} {diagnostic.message} {diagnostic.code ? ` [${diagnostic.code}]` : ''} {diagnostic.source ? ` (${diagnostic.source})` : ''} ))} ))} ); } else { // Show summary in normal mode return ( Found {totalIssues} new diagnostic {totalIssues === 1 ? 'issue' : 'issues'} in {fileCount}{' '} {fileCount === 1 ? 'file' : 'files'} ); } }