Add lowercase and punctuation paste transforms#253
Conversation
Add independent settings to lowercase pasted transcripts and remove Unicode punctuation. Persist both options, include them in the transforms preview, and apply them after existing word modifications before paste and history storage. Cover formatting combinations and legacy settings migration with tests. Opencode-Session: ses_0bd949d00fferT6nCF6ntO80Mp Opencode-Message: msg_f42760e83001l5zbmkL7mxckWu Opencode-Agent: build
Opencode-Session: ses_0bd949d00fferT6nCF6ntO80Mp Opencode-Message: msg_f4276da02001R7u6klN4JoUXT7 Opencode-Agent: build
📝 WalkthroughWalkthroughAdds two transcript formatting options—lowercase and punctuation removal—via a new ChangesPaste Formatting Feature
Estimated code review effort: 2 (Simple) | ~12 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant WordRemappingsView
participant SettingsFeature
participant TranscriptionFeature
participant TranscriptFormattingApplier
User->>WordRemappingsView: Toggle "Lowercase Everything" / "Remove All Punctuation"
WordRemappingsView->>SettingsFeature: setLowercaseTranscripts / setRemovePunctuation
SettingsFeature->>SettingsFeature: Update state.hexSettings
WordRemappingsView->>TranscriptFormattingApplier: apply(previewText, lowercase, removePunctuation)
TranscriptFormattingApplier-->>WordRemappingsView: formatted preview text
Note over TranscriptionFeature: On new transcription result
TranscriptionFeature->>TranscriptFormattingApplier: apply(remappedResult, lowercaseTranscripts, removePunctuation)
TranscriptFormattingApplier-->>TranscriptionFeature: formatted text
TranscriptionFeature->>TranscriptionFeature: modifiedResult = formatted text
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
Hex/Features/Transcription/TranscriptionFeature.swift (1)
461-462: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider logging which formatting options were applied.
The log message
"Applied paste formatting"doesn't indicate whether lowercasing, punctuation removal, or both triggered the change. Including the active flags (e.g.,"Applied paste formatting (lowercase: true, removePunctuation: false)") would aid debugging without exposing sensitive transcript content.🔧 Suggested log improvement
if formattedResult != remappedResult { - transcriptionFeatureLogger.info("Applied paste formatting") + transcriptionFeatureLogger.info("Applied paste formatting (lowercase: \(state.hexSettings.lowercaseTranscripts), removePunctuation: \(state.hexSettings.removePunctuation))") }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Hex/Features/Transcription/TranscriptionFeature.swift` around lines 461 - 462, The paste-formatting log in TranscriptionFeature should include which formatting flags were active instead of only saying “Applied paste formatting.” Update the logging in the formatting branch around the formattedResult/remappedResult comparison to report the state of the lowercase and removePunctuation options so the message clearly identifies which transformation(s) caused the change, while keeping transcript content out of the log.Hex/Features/Remappings/WordRemappingsView.swift (1)
244-248: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider extracting
removalsSectionor renaming it.The new "Paste Formatting" GroupBox lives inside
removalsSection, which is only visible under the "Removals" tab. Since paste formatting is conceptually distinct from word removals, users may not discover these toggles when navigating to "Remappings" or expecting a separate section. Consider either renamingremovalsSectionto something broader (e.g.,modificationsSection) or pulling the GroupBox into its own section.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Hex/Features/Remappings/WordRemappingsView.swift` around lines 244 - 248, The Paste Formatting GroupBox is currently embedded in `removalsSection`, which makes it look like it belongs only to word removals and can hide it from users browsing remappings/modification controls. Update `WordRemappingsView` by either renaming `removalsSection` to a broader, more accurate name such as `modificationsSection`, or by extracting the Paste Formatting GroupBox into its own dedicated section so the UI grouping matches the functionality.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@HexCore/Sources/HexCore/Models/TranscriptFormatting.swift`:
- Around line 10-12: The punctuation stripping in TranscriptFormatting’s
removePunctuation path is too aggressive and can corrupt numeric text like
decimals and grouped numbers. Update the logic in the relevant formatting method
to preserve punctuation used within numbers (for example decimal points and
thousands separators) or explicitly constrain the transformation to non-numeric
punctuation, using the existing removePunctuation branch in TranscriptFormatting
as the place to fix it.
---
Nitpick comments:
In `@Hex/Features/Remappings/WordRemappingsView.swift`:
- Around line 244-248: The Paste Formatting GroupBox is currently embedded in
`removalsSection`, which makes it look like it belongs only to word removals and
can hide it from users browsing remappings/modification controls. Update
`WordRemappingsView` by either renaming `removalsSection` to a broader, more
accurate name such as `modificationsSection`, or by extracting the Paste
Formatting GroupBox into its own dedicated section so the UI grouping matches
the functionality.
In `@Hex/Features/Transcription/TranscriptionFeature.swift`:
- Around line 461-462: The paste-formatting log in TranscriptionFeature should
include which formatting flags were active instead of only saying “Applied paste
formatting.” Update the logging in the formatting branch around the
formattedResult/remappedResult comparison to report the state of the lowercase
and removePunctuation options so the message clearly identifies which
transformation(s) caused the change, while keeping transcript content out of the
log.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0992c3a1-ff28-44c7-9d44-1ad73aac4768
📒 Files selected for processing (8)
.changeset/b80ca233.mdHex/Features/Remappings/WordRemappingsView.swiftHex/Features/Settings/SettingsFeature.swiftHex/Features/Transcription/TranscriptionFeature.swiftHexCore/Sources/HexCore/Models/TranscriptFormatting.swiftHexCore/Sources/HexCore/Settings/HexSettings.swiftHexCore/Tests/HexCoreTests/HexSettingsMigrationTests.swiftHexCore/Tests/HexCoreTests/TranscriptFormattingTests.swift
| if removePunctuation { | ||
| output = output.components(separatedBy: .punctuationCharacters).joined() | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Punctuation removal may alter numbers in transcripts.
components(separatedBy: .punctuationCharacters).joined() strips all Unicode punctuation including decimal points and thousands separators. A transcript containing "3.14" or "1,000" would become "314" or "1000". If transcripts can contain numeric values, consider preserving decimal points and digit-grouping commas, or document this as expected behavior.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@HexCore/Sources/HexCore/Models/TranscriptFormatting.swift` around lines 10 -
12, The punctuation stripping in TranscriptFormatting’s removePunctuation path
is too aggressive and can corrupt numeric text like decimals and grouped
numbers. Update the logic in the relevant formatting method to preserve
punctuation used within numbers (for example decimal points and thousands
separators) or explicitly constrain the transformation to non-numeric
punctuation, using the existing removePunctuation branch in TranscriptFormatting
as the place to fix it.
Summary
Testing
swift test --filter TranscriptFormattingTestsDEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer xcodebuild -scheme Hex -configuration Debug build CODE_SIGNING_ALLOWED=NO -skipMacroValidationgit diff --checkSummary by CodeRabbit