From fc57dcac9a7c972fa59dbd0aded06ae0725000ca Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 28 May 2026 10:08:10 -0500 Subject: refactor(view-sync): pearl--save-query-mark-synced preserves unknown plist keys The prior implementation rebuilt the spec from a fixed key set (:filter, :sort, :order, plus the four :linear-view-* sync keys and the optional :linear-view-url) and silently dropped anything else. No keys outside that set live on a saved-query entry today, but the persistence layer was coupled to the current schema. A future :description, a user-added annotation, or any new pearl field would vanish on every re-sync. I switched to copy-then-plist-put: shallow-copy the existing spec, plist-put the four sync keys on top, and conditionally plist-put :linear-view-url when this call provided one. Arbitrary keys survive untouched. The URL-preservation behavior on a re-sync that omits view-url is unchanged: the prior :linear-view-url is already in the copied spec, so the when-view-url guard skips the put and leaves it in place. I added one regression test that seeds an entry with :description and :user-tag alongside the standard keys and asserts all of them survive a mark-synced call. All 661 ert tests pass. make compile and make lint are clean. --- tests/test-pearl-saved-query-sync.el | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests') diff --git a/tests/test-pearl-saved-query-sync.el b/tests/test-pearl-saved-query-sync.el index f9bab00..ceac5e6 100644 --- a/tests/test-pearl-saved-query-sync.el +++ b/tests/test-pearl-saved-query-sync.el @@ -267,6 +267,34 @@ URL the create path already wrote." (should (equal "https://linear.app/ws/view/old" (plist-get spec :linear-view-url)))))) +(ert-deftest test-pearl-save-query-mark-synced-preserves-unknown-plist-keys () + "Unknown keys on a saved-query spec survive a mark-synced call. +The earlier implementation rebuilt the spec from a fixed key set and +silently dropped anything outside it. Copy-then-plist-put preserves +arbitrary keys so a future schema field or user annotation isn't +erased on every re-sync." + (let ((pearl-saved-queries + (copy-tree '(("Q" :filter (:open t) + :sort updated + :order desc + :description "private note about this query" + :user-tag "experimental"))))) + (cl-letf (((symbol-function 'customize-save-variable) (lambda (_ _) nil))) + (pearl--save-query-mark-synced "Q" "team-uuid" t "view-uuid" "https://x")) + (let ((spec (cdr (assoc "Q" pearl-saved-queries)))) + ;; Original keys survive. + (should (equal '(:open t) (plist-get spec :filter))) + (should (eq 'updated (plist-get spec :sort))) + (should (eq 'desc (plist-get spec :order))) + (should (equal "private note about this query" + (plist-get spec :description))) + (should (equal "experimental" (plist-get spec :user-tag))) + ;; New sync keys layered on top. + (should (equal "view-uuid" (plist-get spec :linear-view-id))) + (should (equal "team-uuid" (plist-get spec :linear-view-team-id))) + (should (eq t (plist-get spec :linear-view-shared))) + (should (equal "https://x" (plist-get spec :linear-view-url)))))) + (ert-deftest test-pearl-save-query-mark-synced-overwrites-prior-sync-metadata () "Re-syncing an already-synced entry overwrites the four `:linear-view-*' keys." (let ((pearl-saved-queries -- cgit v1.2.3