()
| 54 | }; |
| 55 | |
| 56 | export const ToolStatsDisplay: React.FC = () => { |
| 57 | const { stats } = useSessionStats(); |
| 58 | const { tools } = stats.metrics; |
| 59 | const activeTools = Object.entries(tools.byName).filter( |
| 60 | ([, metrics]) => metrics.count > 0, |
| 61 | ); |
| 62 | |
| 63 | if (activeTools.length === 0) { |
| 64 | return ( |
| 65 | <Box |
| 66 | borderStyle="round" |
| 67 | borderColor={Colors.Gray} |
| 68 | paddingY={1} |
| 69 | paddingX={2} |
| 70 | > |
| 71 | <Text>No tool calls have been made in this session.</Text> |
| 72 | </Box> |
| 73 | ); |
| 74 | } |
| 75 | |
| 76 | const totalDecisions = Object.values(tools.byName).reduce( |
| 77 | (acc, tool) => { |
| 78 | acc.accept += tool.decisions.accept; |
| 79 | acc.reject += tool.decisions.reject; |
| 80 | acc.modify += tool.decisions.modify; |
| 81 | return acc; |
| 82 | }, |
| 83 | { accept: 0, reject: 0, modify: 0 }, |
| 84 | ); |
| 85 | |
| 86 | const totalReviewed = |
| 87 | totalDecisions.accept + totalDecisions.reject + totalDecisions.modify; |
| 88 | const agreementRate = |
| 89 | totalReviewed > 0 ? (totalDecisions.accept / totalReviewed) * 100 : 0; |
| 90 | const agreementColor = getStatusColor(agreementRate, { |
| 91 | green: USER_AGREEMENT_RATE_HIGH, |
| 92 | yellow: USER_AGREEMENT_RATE_MEDIUM, |
| 93 | }); |
| 94 | |
| 95 | return ( |
| 96 | <Box |
| 97 | borderStyle="round" |
| 98 | borderColor={Colors.Gray} |
| 99 | flexDirection="column" |
| 100 | paddingY={1} |
| 101 | paddingX={2} |
| 102 | width={70} |
| 103 | > |
| 104 | <Text bold color={Colors.AccentPurple}> |
| 105 | Tool Stats For Nerds |
| 106 | </Text> |
| 107 | <Box height={1} /> |
| 108 | |
| 109 | {/* Header */} |
| 110 | <Box> |
| 111 | <Box width={TOOL_NAME_COL_WIDTH}> |
| 112 | <Text bold>Tool Name</Text> |
| 113 | </Box> |
nothing calls this directly
no test coverage detected