Skip to content

fix: paste into Firefox through clipboard fallback - #425

Closed
juanfradb wants to merge 1 commit into
VocaHQ:mainfrom
juanfradb:codex/firefox-ibus-clipboard-paste
Closed

fix: paste into Firefox through clipboard fallback#425
juanfradb wants to merge 1 commit into
VocaHQ:mainfrom
juanfradb:codex/firefox-ibus-clipboard-paste

Conversation

@juanfradb

Copy link
Copy Markdown
Contributor

Summary

  • detect focused Firefox windows when using the IBus text injection path
  • use clipboard copy plus xdotool key ctrl+v for Firefox instead of direct IBus commit
  • keep the existing IBus path for other applications
  • add tests for Firefox fallback, non-Firefox behavior, and X11 paste injection

Why

Firefox text fields can ignore IBus commit text in some X11 desktop setups even while terminal and other applications work. Clipboard paste is the reliable path there and already matches the existing clipboard fallback model.

Impact

Firefox users get the dictated text inserted instead of silently losing it. The recognized text is copied to clipboard as part of the paste fallback.

Validation

  • PYTHONPATH=src /home/juanfra/.local/share/vocalinux/venv/bin/python -m pytest tests/test_text_injector.py -q
  • PYTHONPATH=src /home/juanfra/.local/share/vocalinux/venv/bin/python -m py_compile src/vocalinux/text_injection/text_injector.py tests/test_text_injector.py
  • black --check on changed files

@codecov

codecov Bot commented May 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.21739% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.76%. Comparing base (0556d16) to head (4650506).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/vocalinux/text_injection/text_injector.py 65.21% 11 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #425      +/-   ##
==========================================
- Coverage   79.91%   79.76%   -0.15%     
==========================================
  Files          30       30              
  Lines        4615     4661      +46     
  Branches      699      709      +10     
==========================================
+ Hits         3688     3718      +30     
- Misses        779      790      +11     
- Partials      148      153       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jatinkrmalik

Copy link
Copy Markdown
Member

Hey @juanfradb, closing this. Thanks for the Firefox report, but I don't want this patch to land.

#665 did not fix Firefox ignoring IBus. That PR restores the XKB layout after scoped injection. IBusTextInjector.inject_text() still returns True as soon as commit_text() succeeds at the IBus layer, so _switch_to_non_ibus_backend() never runs when Firefox drops the text. That failure mode can still be real. This isn't the fix for it.

A few problems with the approach:

  1. "firefox" in target_app after joining window title + class + /proc/cmdline. Any focused window whose title mentions Firefox (Chrome, VS Code, a terminal) would skip IBus and paste. Detect WM_CLASS / comm only.
  2. The same branch runs on WAYLAND_IBUS and then calls xdotool key ctrl+v, which does not inject into native Wayland Firefox.
  3. _inject_via_x11_clipboard_paste reimplements paste and overwrites the clipboard with no restore. main already has _inject_via_clipboard_paste (restore + generation counter).

Draft, untouched since May, and it conflicts with current inject_text().

If Firefox-on-X11 still silently drops IBus commits, the right knobs are already in flight: pin a non-IBus backend (VOCALINUX_FORCE_BACKEND on main; config pin in #649). Neither accepts xdotool today, which is the actual X11 gap. Add xdotool there, or denylist WM_CLASS firefox / Navigator and reuse _inject_via_clipboard_paste. Don't special-case by window title.

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.

2 participants