Skip to content

Fix Clipboard History overwriting snippets created in the same app session - #507

Merged
ggbond268 merged 1 commit into
mactools-app:mainfrom
xcv58:codex/fix-clipboard-new-snippets
Oct 27, 2026
Merged

ggbond268 merged 1 commit into
mactools-app:mainfrom
xcv58:codex/fix-clipboard-new-snippets

Conversation

@xcv58

@xcv58 xcv58 commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Problem and result

Saving snippet B with New Snippet after saving snippet A in the same app session overwrote A instead of adding another entry. Fully quitting and reopening MacTools generates a different draft UUID, allowing the first new snippet after each launch to be added separately; reopening only the Clipboard window does not reset it.

With this change, repeated New Snippet saves create independent entries, and editing an existing snippet preserves its ID.

Changes

  • Make ClipboardSnippetDraft.empty a computed property so each new draft gets a fresh UUID instead of reusing one process-wide value.
  • Add a regression test that creates two snippets through the same factory as New Snippet, edits the first, and reloads a temporary encrypted SQLite database to verify both entries and their contents remain independent.
  • Add an English plugin changelog fragment.

Verification

  • Confirmed the regression fails against the original implementation on the duplicate-ID assertion.
  • make test TEST_FILTER=ClipboardSavedLibraryTests: 19 tests passed, including the regression.
  • make validate-changelog and git diff --check passed.
  • A fresh independent reviewer checked the complete change and integration points at bd70b616, with no actionable issues found.

Earlier creation tests supplied id: nil directly and bypassed the faulty factory. The new regression covers that missing creation path using a fake pasteboard, an in-memory key store, and temporary storage.

UI evidence

Not applicable to visual evidence: no views, layouts, styling, localization, accessibility, or interaction handlers changed. The native UI flow was not manually retested; the regression exercises the draft factory used by New Snippet and the controller/persistence path.

Checklist

  • Core behavior and relevant risks are verified using existing tests, focused additions, or manual checks; results or limitations are recorded.
  • UI evidence is attached where applicable; shared components, themes, localization, and accessibility are respected.
  • User-facing documentation and changelog fragments are updated when required.
  • Plugin metadata, runtime contracts, action policies, and minimum-host compatibility agree.
  • Licensing and third-party notices are complete; no credentials, local configuration, or unrelated generated files are included.

@xcv58
xcv58 marked this pull request as draft October 26, 2026 01:57
@xcv58 xcv58 changed the title Fix Clipboard History overwriting newly created snippets Fix Clipboard History overwriting snippets created in the same app session Oct 26, 2026
@xcv58
xcv58 marked this pull request as ready for review October 26, 2026 02:04
@xcv58
xcv58 requested a balanced review from Copilot October 26, 2026 14:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The narrow factory change addresses the shared-ID defect, with focused regression coverage and no unresolved findings.

No open issues 🎉

What changed in this PR

Fixes Clipboard History’s same-session snippet overwrites by generating a fresh UUID for each new draft while preserving existing snippet IDs during editing.

Changes:

  • Replaces the shared empty draft with a computed factory.
  • Adds regression coverage for independent creation, editing, and persisted contents.
  • Adds a user-facing plugin changelog entry.

Tests were not rerun in this review environment because macOS project execution is unavailable. Local verification: make test TEST_FILTER=ClipboardSavedLibraryTests and make validate-changelog.

File Description
Plugins/​ClipboardHistory/​Tests/​ClipboardSavedLibraryTests.swift Tests separate snippet creation, edit identity, and persistence.
Plugins/​ClipboardHistory/​Sources/​ClipboardSavedLibrary.swift Generates a fresh UUID for each empty draft.
changes/​unreleased/​clipboard-new-snippets.md Documents the snippet overwrite fix.

Review effort: Balanced

@ggbond268
ggbond268 merged commit 271cc24 into mactools-app:main Oct 27, 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.

3 participants