Skip to content

[Feature] Deduplicate clipboard history beyond the 10-second window with efficient hash lookups #56

Open

Description

@mobrava

Background

A user requested that repeated copies of the same content appear only once in clipboard history:

Great app, I've used it for about a day. Please add feature to only show one of many same copy's

The comment was supplied by the maintainer on September 27, 2026 (KST); its original permalink has not yet been recorded.

Current behavior

In ClipboardMonitor.swift, captured raw data is hashed with SHA-256. The duplicate check only matches items with the same content hash whose copiedAt timestamp is within the last 10 seconds:

item.contentHash == hash && item.copiedAt > tenSecondsAgo

A matching capture is skipped without updating the timestamp. Copying identical content after that window can create another history entry. The current history view and search filtering do not collapse those duplicates.

Proposed behavior

Keep one history entry for identical content regardless of elapsed time. When the content is copied again, update the existing entry's copiedAt timestamp so it moves to the front instead of creating another card.

The original comment only requests one visible copy. Reusing a stored entry is a proposed implementation, not an explicitly requested storage policy.

Performance considerations

  • Compare the stored content hashes rather than loading and comparing the full text/image payload of every card.
  • Inspect the existing schema and generated database indexes before assuming contentHash is indexed.
  • Evaluate an index supporting the duplicate lookup, subject to the supported macOS/SwiftData versions and safe schema migration.
  • Fetch at most one matching entry for ordinary duplicate capture rather than counting or materializing all matching entries.
  • Without a suitable index, a hash lookup may scan stored rows. The current 10-second predicate does not by itself guarantee a cheaper query.
  • Measure capture latency with the default 500-item history and larger retained histories, including pinned items. Check that routine lookups do not load all large payloads or cause noticeable UI stalls.
  • Treat these as design considerations to verify, not as evidence of a measured performance regression.

Acceptance criteria

  • Copying the same content again after more than 10 seconds keeps one history entry and moves it to the most recent position.
  • Verify both consecutive copies and A → B → A copies, including after restarting the app.
  • Define duplicate identity consistently across content types. Preserve distinct content where formatting or payload differences matter; avoid merging solely because previews look identical.
  • Preserve pinboard references and user-assigned titles when reusing an entry; define how source-app metadata should change.
  • Verify that the app's own copy/paste actions do not accidentally create new duplicates.
  • Inspect index availability, implement an appropriate lookup strategy, and record capture-latency and memory measurements for representative history sizes.
  • Decide how existing duplicate records should appear and whether an optional cleanup is needed; preserve pinboard relationships and metadata if any records are consolidated.

Source

  • User feedback quoted above and maintainer discussion, September 27, 2026 (KST).
  • Code reviewed at commit 569471f.

Activity

  1. added
    enhancement
    on Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions