Skip to content

fix: preserve clipboard contents and exit cleanly#18

Merged
benmaster82 merged 2 commits into
benmaster82:mainfrom
aladin7:agent/preserve-clipboard-clean-shutdown
Jul 19, 2026
Merged

fix: preserve clipboard contents and exit cleanly#18
benmaster82 merged 2 commits into
benmaster82:mainfrom
aladin7:agent/preserve-clipboard-clean-shutdown

Conversation

@aladin7

@aladin7 aladin7 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

What changed

  • preserve safely duplicable Windows clipboard formats during dictation paste, including common image and copied-file formats
  • restore the clipboard only when WritHer’s temporary transcript is still present
  • retry clipboard transfers and avoid overwriting clipboard content copied during the paste
  • make the clipboard restoration delay configurable
  • run tray-triggered shutdown on Tk’s main thread and join tray, hotkey, and reminder threads
  • cancel service startup when shutdown is requested while the Whisper model is loading

Why

WritHer previously backed up only Unicode text, so pasting dictated text could destroy screenshots, copied files, and other non-text clipboard formats. Its tray callback could also log Shutdown complete while the Tk or tray event loop still kept Python alive.

Impact

Dictation keeps the compatible Ctrl+V workflow while preserving common clipboard content. Quitting from the tray now terminates the process deterministically, including during startup.

Validation

  • 54 tests pass on current upstream main
  • focused Ruff checks pass
  • compilation checks pass
  • git diff --check passes
  • native Windows tray + Tk lifecycle test exits cleanly
  • native CF_DIB and CF_HDROP preservation checks passed during development

@benmaster82
benmaster82 merged commit bc849f5 into benmaster82:main Jul 19, 2026
benmaster82 added a commit that referenced this pull request Jul 19, 2026
- injector: when the full multi-format clipboard snapshot fails (e.g.
  an app with delayed rendering holds a format), fall back to the
  historical text-only save/restore instead of aborting the paste.
  The text-only restore also skips if the clipboard changed during
  the paste. Adds fallback tests.
- README: restore a strong privacy tagline ("No cloud required, no
  account, no telemetry") and warn that pointing the OpenAI-compatible
  URL at a remote endpoint forfeits the offline/privacy guarantees.

Verified: 68 tests green, plus a real Win32 smoke test (bitmap on the
clipboard survives swap-to-text and restore with correct pixels).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
benmaster82 added a commit that referenced this pull request Jul 19, 2026
PR #18 was based on a main where _finish_startup still persisted a
model_ready_* DB flag; the merge reintroduced db.save_setting(
model_flag, ...) after d5efdac had replaced the flag with real HF
cache detection, crashing the startup thread with a NameError. The
app then kept running with a tray icon but no hotkeys.

Removes the stale line and adds the missing happy-path startup
regression test (only the quit-during-load path was covered).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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