Repository navigation
refactor: tidy useGuidedPhraseSegments after TT-7661 - #771
Conversation
Follow-up cleanup from the #762 review. Drop the redundant phraseSegString return value (callers read phraseSegs.segments), rename the internal setter to setPhraseSegsForCurrentMedia so it's clear it stamps the current media id, and delete the unused useCarefulSpeechSegments wrapper and re-export file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
It is a small, verified no-behavior-change cleanup where all removed symbols are confirmed unused and all callers/mocks are consistently updated.
No open issues 🎉
What changed in this PR
This is a follow-up cleanup to PR #762 (TT-7661) with no intended behavior change. It tidies useGuidedPhraseSegments by removing a redundant return value and dead code, and renames an internal setter for clarity. The hook powers Careful Speech / Phrase Back Translation segment loading in the PassageDetail recording flow.
Changes:
- Dropped the redundant
phraseSegStringfrom the hook's return (callers now readphraseSegs.segments, the media-stamped value), and derivedclauseSegStringlocally inPassageDetailGuidedPhraseRecord.tsx. - Renamed the internal setter to
setPhraseSegsForCurrentMedia(still exposed publicly assetPhraseSegString) to clarify it stamps the current recording's id. - Removed the unused
useCarefulSpeechSegmentswrapper and deleted its re-export fileuseCarefulSpeechSegments.ts; updated five test mocks to match the new return shape.
| File | Description |
|---|---|
carefulSpeech/useGuidedPhraseSegments.ts |
Renames internal setter, drops redundant phraseSegString return, removes unused useCarefulSpeechSegments wrapper |
carefulSpeech/useCarefulSpeechSegments.ts |
Deletes the now-unused re-export file |
PassageDetailGuidedPhraseRecord.tsx |
Derives clauseSegString from clauseSegs.segments instead of the removed return field |
carefulSpeech/useGuidedPhraseSegments.test.tsx |
Reads phraseSegs.segments in assertions |
PassageDetailPhraseBackTranslate.undo.test.tsx |
Drops phraseSegString from the hook mock |
PassageDetailGuidedPhraseRecord.stepScope.test.tsx |
Drops phraseSegString from the hook mock |
PassageDetailGuidedPhraseRecord.nextDuringPlayback.test.tsx |
Drops phraseSegString from the hook mock |
PassageDetailCarefulSpeech.test.tsx |
Drops phraseSegString from the hook mock |
I verified that the deleted useCarefulSpeechSegments.ts file has no remaining importers, that no caller reads .phraseSegString off the hook result, that GuidedPhraseSegmentsOptions is only consumed in-file, and that the in-hook imports remain in use. The derived clauseSegString = clauseSegs.segments is equivalent to the previously returned value, so behavior is preserved. No issues found.
Review effort: Balanced
gtryus
left a comment
There was a problem hiding this comment.
One issue remains, and both reviewers flagged it. The #762 reviewer (nabalone) asked for the setter to be renamed "so it doesn't look like a state setter". The PR renames it only inside the hook. It still returns it as setPhraseSegString (useGuidedPhraseSegments.ts:317). The caller then renames it again to setClauseSegString (PassageDetailGuidedPhraseRecord.tsx:448) and wraps it in setClauseSeg, so one setter goes by four names. This breaks CODING_STANDARDS "Naming conventions" (a judgement call, a Mysterious Name smell). The goal is to expose the honest name at the API boundary.
Return the setter under its honest name instead of setPhraseSegString, and drop the caller's extra setClauseSegString alias. The caller's ref-syncing wrapper becomes setClauseSegsForCurrentMedia, so the setter goes by one name in the hook and one in the caller. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follow-up cleanup from the #762 (TT-7661) review. No behavior change.
useGuidedPhraseSegmentsno longer returns the redundantphraseSegString; callers readphraseSegs.segments(the media-stamped value).setPhraseSegsForCurrentMediato make clear it stamps the current recording's id (still exposed assetPhraseSegString).useCarefulSpeechSegmentswrapper and its re-export fileuseCarefulSpeechSegments.ts.Test plan
npm run typechecknpx jest src/components/PassageDetail— 337/337 pass🤖 Generated with Claude Code