The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Show success confirmation when remote sync import/export completes (GHY-3747) (#76099)
Eric Normandf5e0129bf673
diff --git a/e2e/support/helpers/e2e-remote-sync-helpers.ts b/e2e/support/helpers/e2e-remote-sync-helpers.tsindex 6a8802d0039..161d509e465 100644--- a/e2e/support/helpers/e2e-remote-sync-helpers.ts+++ b/e2e/support/helpers/e2e-remote-sync-helpers.ts@@ -291,6 +291,15 @@ export const createSharedTenantCollection = (name: string) => {export const interceptTask = () =>cy.intercept("/api/ee/remote-sync/current-task").as("currentTask");+/**+ * The import/export confirmation modal stays open until the user closes it (GHY-3747). Dismiss it so a+ * subsequent interaction isn't blocked by the modal overlay. Waits for the Close button since the modal+ * renders from the same task poll that `waitForTask` observes.+ */+export const closeSyncResultModal = () => {+ cy.findByTestId("sync-success-close-button", { timeout: 10000 }).click();+};+export const waitForTask = ({ taskName }: { taskName: "import" | "export" },retries = 0,@@ -305,6 +314,8 @@ export const waitForTask = (} else if (body?.status !== "successful") {return waitForTask({ taskName }, retries + 1);}+ // A UI-triggered sync leaves its confirmation modal open; close it so the next step can run.+ return closeSyncResultModal();});};diff --git a/e2e/test/scenarios/admin/remote-sync.cy.spec.ts b/e2e/test/scenarios/admin/remote-sync.cy.spec.tsindex 4eb5d04b261..6c569245bc5 100644--- a/e2e/test/scenarios/admin/remote-sync.cy.spec.ts+++ b/e2e/test/scenarios/admin/remote-sync.cy.spec.ts@@ -408,7 +408,8 @@ describe("Remote Sync", () => {cy.findByText(REMOTE_QUESTION_NAME).should("exist");});- H.modal().findByText("Pushing to Git").should("not.exist");+ // waitForTask above already closed the sync confirmation modal.+ H.modal().should("not.exist");H.clickSwitchBranchOption();H.popover().findByRole("option", { name: "main" }).click();@@ -494,7 +495,9 @@ describe("Remote Sync", () => {.findByText("Success").should("exist");- H.modal().should("not.exist", { timeout: 10000 });+ // Read-only setup runs an initial import; close its confirmation modal (GHY-3747).+ H.closeSyncResultModal();+ H.modal().should("not.exist");H.goToMainApp();// In read-only mode, git sync controls should not be visible in app bardiff --git a/enterprise/backend/src/metabase_enterprise/remote_sync/impl.clj b/enterprise/backend/src/metabase_enterprise/remote_sync/impl.cljindex 104c645ff56..9b6170c1b31 100644--- a/enterprise/backend/src/metabase_enterprise/remote_sync/impl.clj+++ b/enterprise/backend/src/metabase_enterprise/remote_sync/impl.clj@@ -313,6 +313,12 @@[:and [:= :model_type model_type] [:= :model_id model_id]]))rows))+(defn- pulled-change-count+ "Total number of entities applied by a pull, across entity-id- and path-identified models in `imported-data`."+ [imported-data]+ (transduce (map count) + 0 (concat (vals (:by-entity-id imported-data))+ (vals (:by-path imported-data)))))+(defn- incremental-import-plan"What an incremental load would touch, or [[incremental-not-possible]] if the change must fall back to a fullimport. On success returns `{:ingestable <ingestable-or-nil> :deleted-rsos <RemoteSyncObject rows>}`. Falls back@@ -398,7 +404,9 @@(log/info "Successfully reloaded entities from git repository"){:status :success:version snapshot-version- :message "Successfully reloaded from git repository"}))+ :outcome {:kind "pulled"+ :count (+ (pulled-change-count imported-data) (count deletes))+ :branch (settings/remote-sync-branch)}}))(defn- capture-dirty-objects"Returns the current non-synced RemoteSyncObject rows — the local changes that have not been pushed.@@ -445,7 +453,8 @@(log/info "Pull merge: remote has not advanced; keeping local changes unchanged"){:status :success:version (source.p/version snapshot)- :merge-summary {:added 0 :updated 0 :removed 0}})+ :merge-summary {:added 0 :updated 0 :removed 0}+ :outcome {:kind "pull-skipped"}})(seq (:conflicts @merge-result))(let [conflicts (mapv remote-sync.merge/conflict-label (:conflicts @merge-result))]@@ -472,7 +481,10 @@(count dirty-objects)){:status :success:version (source.p/version snapshot)- :merge-summary summary}))))+ :merge-summary summary+ :outcome {:kind "pulled"+ :count (apply + (vals summary))+ :branch (settings/remote-sync-branch)}}))))(defn import!"Imports and reloads Metabase entities from a remote snapshot.@@ -531,11 +543,11 @@;; Cheap no-op pull: nothing changed remotely, so nothing is loaded or deleted(and (not force?) (= last-imported-version snapshot-version))- (let [message (format "Skipping import: snapshot version %s matches last imported version" snapshot-version)]- (log/info message)+ (do+ (log/infof "Skipping import: snapshot version %s matches last imported version" snapshot-version){:status :success:version snapshot-version- :message message})+ :outcome {:kind "pull-skipped"}});; Incremental fast-path: not forced, no local drift, and the change is incrementally loadable.;; Touches only changed files, so it can't wholesale-delete unsynced transforms — no conflict scan,@@ -554,12 +566,13 @@;; No blocking conflicts: do the full reload.:else- (do- (load-snapshot! snapshot task-id sync-timestamp :finalize! finalize!)+ (let [imported-data (load-snapshot! snapshot task-id sync-timestamp :finalize! finalize!)](log/info "Successfully reloaded entities from git repository"){:status :success:version snapshot-version- :message "Successfully reloaded from git repository"})))+ :outcome {:kind "pulled"+ :count (pulled-change-count imported-data)+ :branch (settings/remote-sync-branch)}})))(catch Exception e;; A cancellation isn't a failure: log it and return nil. Otherwise log the error, count it, and;; return a user-friendly :error result.@@ -583,7 +596,8 @@local app DB by loading the merged result (the 'pull' half), so local now contains the remote'schanges. Returns a `:success` result with a `:merge-summary`."[source snapshot base-snapshot task-id message sync-timestamp models]- (let [{:keys [status version conflicts summary]}+ (let [pushed-count (count (remote-sync.object/dirty-rows))+ {:keys [status version conflicts summary]}(source/merge-and-store! models snapshot base-snapshot task-id message)](case status:conflict@@ -610,7 +624,11 @@(remote-sync.task/set-version! task-id version)))(log/infof "Exported with merge: folded in %d remote change(s) (added %d, updated %d, removed %d)"(apply + (vals summary)) (:added summary) (:updated summary) (:removed summary))- {:status :success :version version :merge-summary summary})+ {:status :success :version version :merge-summary summary+ :outcome {:kind "merged"+ :pulled (apply + (vals summary))+ :pushed pushed-count+ :branch (settings/remote-sync-branch)}});; The merge was pushed to `version`, but its commit can't be resolved locally (should not happen —;; write-files! updates the local ref before returning). Fail loudly rather than silently advancing;; the version while skipping the reconcile, which would leave local missing the folded-in remote@@ -804,8 +822,11 @@(let [{:keys [version entries]} (source/store! models snapshot task-id message)](remote-sync.task/set-version! task-id version)(t2/update! :model/RemoteSyncObject {:status "synced" :status_changed_at sync-timestamp})- (record-exported-paths! entries))- {:status :success}))+ (record-exported-paths! entries)+ {:status :success+ :outcome {:kind "pushed"+ :count (count entries)+ :branch (settings/remote-sync-branch)}})))(defn export!"Exports remote-synced collections to a remote source repository.@@ -872,7 +893,8 @@(and (not diverged?) (empty? dirty-rows) (empty? disabled-files))(do(log/info "Remote sync export: no changes to export")- {:status :success})+ {:status :success+ :outcome {:kind "push-skipped"}});; Remote hasn't advanced but a dirty row can't be applied incrementally → full re-serialize.(and (not diverged?) (= plan :remote-sync/unsyncable-batch))@@ -893,7 +915,10 @@(t2/delete! :model/RemoteSyncObject :id [:in removed-ids]))(log/infof "Remote sync incremental export: wrote %d, deleted %d"(count upserts) (count delete-paths))- {:status :success})+ {:status :success+ :outcome {:kind "pushed"+ :count (+ (count upserts) (count delete-paths))+ :branch (settings/remote-sync-branch)}});; Remote advanced and the caller did not ask to merge — refuse. The UI's export preflight;; drives the choice between force, new branch, and merge.@@ -1079,7 +1104,7 @@:success (do(when branch(settings/remote-sync-branch! branch))- (remote-sync.task/complete-sync-task! task-id))+ (remote-sync.task/complete-sync-task! task-id (:outcome result))):conflict (do(remote-sync.task/set-version! task-id (:version result))(remote-sync.task/conflict-sync-task! task-id (:conflicts result)))diff --git a/enterprise/backend/src/metabase_enterprise/remote_sync/models/remote_sync_task.clj b/enterprise/backend/src/metabase_enterprise/remote_sync/models/remote_sync_task.cljindex fdb754b8094..56bda997ac0 100644--- a/enterprise/backend/src/metabase_enterprise/remote_sync/models/remote_sync_task.clj+++ b/enterprise/backend/src/metabase_enterprise/remote_sync/models/remote_sync_task.clj@@ -21,7 +21,8 @@(derive :model/RemoteSyncTask :metabase/model)(t2/deftransforms :model/RemoteSyncTask- {:conflicts mi/transform-json})+ {:conflicts mi/transform-json+ :outcome mi/transform-json})(declare current-task)@@ -96,13 +97,17 @@(defn complete-sync-task!"Marks a sync task as completed.- Takes the ID of the sync task to mark as completed.+ Takes the ID of the sync task to mark as completed and an optional `outcome` map describing the result+ (e.g. `{:kind \"pulled\" :count 12 :branch \"main\"}`). The UI renders the outcome to a localized+ confirmation message; we store structured data rather than customer-facing copy.Returns the number of rows updated (should be 1 if successful)."- [task-id]- (t2/update! :model/RemoteSyncTask task-id- {:progress 1.0- :ended_at (mi/now)}))+ ([task-id] (complete-sync-task! task-id nil))+ ([task-id outcome]+ (t2/update! :model/RemoteSyncTask task-id+ {:progress 1.0+ :ended_at (mi/now)+ :outcome outcome})))(defn fail-sync-task!"Marks a sync task as failed.diff --git a/enterprise/backend/src/metabase_enterprise/remote_sync/schema.clj b/enterprise/backend/src/metabase_enterprise/remote_sync/schema.cljindex bde97707984..47b008de305 100644--- a/enterprise/backend/src/metabase_enterprise/remote_sync/schema.clj+++ b/enterprise/backend/src/metabase_enterprise/remote_sync/schema.clj@@ -24,6 +24,7 @@[:version {:optional true} [:maybe :string]][:cancelled {:optional true} [:maybe :boolean]][:error_message {:optional true} [:maybe :string]]+ [:outcome {:optional true} [:maybe :map]][:conflicts {:optional true} [:maybe [:sequential :string]]][:status TaskStatus]])diff --git a/enterprise/backend/test/metabase_enterprise/remote_sync/api_test.clj b/enterprise/backend/test/metabase_enterprise/remote_sync/api_test.cljindex d9c85d95916..eb1ed0a9b15 100644--- a/enterprise/backend/test/metabase_enterprise/remote_sync/api_test.clj+++ b/enterprise/backend/test/metabase_enterprise/remote_sync/api_test.clj@@ -699,6 +699,17 @@:ended_at some?}(mt/user-http-request :crowberto :get 200 "ee/remote-sync/current-task"))))))+(deftest current-task-returns-outcome-test+ (testing "GET /api/ee/remote-sync/current-task returns the structured outcome for a completed task (GHY-3747)"+ (mt/with-temp [:model/RemoteSyncTask {id :id} {:sync_task_type "import"+ :last_progress_report_at :%now+ :started_at :%now}]+ (remote-sync.task/complete-sync-task! id {:kind "pulled" :count 12 :branch "main"})+ (is (=? {:status "successful"+ :ended_at some?+ :outcome {:kind "pulled" :count 12 :branch "main"}}+ (mt/user-http-request :crowberto :get 200 "ee/remote-sync/current-task"))))))+(deftest current-task-returns-error-for-failed-task-test(testing "GET /api/ee/remote-sync/current-task returns error message for failed task"(mt/with-temp [:model/RemoteSyncTask {id :id} {:sync_task_type "export"diff --git a/enterprise/backend/test/metabase_enterprise/remote_sync/impl_test.clj b/enterprise/backend/test/metabase_enterprise/remote_sync/impl_test.cljindex f7e853d41bd..af379af4586 100644--- a/enterprise/backend/test/metabase_enterprise/remote_sync/impl_test.clj+++ b/enterprise/backend/test/metabase_enterprise/remote_sync/impl_test.clj@@ -145,7 +145,21 @@result (impl/import! (source.p/snapshot mock-source) task-id-2 :force? false)](is (= :success (:status result)))(is (= source-version (:version result)))- (is (re-find #"Skipping import.*matches last imported version" (:message result))))))))+ (is (= {:kind "pull-skipped"} (:outcome result))))))))++(deftest handle-task-result!-stores-outcome-test+ (testing "handle-task-result! records the success result's :outcome on the task (GHY-3747)"+ (mt/with-model-cleanup [:model/RemoteSyncTask]+ (let [task-id (t2/insert-returning-pk! :model/RemoteSyncTask+ {:sync_task_type "import"+ :initiated_by (mt/user->id :rasta)})]+ (impl/handle-task-result! {:status :success+ :outcome {:kind "pulled" :count 3 :branch "main"}}+ task-id)+ (let [task (t2/select-one :model/RemoteSyncTask :id task-id)]+ (is (some? (:ended_at task)))+ (is (= {:kind "pulled" :count 3 :branch "main"} (:outcome task)))+ (is (= :successful (:status (t2/hydrate task :status)))))))))(deftest import!-proceeds-when-version-matches-with-force-test(testing "import! proceeds with import when source version matches last imported version but force? is true"@@ -170,7 +184,8 @@result (impl/import! (source.p/snapshot mock-source) task-id-2 :force? true)](is (= :success (:status result)))(is (= source-version (:version result)))- (is (= "Successfully reloaded from git repository" (:message result))))))))+ (is (= "pulled" (get-in result [:outcome :kind])))+ (is (number? (get-in result [:outcome :count]))))))));; export! tests@@ -263,7 +278,7 @@import-result (impl/import! (source.p/snapshot mock-main) (:id import-task))](remote-sync.task/complete-sync-task! (:id import-task))(is (= :success (:status import-result)))- (is (= "Successfully reloaded from git repository" (:message import-result)))+ (is (= "pulled" (get-in import-result [:outcome :kind])))(is (t2/exists? :model/Collection :id coll-id))(is (t2/exists? :model/Card :id card-id))(let [collection (t2/select-one :model/Collection :id coll-id)diff --git a/enterprise/backend/test/metabase_enterprise/remote_sync/models/remote_sync_task_test.clj b/enterprise/backend/test/metabase_enterprise/remote_sync/models/remote_sync_task_test.cljindex d24e975948d..98754266ca5 100644--- a/enterprise/backend/test/metabase_enterprise/remote_sync/models/remote_sync_task_test.clj+++ b/enterprise/backend/test/metabase_enterprise/remote_sync/models/remote_sync_task_test.clj@@ -91,6 +91,15 @@(let [completed-task (t2/select-one :model/RemoteSyncTask :id (:id task))](is (= 1.0 (:progress completed-task)))(is (some? (:ended_at completed-task)))+ (is (nil? (:error_message completed-task)))+ (is (nil? (:outcome completed-task)))))))++(deftest complete-sync-task-stores-outcome-test+ (testing "stores the structured outcome map (round-tripped as JSON) when one is provided"+ (let [task (rst/create-sync-task! "import" (mt/user->id :rasta))]+ (rst/complete-sync-task! (:id task) {:kind "pulled" :count 12 :branch "main"})+ (let [completed-task (t2/select-one :model/RemoteSyncTask :id (:id task))]+ (is (= {:kind "pulled" :count 12 :branch "main"} (:outcome completed-task)))(is (nil? (:error_message completed-task)))))));;; ------------------------------------------------------------------------------------------------diff --git a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncProgressModal.tsx b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncProgressModal.tsxindex 46dfef1d60d..37ac9459ad8 100644--- a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncProgressModal.tsx+++ b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncProgressModal.tsx@@ -6,13 +6,15 @@ import { useSelector } from "metabase/redux";import { getUserIsAdmin } from "metabase/selectors/user";import { Button, Group, Modal, Progress, Stack, Text } from "metabase/ui";import { useCancelRemoteSyncCurrentTaskMutation } from "metabase-enterprise/api";-import type { RemoteSyncTaskType } from "metabase-types/api";+import type { RemoteSyncOutcome, RemoteSyncTaskType } from "metabase-types/api";interface SyncProgressModalProps {taskType: RemoteSyncTaskType;progress: number;isError: boolean;errorMessage: string;+ isSuccess: boolean;+ outcome: RemoteSyncOutcome | null;onDismiss: () => void;}@@ -21,6 +23,8 @@ export function SyncProgressModal({taskType,isError,errorMessage,+ isSuccess,+ outcome,onDismiss,}: SyncProgressModalProps) {const canCancel = useSelector(getUserIsAdmin);@@ -72,6 +76,25 @@ export function SyncProgressModal({);}+ if (isSuccess) {+ const { successTitle } = getModalContent(taskType);++ return (+ <Modal onClose={onDismiss} opened size="md" title={successTitle}>+ <Stack mt="md" gap="md">+ <Text>{getSuccessMessage(outcome, taskType)}</Text>+ <Group justify="flex-end">+ <Button+ data-testid="sync-success-close-button"+ onClick={onDismiss}+ variant="filled"+ >{t`Close`}</Button>+ </Group>+ </Stack>+ </Modal>+ );+ }+const { title, progressLabel } = getModalContent(taskType);return (@@ -105,16 +128,61 @@ export function SyncProgressModal({const getModalContent = (taskType: RemoteSyncTaskType,-): { title: string; progressLabel: string } => {+): {+ title: string;+ progressLabel: string;+ successTitle: string;+} => {if (taskType === "import") {return {title: t`Pulling from Git`,progressLabel: t`Importing content…`,+ successTitle: t`Pull complete`,};}return {title: t`Pushing to Git`,progressLabel: t`Exporting content…`,+ successTitle: t`Push complete`,};};++const isCount = (value: unknown): value is number =>+ typeof value === "number" && Number.isFinite(value);+const isBranch = (value: unknown): value is string => typeof value === "string";++/**+ * Maps a structured sync outcome to a localized confirmation message. Falls back to generic per-task-type+ * copy whenever the outcome is missing, has an unknown `kind`, or is missing the fields that kind needs —+ * so an unrecognized shape never renders a broken message.+ */+function getSuccessMessage(+ outcome: RemoteSyncOutcome | null,+ taskType: RemoteSyncTaskType,+): string {+ switch (outcome?.kind) {+ case "pull-skipped":+ return t`Skipped pull: no changes.`;+ case "push-skipped":+ return t`Skipped push: no changes.`;+ case "pulled":+ return isCount(outcome.count) && isBranch(outcome.branch)+ ? t`Successfully pulled ${outcome.count} changes from ${outcome.branch}.`+ : t`Successfully pulled changes.`;+ case "pushed":+ return isCount(outcome.count) && isBranch(outcome.branch)+ ? t`Successfully pushed ${outcome.count} changes to ${outcome.branch}.`+ : t`Successfully pushed changes.`;+ case "merged":+ return isCount(outcome.pulled) &&+ isCount(outcome.pushed) &&+ isBranch(outcome.branch)+ ? t`Successfully pulled ${outcome.pulled} changes and pushed ${outcome.pushed} changes to ${outcome.branch}.`+ : t`Successfully pulled and pushed changes.`;+ default:+ return taskType === "import"+ ? t`Successfully pulled changes.`+ : t`Successfully pushed changes.`;+ }+}diff --git a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncProgressModal.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncProgressModal.unit.spec.tsxindex 3d40589fbed..e58550a6314 100644--- a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncProgressModal.unit.spec.tsx+++ b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncProgressModal.unit.spec.tsx@@ -6,6 +6,7 @@ import {} from "__support__/server-mocks";import { renderWithProviders, screen, waitFor } from "__support__/ui";import { createMockState } from "metabase/redux/store/mocks";+import type { RemoteSyncOutcome } from "metabase-types/api";import { createMockUser } from "metabase-types/api/mocks";import { SyncProgressModal } from "./SyncProgressModal";@@ -15,6 +16,8 @@ const setup = ({progress = 0.5,isError = false,errorMessage = "",+ isSuccess = false,+ outcome = null,isAdmin = true,onDismiss = jest.fn(),cancelResponse,@@ -23,6 +26,8 @@ const setup = ({progress?: number;isError?: boolean;errorMessage?: string;+ isSuccess?: boolean;+ outcome?: RemoteSyncOutcome | null;isAdmin?: boolean;onDismiss?: jest.Mock;cancelResponse?: { status?: number; body?: any; delay?: number };@@ -39,6 +44,8 @@ const setup = ({progress={progress}isError={isError}errorMessage={errorMessage}+ isSuccess={isSuccess}+ outcome={outcome}onDismiss={onDismiss}/>,{@@ -121,6 +128,131 @@ describe("SyncProgressModal", () => {});});+ describe("success state", () => {+ it("should render the pulled outcome with count and branch", () => {+ setup({+ taskType: "import",+ isSuccess: true,+ outcome: { kind: "pulled", count: 12, branch: "main" },+ });++ expect(screen.getByText("Pull complete")).toBeInTheDocument();+ expect(+ screen.getByText("Successfully pulled 12 changes from main."),+ ).toBeInTheDocument();+ });++ it("should render the pushed outcome with count and branch", () => {+ setup({+ taskType: "export",+ isSuccess: true,+ outcome: { kind: "pushed", count: 3, branch: "main" },+ });++ expect(screen.getByText("Push complete")).toBeInTheDocument();+ expect(+ screen.getByText("Successfully pushed 3 changes to main."),+ ).toBeInTheDocument();+ });++ it("should render the merged outcome with both counts", () => {+ setup({+ taskType: "export",+ isSuccess: true,+ outcome: { kind: "merged", pulled: 1, pushed: 1, branch: "main" },+ });++ expect(+ screen.getByText(+ "Successfully pulled 1 changes and pushed 1 changes to main.",+ ),+ ).toBeInTheDocument();+ });++ it("should render the skipped outcomes", () => {+ setup({+ taskType: "import",+ isSuccess: true,+ outcome: { kind: "pull-skipped" },+ });+ expect(screen.getByText("Skipped pull: no changes.")).toBeInTheDocument();+ });++ it("should fall back to generic copy when there is no outcome", () => {+ setup({ taskType: "import", isSuccess: true, outcome: null });++ expect(+ screen.getByText("Successfully pulled changes."),+ ).toBeInTheDocument();+ });++ it("should fall back to task-type copy when the outcome shape is unrecognized", () => {+ // An unknown kind (e.g. from a newer/older server) must not render a broken message.+ setup({+ taskType: "export",+ isSuccess: true,+ outcome: { kind: "teleported" } as unknown as RemoteSyncOutcome,+ });++ expect(+ screen.getByText("Successfully pushed changes."),+ ).toBeInTheDocument();+ });++ it("should fall back to generic pull copy when a pulled outcome is missing fields", () => {+ setup({+ taskType: "import",+ isSuccess: true,+ outcome: { kind: "pulled" } as unknown as RemoteSyncOutcome,+ });++ expect(+ screen.getByText("Successfully pulled changes."),+ ).toBeInTheDocument();+ });++ it("should fall back to generic push copy when a pushed outcome is missing fields", () => {+ setup({+ taskType: "export",+ isSuccess: true,+ outcome: { kind: "pushed", count: 3 } as unknown as RemoteSyncOutcome,+ });++ expect(+ screen.getByText("Successfully pushed changes."),+ ).toBeInTheDocument();+ });++ it("should fall back to combined pull-and-push copy when a merged outcome is missing fields", () => {+ setup({+ taskType: "export",+ isSuccess: true,+ outcome: { kind: "merged", pulled: 1 } as unknown as RemoteSyncOutcome,+ });++ expect(+ screen.getByText("Successfully pulled and pushed changes."),+ ).toBeInTheDocument();+ });++ it("should not show a cancel button in the success state", () => {+ setup({ isSuccess: true, isAdmin: true });++ expect(+ screen.queryByRole("button", { name: "Cancel" }),+ ).not.toBeInTheDocument();+ });++ it("should call onDismiss when the close button is clicked", async () => {+ const onDismiss = jest.fn();+ setup({ isSuccess: true, onDismiss });++ await userEvent.click(screen.getByTestId("sync-success-close-button"));++ expect(onDismiss).toHaveBeenCalled();+ });+ });+describe("cancel functionality", () => {it("should call onDismiss when cancel succeeds", async () => {const onDismiss = jest.fn();diff --git a/enterprise/frontend/src/metabase-enterprise/remote_sync/hooks/use-sync-status.tsx b/enterprise/frontend/src/metabase-enterprise/remote_sync/hooks/use-sync-status.tsxindex 567f90af691..146719cb08f 100644--- a/enterprise/frontend/src/metabase-enterprise/remote_sync/hooks/use-sync-status.tsx+++ b/enterprise/frontend/src/metabase-enterprise/remote_sync/hooks/use-sync-status.tsx@@ -9,8 +9,10 @@ import {getHasPendingMutation,getIsError,getIsRunning,+ getIsSuccess,getProgress,getShowModal,+ getTaskOutcome,getTaskType,} from "../selectors";import { modalDismissed } from "../sync-task-slice";@@ -27,6 +29,8 @@ export const useSyncStatus = () => {const progress = useSelector(getProgress);const isError = useSelector(getIsError);const errorMessage = useSelector(getErrorMessage);+ const isSuccess = useSelector(getIsSuccess);+ const outcome = useSelector(getTaskOutcome);const hasPendingMutation = useSelector(getHasPendingMutation);const shouldPoll = isRunning && showModal && !hasPendingMutation;@@ -44,6 +48,8 @@ export const useSyncStatus = () => {progress={progress}isError={isError}errorMessage={errorMessage}+ isSuccess={isSuccess}+ outcome={outcome}onDismiss={() => dispatch(modalDismissed())}/>) : null;diff --git a/enterprise/frontend/src/metabase-enterprise/remote_sync/middleware/remote-sync-listener-middleware.ts b/enterprise/frontend/src/metabase-enterprise/remote_sync/middleware/remote-sync-listener-middleware.tsindex 02611ab6214..ed80cd53bed 100644--- a/enterprise/frontend/src/metabase-enterprise/remote_sync/middleware/remote-sync-listener-middleware.ts+++ b/enterprise/frontend/src/metabase-enterprise/remote_sync/middleware/remote-sync-listener-middleware.ts@@ -135,9 +135,8 @@ remoteSyncListenerMiddleware.startListening({const isSuccessful = task.status === "successful";if (isSuccessful) {- setTimeout(() => {- dispatch(modalDismissed());- }, 500);+ // Leave the modal open showing the success confirmation; the user dismisses it explicitly+ // (the sync can take a while, so we want to acknowledge completion rather than silently close).// Both import and a merged export change local content, so refresh everything. A plain push// doesn't change local data, but the extra refetch is harmless and keeps this simple.diff --git a/enterprise/frontend/src/metabase-enterprise/remote_sync/selectors.ts b/enterprise/frontend/src/metabase-enterprise/remote_sync/selectors.tsindex ec39301183f..952aa2d28f1 100644--- a/enterprise/frontend/src/metabase-enterprise/remote_sync/selectors.ts+++ b/enterprise/frontend/src/metabase-enterprise/remote_sync/selectors.ts@@ -40,11 +40,21 @@ export const getIsError = createSelector((currentTask) => currentTask?.status === "errored",);+export const getIsSuccess = createSelector(+ getCurrentTask,+ (currentTask) => currentTask?.status === "successful",+);+export const getErrorMessage = createSelector(getCurrentTask,(currentTask) => currentTask?.error_message ?? "",);+export const getTaskOutcome = createSelector(+ getCurrentTask,+ (currentTask) => currentTask?.outcome ?? null,+);+export const getHasPendingMutation = createSelector([(state: State) => state[remoteSyncApi.reducerPath]?.mutations],(mutations) => {diff --git a/frontend/src/metabase-types/api/remote-sync.ts b/frontend/src/metabase-types/api/remote-sync.tsindex dc20c688856..20ce041785b 100644--- a/frontend/src/metabase-types/api/remote-sync.ts+++ b/frontend/src/metabase-types/api/remote-sync.ts@@ -145,6 +145,17 @@ export type RemoteSyncTaskStatus =export type RemoteSyncTaskType = "import" | "export" | null;+/**+ * Structured result of a completed sync task. The UI renders it to a localized message; unrecognized+ * shapes fall back to generic copy, so this union can grow without breaking older/newer clients.+ */+export type RemoteSyncOutcome =+ | { kind: "pulled"; count: number; branch: string }+ | { kind: "pull-skipped" }+ | { kind: "pushed"; count: number; branch: string }+ | { kind: "push-skipped" }+ | { kind: "merged"; pulled: number; pushed: number; branch: string };+export type RemoteSyncTask = {id: number;sync_task_type: RemoteSyncTaskType;@@ -154,6 +165,7 @@ export type RemoteSyncTask = {ended_at: string | null;last_progress_report_at: string | null;error_message: string | null;+ outcome?: RemoteSyncOutcome | null;initiated_by: UserId;conflicts?: string[];};diff --git a/resources/migrations/063/20260618_ghy_3747_remote_sync_task_outcome.yaml b/resources/migrations/063/20260618_ghy_3747_remote_sync_task_outcome.yamlnew file mode 100644index 00000000000..46ed74ca04d--- /dev/null+++ b/resources/migrations/063/20260618_ghy_3747_remote_sync_task_outcome.yaml@@ -0,0 +1,22 @@+## Add outcome column to remote_sync_task: structured result data, rendered to a localized message on read (GHY-3747)++databaseChangeLog:++ - changeSet:+ id: v63.2026-06-18T00:00:00+ author: ericnormand+ comment: Add remote_sync_task.outcome, a JSON map describing the task result (e.g. {"kind":"pulled","count":12,"branch":"main"}); the UI renders it to a localized confirmation message rather than storing customer-facing copy+ changes:+ - addColumn:+ tableName: remote_sync_task+ columns:+ - column:+ name: outcome+ type: ${text.type}+ remarks: JSON describing the task outcome (kind plus counts/branch), rendered to a localized confirmation message in the UI+ constraints:+ nullable: true+ rollback:+ - dropColumn:+ tableName: remote_sync_task+ columnName: outcome