Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Sync: a new own colour picked later wins over an older preset from another device

Duarte Santos73b2600673a2
diff --git a/frontend/src/lib/accent.test.js b/frontend/src/lib/accent.test.js
index acd9ed397..6c7cff436 100644
--- a/frontend/src/lib/accent.test.js
+++ b/frontend/src/lib/accent.test.js
@@ -5,7 +5,7 @@ import {
cleanHex, sanitizeAccent, accentKey, accentValue, contrast, inkOn, readableIn, adjustedIn,
customAccentVars, accentPair, applyAccent, THEMES, isGrey, inkOnBoth, mix, GREY_TEXT, GREY_GAP,
} from './accent.js'
-import { mergeStates } from './sync-merge.js'
+import { mergeStates, stampChange } from './sync-merge.js'
describe('cleanHex', () => {
it('takes #rrggbb only, in lowercase', () => {
@@ -218,3 +218,24 @@ describe('sync with an app from before own colours', () => {
expect(accentValue(out)).toBe('lime')
})
})
+
+describe('an own colour and a preset picked on two devices', () => {
+ // QA round 2 (2026-10-06): with the own colour already on, a new one changed only accentCustom,
+ // so a preset picked earlier on the other device kept `accent` and the newer choice was undone.
+ const T = 1_800_000_000_000
+ const base = { _ts: T, unit: 'kg', workouts: [], routines: [], bodyweight: [], accent: 'custom', accentCustom: '#ff0000' }
+ const change = (prev, wall, mut) => { const n = JSON.parse(JSON.stringify(prev)); mut(n); n._ts = stampChange(prev, n, wall); return n }
+ it('a new own colour picked later wins both fields, in either merge order', () => {
+ const B = change(base, T + 1000, s => { s.accent = 'sky' })
+ const A = change(base, T + 4000, s => { s.accent = 'custom'; s.accentCustom = '#00aa00' })
+ for (const out of [mergeStates(A, B), mergeStates(B, A)]) {
+ expect(out.accent).toBe('custom')
+ expect(out.accentCustom).toBe('#00aa00')
+ }
+ })
+ it('a preset picked later still wins over an own colour picked earlier', () => {
+ const A = change(base, T + 1000, s => { s.accent = 'custom'; s.accentCustom = '#00aa00' })
+ const B = change(base, T + 4000, s => { s.accent = 'sky' })
+ for (const out of [mergeStates(A, B), mergeStates(B, A)]) expect(out.accent).toBe('sky')
+ })
+})
diff --git a/frontend/src/lib/sync-merge.js b/frontend/src/lib/sync-merge.js
index b15cac1b8..ef7de93fb 100644
--- a/frontend/src/lib/sync-merge.js
+++ b/frontend/src/lib/sync-merge.js
@@ -525,6 +525,13 @@ export function stampEdits(prev, next, now = Date.now()) {
}
} else if (p !== n && !same(p, n)) { ed[k] = now; touched = true }
}
+ // An own accent colour is one choice made in two fields: picking a new colour while the own
+ // colour is already on changes only accentCustom, and a preset picked earlier on another device
+ // then kept `accent` and won (QA 2026-10-06). Either one changed to an own colour stamps both.
+ if (touched && next.accent === 'custom' && (ed.accent === now || ed.accentCustom === now)) {
+ ed.accent = now
+ ed.accentCustom = now
+ }
if (touched) {
for (const [k, at] of Object.entries(ed)) {
const dot = k.indexOf('.')