From 8edf5c4ded5c85e7e909e36f83d11d84cd0677df Mon Sep 17 00:00:00 2001 From: none23 Date: Wed, 2 Sep 2026 19:24:00 +0400 Subject: [PATCH] Keep Chromium focused between wtype chunks --- baml_src/delivery.baml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/baml_src/delivery.baml b/baml_src/delivery.baml index 5a52cc2..84e3877 100644 --- a/baml_src/delivery.baml +++ b/baml_src/delivery.baml @@ -40,6 +40,23 @@ function wtype_chunks(transcript: string) -> string[] { } function type_text(transcript: string) -> bool { + // Keep a virtual keyboard registered so Chromium preserves editor focus as chunk keyboards exit. + let anchor_options = process_options(null); + anchor_options.keep_stdin_open = true; + let anchor = baml.sys.start_process("wtype", ["-"], anchor_options) catch_all (error) { + _ => { + return false; + }, + }; + defer { + anchor.close() + } + // Give the anchor time to register before starting the first chunk. + baml.sys.sleep(baml.time.Duration.from_milliseconds(20)) catch_all (error) { + _ => { + return false; + }, + }; for (let chunk in wtype_chunks(transcript)) { if (!run_delivery_command("wtype", ["-"], chunk)) { return false;