Skip to content

Fix transcript editor performance problem #913

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

Merged
merged 3 commits into from
Jun 4, 2025
Merged

Conversation

yujonglee
Copy link
Contributor

No description provided.

Copy link

coderabbitai bot commented Jun 3, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The change updates the seeding logic in the seed function, specifically altering how the words field of a Session is initialized. Instead of using a single deserialized list, the new approach repeats the original list 100 times to create a longer vector for the words field. Additionally, another session's words field is now explicitly initialized. Multiple transcript editor components were refactored by removing the WordSplit extension and WordNode, simplifying word handling to plain text nodes without per-word metadata. The SearchAndReplace component was modified to debounce search term updates. Corresponding CSS styles for transcript words were removed.

Changes

File(s) Change Summary
crates/db-user/src/init.rs Modified seed function to initialize Session.words by repeating the original word list 100 times; added explicit initialization for another session's words.
apps/desktop/src/components/right-panel/views/transcript-view.tsx Changed SearchAndReplace component to debounce search term updates with a 300ms delay instead of immediate updates.
packages/tiptap/src/styles/transcript.css Removed all styles related to .transcript-word and its pseudo-elements and hover states.
packages/tiptap/src/transcript/extensions.ts Removed entire WordSplit extension; updated SpeakerSplit extension's Enter key handling to split at word boundaries with custom logic.
packages/tiptap/src/transcript/index.tsx Removed WordSplit and WordNode imports and extensions; added appendWords method to TranscriptEditorRef for inserting words at document end.
packages/tiptap/src/transcript/nodes.ts Removed WordNode definition; changed SpeakerNode content from "word*" to "inline*".
packages/tiptap/src/transcript/utils.ts Removed WordContent type; changed SpeakerContent to hold plain text nodes; updated conversion functions to concatenate words into single text nodes, losing per-word metadata.
packages/tiptap/src/transcript/utils.test.ts Updated "conversion" test to reflect removal of word nodes and per-word metadata, expecting concatenated text nodes instead.

Sequence Diagram(s)

sequenceDiagram
    participant SeedFunction
    participant JSONSource
    participant WordList

    SeedFunction->>JSONSource: Deserialize JSON to Vec<Word>
    JSONSource-->>SeedFunction: Return original word list
    SeedFunction->>WordList: Create new vector with 100x capacity
    loop 100 times
        SeedFunction->>WordList: Clone and append original word list
    end
    SeedFunction-->>Session: Set words field to extended list
Loading
sequenceDiagram
    participant User
    participant SearchAndReplace
    participant Editor

    User->>SearchAndReplace: Input search term
    SearchAndReplace->>SearchAndReplace: Debounce 300ms
    SearchAndReplace->>Editor: Set search term (debounced)
    alt Replace term condition met
        SearchAndReplace->>Editor: Update replace term
    end
Loading
sequenceDiagram
    participant User
    participant Editor
    participant SpeakerSplitExtension

    User->>Editor: Press Enter key
    Editor->>SpeakerSplitExtension: handleKeyDown event
    SpeakerSplitExtension->>Editor: Calculate split position at word boundary
    SpeakerSplitExtension->>Editor: Dispatch split transaction with new speaker node
    Editor->>User: Cursor moves to new speaker node
Loading

Possibly related PRs

  • Transcript editor styling #873: Introduces the SearchAndReplace UI component and integrates it into the transcript view, related to the debounced search term update logic changes in this PR.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c9ee9b1 and 6fec6e6.

📒 Files selected for processing (8)
  • apps/desktop/src/components/right-panel/views/transcript-view.tsx (2 hunks)
  • crates/db-user/src/init.rs (2 hunks)
  • packages/tiptap/src/styles/transcript.css (0 hunks)
  • packages/tiptap/src/transcript/extensions.ts (1 hunks)
  • packages/tiptap/src/transcript/index.tsx (3 hunks)
  • packages/tiptap/src/transcript/nodes.ts (1 hunks)
  • packages/tiptap/src/transcript/utils.test.ts (3 hunks)
  • packages/tiptap/src/transcript/utils.ts (3 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
crates/db-user/src/init.rs (1)

322-332: Optimize the word list repetition logic.

The implementation correctly creates a 10x repeated word list for performance testing, but the current approach clones the entire vector 10 times in a loop, which is inefficient.

Consider this more efficient approach:

-            words: {
-                let words = serde_json::from_str::<Vec<hypr_listener_interface::Word>>(
-                    &hypr_data::english_4::WORDS_JSON,
-                )
-                .unwrap();
-                let mut repeated = Vec::with_capacity(words.len() * 10);
-                for _ in 0..10 {
-                    repeated.extend(words.clone());
-                }
-                repeated
-            },
+            words: {
+                let words = serde_json::from_str::<Vec<hypr_listener_interface::Word>>(
+                    &hypr_data::english_4::WORDS_JSON,
+                )
+                .unwrap();
+                words.repeat(10)
+            },

This uses the built-in repeat method which is more concise and avoids multiple cloning operations.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f630dcf and c9ee9b1.

📒 Files selected for processing (1)
  • crates/db-user/src/init.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{js,ts,tsx,rs}`: 1. No error handling. 2. No unused imports, variables, or functions. 3. For comments, keep it minimal. It should be about "Why", not "What".

**/*.{js,ts,tsx,rs}: 1. No error handling.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".

  • crates/db-user/src/init.rs
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: ci

@yujonglee yujonglee force-pushed the fix-tiptap-performance branch from c9ee9b1 to 6fec6e6 Compare June 4, 2025 00:45
@yujonglee yujonglee merged commit 30b3033 into main Jun 4, 2025
4 of 5 checks passed
@yujonglee yujonglee deleted the fix-tiptap-performance branch June 4, 2025 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant