Skip to content

fix(windows): buffer streaming SendInput events#502

Merged
H-Chris233 merged 1 commit into
Open-Less:betafrom
H-Chris233:issue-491-windows-sendinput-pacing
May 19, 2026
Merged

fix(windows): buffer streaming SendInput events#502
H-Chris233 merged 1 commit into
Open-Less:betafrom
H-Chris233:issue-491-windows-sendinput-pacing

Conversation

@H-Chris233
Copy link
Copy Markdown
Collaborator

@H-Chris233 H-Chris233 commented May 19, 2026

User description

Summary

  • buffer streaming insertion deltas and flush them in 12ms windows
  • remove the per-character Windows SendInput delay so long transcripts do not gain linear delay
  • keep streaming insertion enabled while reducing foreground app message-queue pressure

Diagnosis

Issue #491 logs show visible stalls on the Windows streaming_insert path after ASR/LLM work completes. The likely cause is rapid Unicode SendInput delivery overwhelming foreground apps such as Chromium, VSCode, Notepad3, or Explorer.

Fix

Instead of sleeping after every character, the typer now accumulates SSE deltas into a small buffer and flushes the current buffer every 12ms. This avoids 500-character transcripts gaining ~6s of artificial delay while still pacing output bursts.

Validation

  • git diff --check
  • cargo test --manifest-path "/home/chris233/openless/openless-all/app/src-tauri/Cargo.toml" streaming_insert -- --test-threads=1
  • cargo test --manifest-path "/home/chris233/openless/openless-all/app/src-tauri/Cargo.toml" unicode_keystroke -- --test-threads=1

Follow-up

Refs #491


PR Type

Bug fix


Description

  • Batch streaming deltas every 12ms

  • Remove Windows per-character input delay

  • Reduce post-dictation UI stalls

  • Preserve typed text on failures


Diagram Walkthrough

flowchart LR
  A["Streaming SSE deltas"] --> B["mpsc buffering"]
  B -- "12ms flush window" --> C["Batch type_unicode_chunk calls"]
  C --> D["Windows SendInput"]
  D --> E["Less foreground app stalling"]
Loading

File Walkthrough

Relevant files
Bug fix
dictation.rs
Batch streaming deltas before typing                                         

openless-all/app/src-tauri/src/coordinator/dictation.rs

  • Adds a 12ms flush interval for streaming inserts
  • Switches from unbounded async channel to blocking mpsc
  • Buffers incoming deltas and types them in batches
  • Extracts a helper to flush buffered text safely
+64/-32 
unicode_keystroke.rs
Remove Windows keystroke pacing delay                                       

openless-all/app/src-tauri/src/unicode_keystroke.rs

  • Removes the 1ms sleep between Unicode keystrokes
  • Keeps Windows SendInput delivery fully synchronous
  • Relies on upstream batching to avoid app stalls
+0/-7     

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 19, 2026

PR Reviewer Guide 🔍

(Review updated until commit 52ea7f5)

Here are some key observations to aid the review process:

**🎫 Ticket compliance analysis **

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ No major issues detected

@H-Chris233 H-Chris233 force-pushed the issue-491-windows-sendinput-pacing branch from e7d4a38 to 52ea7f5 Compare May 19, 2026 12:53
@H-Chris233 H-Chris233 changed the title fix(windows): pace streaming SendInput events fix(windows): buffer streaming SendInput events May 19, 2026
@github-actions
Copy link
Copy Markdown

Persistent review updated to latest commit 52ea7f5

@H-Chris233 H-Chris233 merged commit 2996913 into Open-Less:beta May 19, 2026
4 checks passed
appergb pushed a commit that referenced this pull request May 19, 2026
…lush

合并 #502(fix(windows): buffer streaming SendInput events):
SSE delta 在 12ms 时间窗内合并后再调用 type_unicode_chunk,
显著降低 Windows 流式输入路径上的 SendInput 调用频率与 CPU 占用。
mpsc 由 tokio unbounded 切到 std sync::mpsc,typer 任务里
用 recv_timeout 实现 flush 窗口,断开/失败后仍能 drain 完剩余 delta,
并把缓冲写入逻辑抽到 flush_streaming_insert_buffer 单元函数。
本次只动版本号,逻辑改动已在 #502 落盘。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant