feat(paste): auto-insert transcript at cursor via wtype/xdotool/ydotool/osascript/SendKeys
Adds an opt-in "auto-paste into focused window" toggle. When enabled, the dictation pipeline sets the clipboard and then sends a Ctrl+V / Cmd+V keystroke to whatever window currently has focus — the common case after a global-hotkey dictation, since Kon's own window never stole focus. Backend (src-tauri/src/commands/paste.rs) probes for a platform paste tool and falls back cleanly: - Linux Wayland: wtype > ydotool > xdotool - Linux X11: xdotool > ydotool > wtype - macOS: osascript System Events keystroke - Windows: PowerShell WScript.Shell SendKeys detect_paste_backends is a pure probe used by Settings to describe the available backend next to the toggle (or nudge the user to install one). paste_text always copies first, so auto-paste failure degrades to the existing clipboard-only behaviour and surfaces a warn toast. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -479,7 +479,22 @@
|
||||
replaceSegmentsWithCleanedText(cleanedTranscript);
|
||||
}
|
||||
|
||||
if (settings.autoCopy) {
|
||||
if (settings.autoPaste) {
|
||||
try {
|
||||
const outcome = await invoke("paste_text", { text: transcript });
|
||||
if (!outcome?.pasted && outcome?.message) {
|
||||
toasts.warn(
|
||||
"Auto-paste unavailable",
|
||||
`${outcome.message}${outcome.copied ? ". Transcript is on your clipboard." : ""}`,
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
await navigator.clipboard
|
||||
.writeText(transcript)
|
||||
.catch(() => invoke("copy_to_clipboard", { text: transcript }).catch(() => {}));
|
||||
toasts.warn("Auto-paste failed", String(err));
|
||||
}
|
||||
} else if (settings.autoCopy) {
|
||||
navigator.clipboard.writeText(transcript).catch(() => {
|
||||
invoke("copy_to_clipboard", { text: transcript }).catch(() => {});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user