Skip to content

Fix stale clipboard capture in macOS selection fallback - #22

Merged
fly1d merged 1 commit into
mainfrom
codex/fix-stale-clipboard-selection
Aug 14, 2026
Merged

Fix stale clipboard capture in macOS selection fallback#22
fly1d merged 1 commit into
mainfrom
codex/fix-stale-clipboard-selection

Conversation

@fly1d

@fly1d fly1d commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • seed the clipboard with a private marker before the copy fallback
  • wait up to 500 ms for a real clipboard change
  • return a clear no-selection error instead of translating stale clipboard content
  • preserve and restore the users existing clipboard as before
  • add regression tests for marker, empty, and trimmed clipboard output

Risk

  • Low: documentation, copy, styles, or isolated dictionary data
  • Medium: UI behavior, translation provider, document parsing, or shared API
  • High: selection capture, OS permissions, credentials, packaging, or releases

Verification

  • npm run check
  • npm run test:smoke when user-facing behavior changed
  • npm run test:site
  • npm run desktop:check
  • rebuilt and launched the release app locally
  • No API keys, user content, or sensitive logs were added
  • Error and fallback states were exercised

Review Notes

A manual probe reproduced the old behavior: with copy unavailable, the fallback returned the previous clipboard value () as selected text. After this change, the same probe returns 没有检测到选中的文字. The marker is generated from one Rust constant and is never exposed to the translation layer. Clipboard restoration runs on both success and AppleScript error paths.

@fly1d fly1d left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the complete selection-capture diff at ab88aa5. The fallback now seeds the clipboard before issuing Copy, polls for a real change, restores the prior clipboard on both success and script errors, and maps an unchanged marker to an explicit no-selection error. The marker is sourced from one Rust constant, and regression tests cover marker, empty, and trimmed output. The original stale-content behavior was reproduced locally, the corrected failure state was exercised, a release app was rebuilt and launched, all local suites passed, and all five protected GitHub checks passed. No blocking findings.

@fly1d
fly1d merged commit cd84da9 into main Aug 14, 2026
5 checks passed
@fly1d
fly1d deleted the codex/fix-stale-clipboard-selection branch August 14, 2026 09:33
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.

1 participant