refactor(components): decompose AnalyticsTab into per-section siblings#49
Merged
Merged
Conversation
Move the rating-distribution sub-component out of AnalyticsTab.tsx into its own file. Wave 5.2 of docs/plans/ancient-kindling-wilkes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move the KB article usage table out of AnalyticsTab.tsx into its own file. Wave 5.2. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move QualityDrilldownExamples + formatDrilldownMetric out of AnalyticsTab.tsx into their own file. Wave 5.2. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move ResponseQualityPanel out of AnalyticsTab.tsx into its own file. The panel owns its imports of buildResponseQualityCoaching, buildOperatorScorecard, loadQueueHandoffSnapshot, and renders QualityDrilldownExamples internally. Wave 5.2. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move PilotDiagnosticsSection + its PilotLoggingPolicy type + the get_pilot_logging_policy invoke call out of AnalyticsTab.tsx into its own file. Wave 5.2. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move the response-quality-thresholds sync wiring out of AnalyticsTab.tsx into a pure helper module: readCurrentThresholds (initial value) + subscribeToQualityThresholds (event listeners with returned cleanup). Shell useEffect shrinks to two lines. Wave 5.2. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Extract the loadData promise fanout, period/loading/error state, data slices (summary/kbUsage/qualitySummary/qualityDrilldown/ lowRatingData/gapCandidates), and the KB-gap-status mutator into useAnalyticsLoader. Shell consumes the hook and keeps only activeSection, qualityThresholds, and selectedArticleId state. Wave 5.2. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add focused tests for the five Analytics siblings extracted in this PR: RatingDistribution (empty + populated), KbUsageTable (empty + click callback), QualityDrilldownExamples (null payload + populated + format helper), ResponseQualityPanel (empty + metric grid), PilotDiagnosticsSection (policy load + reject fallback). +11 tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Decompose
src/components/Analytics/AnalyticsTab.tsx(829 → 361LOC) into 5 sibling section components + a data-loader hook +
threshold-sync pure helpers. Adds 11 focused per-section tests.
Wave 5.2 of docs/plans/ancient-kindling-wilkes.
Why
Each internal named section (PilotDiagnosticsSection,
ResponseQualityPanel, QualityDrilldownExamples, RatingDistribution,
KbUsageTable) already had clean prop boundaries — extraction is
free, and per-section tests now mock only the hooks that section
actually needs.
How
8 commits:
RatingDistribution.tsx— siblingKbUsageTable.tsx— siblingQualityDrilldownExamples.tsx— sibling +formatDrilldownMetricResponseQualityPanel.tsx— sibling, owns coaching/scorecard importsPilotDiagnosticsSection.tsx— sibling with its own invoke + policyqualityThresholdsState.ts—readCurrentThresholds+subscribeToQualityThresholdspure helpersuseAnalyticsLoader.ts—loadDatafanout + data slices +period/loading/error state + gap-status mutator
AnalyticsTab.tsxkeeps its default export andAnalyticsTabPropscontract.
AnalyticsPage.tsxconsumer unchanged.Testing
pnpm ui:gate:static— cleanpnpm test— 150/150 passing (+11 from this PR)AnalyticsTab.test.tsxomnibus passes unchanged —extraction preserves the public default export
Performance impact
Risk / Notes
AnalyticsPage.tsx+ omnibus test) — publicsurface unchanged
src/components/Analytics/Screenshots
N/A — internals only.
Lockfile rationale
No lockfile changes.