Improve reliable paste verification and avoid FluidVoice self-target duplication#231
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d3590968e1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Self.pasteboardRestoreQueue.async { | ||
| _ = self.waitForFocusedTextVerification( | ||
| from: focusedTextSnapshot, | ||
| expectedText: text, | ||
| timeoutMicros: restoreDelayMicros |
There was a problem hiding this comment.
Serialize clipboard lifecycle before returning from paste path
withTemporaryPasteboardString now dispatches clipboard restoration asynchronously and returns immediately, which allows a second paste operation to start while the first operation still owns the temporary clipboard contents. In that overlap, the second call snapshots the first call’s temporary text (not the user’s original clipboard), the first restore is skipped by the change-count guard, and the second restore can permanently restore stale dictated text instead of the original clipboard. This is reproducible when two reliable-paste insertions happen within the 5-second verification window.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e664395a9e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if let preferredTargetPID, preferredTargetPID > 0 { | ||
| self.log("[TypingService] Trying clipboard-to-PID insertion first") | ||
| if self.insertTextViaClipboardToPid(text, targetPID: preferredTargetPID) { | ||
| self.log("[TypingService] Reliable Paste dispatched via clipboard-to-PID") |
There was a problem hiding this comment.
Preserve fallback when preferred-PID paste cannot be confirmed
This new early return makes reliable paste trust insertTextViaClipboardToPid before trying global/menu paste, but that helper reports success after posting Cmd+V events without confirming delivery. If preferredTargetPID is stale (for example, the original target app exited before insertion), this branch returns true and skips the fallbacks that previously still delivered text to the active app, causing silent output loss.
Useful? React with 👍 / 👎.
| let frontmostName = frontmostApp?.localizedName ?? "Unknown" | ||
| let isFluidFrontmost = frontmostApp?.bundleIdentifier?.contains("fluid") == true | ||
| let shouldTypeExternally = shouldPersistOutputs && (!isFluidFrontmost || self.isTranscriptionFocused == false) | ||
| let shouldTypeExternally = shouldPersistOutputs && !isFluidFrontmost |
There was a problem hiding this comment.
Keep external typing enabled when FluidVoice is frontmost but unfocused
This condition now suppresses external typing for all isFluidFrontmost cases, but FluidVoice can be frontmost while its transcription editor is not the active destination (e.g., control UI/popover flow). In that state, the code no longer restores focus or calls typeTextToActiveField, and clipboard copy is also disabled above, so dictated text is not delivered to the original target app.
Useful? React with 👍 / 👎.
|
#213 covered! |
Summary
Validation
swiftformat --config .swiftformat Sourcesswiftlint --strict --config .swiftlint.yml Sources/./build_incremental.shNotes