From e4e237346e368eb33410c8b175c0a42fea980b2b Mon Sep 17 00:00:00 2001 From: elhombretecla Date: Tue, 27 Oct 2026 15:59:40 +0100 Subject: [PATCH] :sparkles: Sum up what a merge applies and leaves out The compare dialog no longer opens on an overview, so the merge confirmation now says what the merge does: how many changes go into main and how many were left out. When changes are left out and the branch is not kept archived, a warning replaces the deletion note: deleting the branch loses those changes. The counts show when the compare dialog of that branch asked for the merge, as it holds the comparison. --- .../main/ui/workspace/sidebar/branches.cljs | 29 ++++++++++++++++++- .../main/ui/workspace/sidebar/branches.scss | 11 +++++++ frontend/translations/en.po | 15 ++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/main/ui/workspace/sidebar/branches.cljs b/frontend/src/app/main/ui/workspace/sidebar/branches.cljs index 23f239c5bd..edc4c830e6 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/branches.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/branches.cljs @@ -44,6 +44,9 @@ (def ^:private branches (l/derived :workspace-branches st/state)) +(def ^:private branch-diff + (l/derived :workspace-branch-diff st/state)) + (def ^:private branch-context ;; see refs/branch-context: the state entry wraps the row under :info (l/derived #(get-in % [:workspace-branch-context :info]) st/state)) @@ -205,6 +208,16 @@ (let [archive?* (mf/use-state false) archive? (deref archive?*) + ;; what goes in and what stays out, when the compare dialog of this + ;; branch is the one that asked for the merge + diff-st (mf/deref branch-diff) + changes (when (and (= (:id branch) (:branch-id diff-st)) + (= :loaded (:status diff-st))) + (filterv #(contains? #{:added :modified :deleted} (:status %)) + (get-in diff-st [:diff :changes]))) + left-out (count (filter #(contains? (or excluded #{}) (:key %)) changes)) + going-in (- (count changes) left-out) + ;; The branch name and "main" are highlighted (foreground-primary) ;; within the otherwise secondary-colored prompt. We wrap each of ;; them with a sentinel in the `tr` args and split on it, so the @@ -241,14 +254,28 @@ [:span {:key idx :class (stl/css :modal-message-emphasis)} part] [:span {:key idx} part]))] + (when (seq changes) + [:ul {:class (stl/css :merge-summary)} + [:li (tr "workspace.branches.merge.summary-in" (i18n/c going-in))] + (when (pos? left-out) + [:li (tr "workspace.branches.merge.summary-out" (i18n/c left-out))])]) + [:> checkbox* {:id "merge-archive-branch" :label (tr "workspace.branches.merge.archive-label") :checked archive? :on-change on-toggle-archive}] - (if archive? + (cond + archive? [:> context-notification* {:level :warning :type :context} (tr "workspace.branches.merge.archive-warning")] + + ;; deleting the branch takes the changes left out with it + (pos? left-out) + [:> context-notification* {:level :warning :type :context} + (tr "workspace.branches.merge.left-out-lost" (i18n/c left-out))] + + :else [:> context-notification* {:level :info :type :context} (tr "workspace.branches.merge.delete-info")])] diff --git a/frontend/src/app/main/ui/workspace/sidebar/branches.scss b/frontend/src/app/main/ui/workspace/sidebar/branches.scss index c26f27e237..572cdcef50 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/branches.scss +++ b/frontend/src/app/main/ui/workspace/sidebar/branches.scss @@ -169,6 +169,17 @@ color: var(--color-foreground-primary); } +.merge-summary { + @include use-typography("body-small"); + + display: flex; + flex-direction: column; + gap: var(--sp-xs); + margin: 0; + padding-inline-start: var(--sp-l); + color: var(--color-foreground-primary); + list-style: disc; +} .field { display: flex; diff --git a/frontend/translations/en.po b/frontend/translations/en.po index 7661d6cf08..6aae6ad1c5 100644 --- a/frontend/translations/en.po +++ b/frontend/translations/en.po @@ -11556,8 +11556,23 @@ msgstr "Main's %s:" msgid "workspace.branches.resolve.drops.branch-short" msgstr "The branch's %s:" +#: src/app/main/ui/workspace/sidebar/branches.cljs +msgid "workspace.branches.merge.summary-in" +msgid_plural "workspace.branches.merge.summary-in" +msgstr[0] "1 change goes into main." +msgstr[1] "%s changes go into main." +#: src/app/main/ui/workspace/sidebar/branches.cljs +msgid "workspace.branches.merge.summary-out" +msgid_plural "workspace.branches.merge.summary-out" +msgstr[0] "1 change is left out." +msgstr[1] "%s changes are left out." +#: src/app/main/ui/workspace/sidebar/branches.cljs +msgid "workspace.branches.merge.left-out-lost" +msgid_plural "workspace.branches.merge.left-out-lost" +msgstr[0] "The change you left out is lost when the branch is deleted. Archive the branch to keep it." +msgstr[1] "The %s changes you left out are lost when the branch is deleted. Archive the branch to keep them." #: src/app/main/ui/workspace/sidebar/branch_review/compare.cljs msgid "workspace.branches.review.view.expand"