Skip to content

fix(context): detect clipboard fallback copy by content, not by change#285

Merged
quiet-node merged 2 commits into
mainfrom
claude/festive-lovelace-158388
Jul 1, 2026
Merged

fix(context): detect clipboard fallback copy by content, not by change#285
quiet-node merged 2 commits into
mainfrom
claude/festive-lovelace-158388

Conversation

@quiet-node

Copy link
Copy Markdown
Owner

Summary

Selected-text context capture silently failed when re-selecting and re-querying the same passage in a row: the host-app picker bar showed no quoted context, and nothing was attached to the message.

What changed

clipboard_fallback() in context.rs (used whenever the macOS Accessibility API can't expose a selection directly, e.g. web-based rich-text editors) detected a successful synthetic Cmd+C by diffing clipboard contents before vs. after. If the clipboard already held the exact same text as the new selection, the diff came back unchanged, so the function concluded nothing had been copied and returned no context — even though the copy succeeded.

Fix: clear the pasteboard before issuing the synthetic Cmd+C, then check for non-empty content afterward instead of "did it change." This detects a real copy even when it's byte-identical to what was already there, while still restoring the original clipboard contents afterward.

Testing

  • Reproduced live via a debug build with temporary instrumentation in the capture path; confirmed the failure (changed=false despite a real selection) and confirmed the fix resolves it across repeated captures of the same text.
  • bun run test:all:coverage — 100% line coverage, all green.
  • bun run validate-build — zero warnings/errors.

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>
Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>
@quiet-node quiet-node merged commit 89ae62a into main Jul 1, 2026
5 checks passed
@quiet-node quiet-node deleted the claude/festive-lovelace-158388 branch July 1, 2026 00:00
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