-
Notifications
You must be signed in to change notification settings - Fork 439
feat: implement TDD improvements for transcript and segment logic (10/10 issues) #1817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: implement TDD improvements for transcript and segment logic (10/10 issues) #1817
Conversation
- Issue #1: Fix partial hints index mismatch after filtering - Added index mapping to track position changes when filtering partial words - Changed filtering condition from > to >= to keep consecutive words - Added comprehensive tests for index adjustment scenarios - Issue #3: Add memory leak prevention safeguards - Implemented MAX_PARTIAL_WORDS (1000) and MAX_PARTIAL_HINTS (1000) limits - Added automatic cleanup when limits are exceeded - Adjusted hint indices when trimming old partial words - Issue #4: Add input validation for transcript handling - Validate channelIndex bounds (0-255) - Verify words are properly ordered by timestamp - Handle undefined channelIndex and missing alternatives gracefully - Issue #5: Improve string matching and add logging - Added console.warn when words not found in transcript - Log includes word, transcript, position, and wordIndex for debugging - Added tests for edge cases (empty transcript, empty words array) - Issue #8: Make gap threshold configurable - Added optional maxGapMs parameter to buildSegments - Defaults to 2000ms when not specified - Allows per-call customization of segment gap threshold All changes follow TDD approach with tests written first, then implementations. All unit tests passing (12 transcript tests, 8 utils tests, 6+ segment tests). Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
✅ Deploy Preview for hyprnote ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
- Issue #2: Added tests for out-of-order partial word management - Tests verify words aren't lost when partial results arrive out of order - Tests verify overlapping partial results are handled correctly - All tests passing - existing implementation already handles this correctly - Issue #9: Added tests for partial word extension edge cases - Tests verify partial words can extend segments with all partial words - Tests verify partial words with speaker identity can extend final word segments - Tests verify gap handling between partial words - Tests verify anonymous segment extension - All tests passing - existing implementation already handles edge cases correctly Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
- Import RuntimeSpeakerHint type from segment module - Remove isFinal property from WordLike objects (final vs partial distinction is encoded by array parameter) - All 38 tests passing including 4 new Issue #9 tests Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
cd99174 to
cb527d5
Compare
feat: implement TDD improvements for transcript and segment logic (10/10 issues)
Summary
This PR addresses all 10 identified issues in the transcript handling and segment logic using Test-Driven Development (TDD). Changes include code fixes with comprehensive unit tests, verification tests for existing correct behavior, and documentation of already well-structured code.
Issues Fixed with Code Changes (5/10):
Issue i editor #1: Partial Hints Index Mismatch - Fixed index adjustment when filtering partial words after final words arrive. Added Map-based tracking to correctly remap hint indices to filtered array positions. Changed filtering condition from
>to>=to properly handle consecutive words.Issue migration to radix primitive #3: Memory Leak Prevention - Added hard limits (MAX_PARTIAL_WORDS=1000, MAX_PARTIAL_HINTS=1000) to prevent unbounded growth of partial data. Automatically trims oldest words when limits are exceeded with proper index adjustment.
Issue Component modularization #4: Input Validation - Added validation for channelIndex bounds (0-255) and word timestamp ordering. Throws descriptive errors for invalid inputs instead of silently failing.
Issue Setup and cleanup Tauri plugins #5: String Matching Logging - Added console.warn when words aren't found in transcript during spacing fixup, including diagnostic context (word, transcript, position, wordIndex).
Issue Add login page in Tauri #8: Configurable Gap Threshold - Made segment gap threshold configurable via optional
maxGapMsparameter inbuildSegments(), defaulting to 2000ms for backward compatibility.Issues Verified Through Tests (2/10):
Issue editor is working #2: Race Conditions in Partial Word Management - Added comprehensive tests to verify out-of-order partial word handling. Tests confirm that the existing time-based filtering logic (before/after arrays) correctly handles out-of-order partial results without losing words. No code changes needed.
Issue Update landing page #9: Partial Word Extension Edge Cases - Added comprehensive tests to verify partial word extension logic handles all edge cases correctly (all-partial segments, speaker identity inheritance, gap handling, anonymous segments). Tests confirm existing implementation already handles these cases properly. No code changes needed.
Issues Already Well-Structured (3/10):
Issue Update landing page #10: Identity Resolution Rule Priority - Rule priority is clearly defined by code structure in
applyIdentityRulesfunction (lines 50-54 of pass-resolve-speakers.ts). The ordered array documents the priority: explicit assignment → speaker index mapping → channel mapping → carry forward. Each rule function has early returns that respect previous rules' decisions.Issue Add audio format converter in swift crate #6: Complex Segment Extension Logic - The
canExtendfunction is already well-refactored with helper functionscanExtendWithSpeakerIdentityandcanExtendNonLastSegmentin pass-build-segments.ts. Each helper has a single, clear responsibility.Issue landing v0 #7: State Mutation in Pipeline - State mutations are localized to
rememberIdentityfunction in pass-resolve-speakers.ts. Reads use immutableSpeakerStateSnapshottype. Mutations are intentional for performance and contained within the pass.Test Coverage:
Updates Since Last Revision:
isFinalproperty fromWordLikeobjects, importedRuntimeSpeakerHinttype)Review & Testing Checklist for Human
Verify Issues Update landing page #10, Add audio format converter in swift crate #6, landing v0 #7 approach - These 3 issues were addressed by documenting existing well-structured code rather than making changes. Confirm this meets your expectations or if you want additional refactoring/tests.
Test real recording session - Start a recording and verify that partial transcripts update correctly and final transcripts don't lose words. Pay special attention to speaker hints remaining accurate.
Verify memory limits are appropriate - The 1000 word/hint limits are arbitrary. Test with a 2+ hour meeting to ensure this doesn't cause issues. Consider if trimming oldest words is the right strategy.
Test Plan
Notes
Devin Session: https://app.devin.ai/sessions/51e4365e8e604529b6901744a099ad61
Requested by: @yujonglee (yujonglee.dev@gmail.com)