fix(sync-ui): clarify remote merge target

This commit is contained in:
2026-07-13 12:43:17 -07:00
parent 37dcec25eb
commit ad37b4322b
3 changed files with 22 additions and 3 deletions
+11 -1
View File
@@ -1,6 +1,11 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { formatBytes, formatRelativeTime, summarizeMergeCounts } from './syncui-format';
import {
formatBytes,
formatMergeTargetHeading,
formatRelativeTime,
summarizeMergeCounts,
} from './syncui-format';
test('formatBytes renders human readable sizes', () => {
assert.equal(formatBytes(0), '0 B');
@@ -19,6 +24,11 @@ test('formatRelativeTime renders past timestamps', () => {
assert.equal(formatRelativeTime(now - 2 * 86_400_000, now), '2 d ago');
});
test('formatMergeTargetHeading names the local and remote machines', () => {
assert.equal(formatMergeTargetHeading('local'), 'Merged into this machine');
assert.equal(formatMergeTargetHeading('remote'), 'Merged into remote machine');
});
test('summarizeMergeCounts lists only non-zero counts', () => {
const summary = {
sessionsMerged: 3,
+4
View File
@@ -1,5 +1,9 @@
import type { SyncMergeSummary } from '../shared/sync/sync-events';
export function formatMergeTargetHeading(target: 'local' | 'remote'): string {
return target === 'local' ? 'Merged into this machine' : 'Merged into remote machine';
}
export function formatBytes(bytes: number): string {
if (bytes < 1024) return `${Math.round(bytes)} B`;
const units = ['KB', 'MB', 'GB', 'TB'];
+7 -2
View File
@@ -7,7 +7,12 @@ import type {
SyncUiSnapshot,
SyncUiStartResult,
} from '../types/sync-ui';
import { formatBytes, formatRelativeTime, summarizeMergeCounts } from './syncui-format';
import {
formatBytes,
formatMergeTargetHeading,
formatRelativeTime,
summarizeMergeCounts,
} from './syncui-format';
declare global {
interface Window {
@@ -134,7 +139,7 @@ function appendMergeSummary(
resultCard.classList.remove('hidden');
const heading = document.createElement('div');
heading.className = 'result-title';
heading.textContent = target === 'local' ? 'Merged into this machine' : 'Merged into the device';
heading.textContent = formatMergeTargetHeading(target);
const grid = document.createElement('div');
grid.className = 'count-grid';
for (const line of lines) {