refactor(components): decompose ResponsePanel into helpers + hook + sections#48
Merged
Merged
Conversation
Lift six pure helpers (parseResponseSections, getModeLabel, getConfidenceLevel, getSearchMethodLabel, getSourceTypeLabel, getScoreBarClassName) out of ResponsePanel.tsx into a sibling module. Wave 5.1 of docs/plans/ancient-kindling-wilkes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add 9 tests for the six helpers extracted in the prior commit: parseResponseSections legacy + split paths, getModeLabel mode mappings, getConfidenceLevel band classifier, the two label mappers, and getScoreBarClassName CSS buckets. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move the 5 copy/export state slots, the click-outside effect, and the three copy/export callbacks into useResponsePanelCopy. Shell consumes the hook and keeps only source-toggle/section-tab state. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Lift the OUTPUT / IT SUPPORT INSTRUCTIONS tab switcher and its textarea/instructions content view out of ResponsePanel.tsx. Shell passes parsed sections + activeSection + setter + onResponseChange as props so parse-once lives at the parent. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add the first tests for ResponsePanel.tsx: happy-path render, copy-gating + audit override flow, and source-row expansion that fetches preview chunks. Mocks invoke, toast context, and the two child panels that make Tauri calls. 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/Draft/ResponsePanel.tsx(747 → 534 LOC)by extracting pure helpers, a copy/export state hook, and the
OUTPUT/INSTRUCTIONS sections sub-component. Adds the file's
first-ever tests. Wave 5.1 of docs/plans/ancient-kindling-wilkes.
Why
Reduce a 747-LOC monolith so future edits stay in a quarter of
the original file. Establishes the Wave 5 pattern: preserve the
public export, extract to siblings, test each unit.
How
5 commits:
responsePanelHelpers.ts— 6 pure functions lifted outresponsePanelHelpers.test.ts— 9 unit testsuseResponsePanelCopy.ts— 5 state slots + click-outsideeffect + copy/export/override callbacks
ResponsePanelSections.tsx— section-tab + textarea/instructions view
ResponsePanel.test.tsx— 3 integration tests (render,copy-with-override audit, source expansion fetch)
ResponsePanel.tsxkeeps its named export and props contract.DraftTab.tsxconsumer is unchanged.Testing
pnpm ui:gate:static— cleanpnpm test— 139/139 passing (+12 new)Performance impact
Risk / Notes
not regression risk.
is the sources panel / grounding list JSX, which the plan did
not call out for extraction. Deferring further shrinkage.
Screenshots
N/A — internals only.
Lockfile rationale
No lockfile changes.