Skip to content

Conversation

yujonglee
Copy link
Contributor

No description provided.

Copy link

coderabbitai bot commented Sep 4, 2025

📝 Walkthrough

Walkthrough

Introduced a private emit(handle, event) helper in plugins/listener/src/fsm.rs that conditionally shows the Windows main window for specific session state events before emitting them. Replaced direct event emissions throughout the FSM with this helper, and changed several call sites to ignore the returned tauri::Result.

Changes

Cohort / File(s) Summary
FSM event emission centralization
plugins/listener/src/fsm.rs
Added private emit(handle, event) -> tauri::Result<()> that shows HyprWindow::Main on Windows for Inactive/RunningActive/RunningPaused before event emission; replaced direct SessionEvent emissions (audio chunks, PartialWords, FinalWords, MicMuted, SpeakerMuted, state transitions) with emit(...); many call sites now ignore errors via let _ = ....

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant FSM as FSM
  participant Helper as emit(...)
  participant UI as HyprWindow::Main (Windows)
  participant Tauri as Tauri Handle
  participant Bus as Event Bus

  User->>FSM: Trigger state/data change
  FSM->>Helper: emit(handle, SessionEvent)
  alt Event is RunningActive/RunningPaused/Inactive and OS is Windows
    Helper->>UI: show()
    note right of UI: Only on Windows
  end
  Helper->>Tauri: event.emit(handle)
  Tauri->>Bus: Dispatch SessionEvent
  note over FSM,Helper: Many call sites ignore Result<br/>(errors swallowed)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch focus-on-state-transition

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.

❤️ Share
🪧 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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 (2)
plugins/listener/src/fsm.rs (2)

615-631: Generalize emit over Runtime and reduce log noise

  • Avoid locking the helper to Wry; make it generic like other fns in this file.
  • The info log will fire on every state transition in prod; consider debug to keep noise down.
-fn emit(handle: &tauri::AppHandle<tauri::Wry>, event: &SessionEvent) -> tauri::Result<()> {
+fn emit<R: tauri::Runtime>(handle: &tauri::AppHandle<R>, event: &SessionEvent) -> tauri::Result<()> {
@@
-            } else {
-                tracing::info!("show_main_window_when_state_transition");
-            }
+            } else {
+                tracing::debug!("show_main_window_when_state_transition");
+            }

Additionally, naming this helper emit can be confused with Event::emit; consider a more explicit name in a follow-up (e.g., emit_with_state_ui).


338-341: Clarify log label to match the new helper path

This error now originates from the centralized emit helper, not a generic "broadcast." Rename for clearer observability.

-                            tracing::error!("broadcast_error: {:?}", e);
+                            tracing::error!("emit_error: {:?}", e);
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 24cdb87 and ed18625.

📒 Files selected for processing (1)
  • plugins/listener/src/fsm.rs (6 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

⚙️ CodeRabbit configuration file

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

Files:

  • plugins/listener/src/fsm.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: ci (macos, macos-14)
  • GitHub Check: ci (windows, windows-latest)
🔇 Additional comments (4)
plugins/listener/src/fsm.rs (4)

495-500: Swallowing PartialWords emit errors—confirm intent

let _ = emit(...) drops failures silently. If the UI relies on these events, silent drops can desync state. If intentional (to avoid noisy logs), consider adding a rate-limited metric/log in a follow-up.


532-537: Swallowing FinalWords emit errors—confirm intent

Same as above. Final results are higher value; losing the event without any signal can hinder debuggability. Please confirm this behavior is desired.


696-704: Muted-state events also ignore emit failures—confirm

These events affect UX controls. Dropping errors here may hide issues when toggling mute from the UI. Intentional?


830-834: State-transition emits are ignored—verify impact

State events drive window behavior and client state. Ignoring emit failures here could leave the frontend out of sync after transitions. Was this trade-off intentional, or should we at least log failures like the amplitude path?

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