feat(clipboard): make clipboard restore delay configurable#110
Merged
Conversation
Add a global clipboard.restore_delay_ms setting to config.yaml controlling how long Koe waits after an automatic paste completion callback before restoring the pre-session clipboard (default 1500, range 0-60000; 0 restores immediately). - Rust: new ClipboardSection with tolerant deserialization — invalid values (negative, non-integer, overflow, >60000) warn and fall back to 1500 without poisoning unrelated ASR/LLM/hotkey config - FFI: sp_core_get_clipboard_config() exposes the validated cached value; the native layer never rereads raw YAML at paste time - Native: SPClipboardRestorePolicy snapshots the effective delay per session and is the single restoration entry point for both automatic paste flows (normal final-text and experimental ASR-first), removing both literal 1500 call sites; clipboard-only delivery is unchanged - Tests: Rust config parsing battery incl. field-level fallback and unrelated-section preservation; native policy-seam tests with a recording clipboard-manager double Closes #109
0c3d347 to
066448e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #109
Summary
Adds a global, file-based
clipboard.restore_delay_mssetting toconfig.yamlcontrolling how long Koe waits after an automatic paste completion callback before restoring the pre-session clipboard contents. Default 1500 ms (unchanged behavior), inclusive range 0–60000; 0 schedules restoration immediately after the paste completes (it does not disable restoration).Changes
Rust (koe-core)
ClipboardSectionin the typed config model with tolerant deserialization: a negative, non-integer, overflowing, or >60000 value emits a warning (never containing clipboard contents) and falls back only this field to 1500, preserving all unrelated ASR/LLM/hotkey configuration. Custom serde visitors are required because serde_yaml hard-errors on integers wider than u64 otherwise.sp_core_get_clipboard_config()exposes the validated, cached value across the FFI boundary (mirrorssp_core_get_feedback_config); the native layer never rereads raw YAML at paste time.Native (KoeApp)
SPClipboardRestorePolicy: snapshots the effective delay once per voice-input session (right aftersession_begin, which is also where Rust hot-reloads config — so edits during an active session apply from the next session) and serves as the single restoration entry point for both automatic paste flows.1500call sites (normal final-text flow and experimental ASR-first flow) now go through the policy. Clipboard-only delivery (missing Accessibility permission, prompt-template rewrites, unsafe in-place correction fallback) still never schedules restoration.Docs: DESIGN.md §20.13 + hardcoded-timing note updated; CHANGELOG.md unreleased entry added.
Tests
asr/llmfields; malformed section shapes tolerated.cargo test -p koe-core --lib: 88 passed.KoeLogicTests: 25 passed.xcodebuild -scheme Koe),cargo check --workspaceclean, rustfmt applied, no new clippy warnings.🤖 Generated with Claude Code