From 8fa0febbc3a3afe78d1a5abbbb944adf6dd3612a Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 25 May 2026 19:54:32 -0500 Subject: feat(save): add an atomic conflict gate for enum and relation fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The text conflict gate (pearl--resolve-conflict) is built for mergeable text — it can open an smerge buffer, stash to the kill ring, and advance a SHA hash. None of that fits a state, priority, assignee, or label conflict, where the value is a single id or scalar that can't be combined. pearl--resolve-atomic-conflict is the sibling for those fields: it prompts use-local / use-remote / cancel (no merge option), and delegates the actual push and the baseline advance to the caller's two callbacks, so it stays free of any field-specific mechanics. It maps to the same outcome contract as the text gate — cancel to conflict/cancelled, use-local to pushed or failed/push-failed, use-remote to resolved-remote. It's not wired into a saver yet — the per-field savers in the next commit call it. --- pearl.el | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'pearl.el') diff --git a/pearl.el b/pearl.el index abd0166..7d2210e 100644 --- a/pearl.el +++ b/pearl.el @@ -2081,6 +2081,52 @@ push-failed), `rewrite' abort -> (conflict aborted)." (when outcome-cb (funcall outcome-cb 'failed 'push-failed)))))) (lambda () (when outcome-cb (funcall outcome-cb 'conflict 'aborted))))))) +(defun pearl--read-atomic-conflict-resolution (label) + "Prompt for resolving an atomic-field conflict on LABEL, returning a symbol. +One of `use-local' (push mine, overwrite Linear), `use-remote' (take Linear's), +or `cancel'. There is no merge option -- an enum or relation value can't be +combined. A bare RET defaults to `cancel'." + (let* ((choices '(("cancel -- leave the field in conflict" . cancel) + ("use local -- push my value, overwrite Linear" . use-local) + ("use remote -- take Linear's value" . use-remote))) + (default (caar choices)) + (pick (completing-read + (format "Conflict on %s (RET cancels): " label) + (mapcar #'car choices) nil t nil nil default))) + (cdr (assoc pick choices)))) + +(defun pearl--resolve-atomic-conflict + (label local-display remote-display push-local-fn take-remote-fn outcome-cb) + "Resolve an atomic-field (enum/relation) conflict on LABEL interactively. +The sibling of `pearl--resolve-conflict' for fields whose value is a single +id or scalar, not mergeable text -- so there is no smerge/rewrite branch and no +SHA hash is written. + +LOCAL-DISPLAY and REMOTE-DISPLAY are human-readable values for the prompt. +PUSH-LOCAL-FN takes a callback invoked with non-nil on a successful push of the +local value (the caller advances the baseline on success). TAKE-REMOTE-FN +adopts Linear's value locally and advances the baseline, with no push. +OUTCOME-CB is called once with (STATUS REASON): `cancel' -> (conflict +cancelled); `use-local' -> (pushed nil) or (failed push-failed); `use-remote' +-> (resolved-remote nil)." + (pcase (pearl--read-atomic-conflict-resolution label) + ('cancel + (message "Left %s in conflict (refresh to see Linear's %s)" label remote-display) + (funcall outcome-cb 'conflict 'cancelled)) + ('use-local + (funcall push-local-fn + (lambda (ok) + (if ok + (progn + (message "Pushed your %s (%s) to Linear" label local-display) + (funcall outcome-cb 'pushed nil)) + (message "Failed to push %s" label) + (funcall outcome-cb 'failed 'push-failed))))) + ('use-remote + (funcall take-remote-fn) + (message "Took Linear's %s (%s)" label remote-display) + (funcall outcome-cb 'resolved-remote nil)))) + ;;; Compose Buffer ;; ;; A focused Org buffer for composing multi-line text (comments, descriptions) -- cgit v1.2.3