Skip to content

feat(clipboard): make clipboard restore delay configurable#110

Merged
missuo merged 1 commit into
mainfrom
missuo/issue-109-make-clipboard-restore
Jul 15, 2026
Merged

feat(clipboard): make clipboard restore delay configurable#110
missuo merged 1 commit into
mainfrom
missuo/issue-109-make-clipboard-restore

Conversation

@missuo

@missuo missuo commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Closes #109

Summary

Adds a global, file-based 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 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)

  • New ClipboardSection in 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 (mirrors sp_core_get_feedback_config); the native layer never rereads raw YAML at paste time.
  • Default config template documents the setting, range, zero semantics, and fallback behavior.

Native (KoeApp)

  • New SPClipboardRestorePolicy: snapshots the effective delay once per voice-input session (right after session_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.
  • Both literal 1500 call 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.
  • Existing safety mechanics are untouched: pasteboard change-count check, restore-generation supersession, earliest-backup preservation.

Docs: DESIGN.md §20.13 + hardcoded-timing note updated; CHANGELOG.md unreleased entry added.

Tests

  • Rust config seam: absent section/field, 0 / 1500 / 60000 accepted; negative, float, string, bool, sequence, >60000, and u64-overflowing values fall back to 1500; invalid clipboard values preserve unrelated asr/llm fields; malformed section shapes tolerated. cargo test -p koe-core --lib: 88 passed.
  • Native policy seam: recording clipboard-manager test double verifies the session snapshot value is what gets scheduled, zero-delay is scheduled (not skipped), a newer session snapshot supersedes the previous one, and capturing a policy schedules nothing by itself. KoeLogicTests: 25 passed.
  • Full app target builds (xcodebuild -scheme Koe), cargo check --workspace clean, rustfmt applied, no new clippy warnings.

🤖 Generated with Claude Code

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
@missuo missuo force-pushed the missuo/issue-109-make-clipboard-restore branch from 0c3d347 to 066448e Compare July 15, 2026 09:59
@missuo missuo merged commit e62ae81 into main Jul 15, 2026
2 checks passed
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.

Make clipboard restore delay configurable

1 participant