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.

feat(weigh-ins): Undo after deleting a weigh-in (#756)

Duarte Santos5f324935ba58
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0e8499290..50ebfa2ee 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -88,6 +88,8 @@ per muscle. Settings → Workout → Fine-tuning turns it off.
Fine-tuning → Last time means → Any workout lets Thursday start from Monday, for the rows, the
"last time" line and progression alike. The default stays per routine, so a heavy day and a
light day keep their own numbers.
+- **Deleted a weigh-in by mistake? Undo.** Deleting one now shows a toast with Undo, on the log
+ sheet and in All weigh-ins, and the weigh-in comes back as if nothing happened (#756).
**Security.** Follow-ups to v1.4.2's audit.
- **Pairing the phone app asks you to confirm it's you** (passkey, or your password where that
diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.js
index aa4a10c31..3068b4509 100644
--- a/frontend/src/locales/ar.js
+++ b/frontend/src/locales/ar.js
@@ -2547,4 +2547,6 @@ export default {
"{0} must be between 0 and 100%.": "يجب أن تكون قيمة {0} بين 0 و100٪.",
// --- warm-ups counted in volume (#719) ---
"Added before your work sets. They count in your volume (Settings), but stay out of records and progression. Each one closes half the gap to the work weight, never below the bar on a barbell lift, and you can still change any of them mid-session.": "تُضاف قبل مجموعات العمل. تُحتسب في حجمك (الإعدادات)، لكنها لا تُحتسب في الأرقام القياسية أو التدرج. كل واحدة تقلص الفجوة إلى وزن العمل إلى النصف، ولا تقل أبدًا عن وزن البار في تمارين البار، ويمكنك تعديل أي منها أثناء الجلسة.",
+ // --- weigh-in undo (#756) ---
+ "Weigh-in deleted": "تم حذف الوزن",
}
diff --git a/frontend/src/locales/bn.js b/frontend/src/locales/bn.js
index f309e7e62..ef12dd9d5 100644
--- a/frontend/src/locales/bn.js
+++ b/frontend/src/locales/bn.js
@@ -2571,4 +2571,6 @@ export default {
"{0} must be between 0 and 100%.": "{0} অবশ্যই ০ থেকে ১০০%-এর মধ্যে হতে হবে।",
// --- warm-ups counted in volume (#719) ---
"Added before your work sets. They count in your volume (Settings), but stay out of records and progression. Each one closes half the gap to the work weight, never below the bar on a barbell lift, and you can still change any of them mid-session.": "ওয়ার্ক সেটের আগে যোগ হয়। আপনার ভলিউমে গোনা হয় (সেটিংস), কিন্তু রেকর্ড আর প্রগ্রেশনে নয়। প্রতিটি ওয়ার্ক ওয়েটের দূরত্বের অর্ধেক কমায়, বারবেল লিফটে বারের নিচে কখনো নামে না, আর সেশনের মাঝেও যেকোনোটা বদলাতে পারবেন।",
+ // --- weigh-in undo (#756) ---
+ "Weigh-in deleted": "ওজন মুছে ফেলা হয়েছে",
}
diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js
index e7f04a571..d3a83d0c0 100644
--- a/frontend/src/locales/de.js
+++ b/frontend/src/locales/de.js
@@ -2512,4 +2512,6 @@ export default {
"{0} must be between 0 and 100%.": "{0} muss zwischen 0 und 100 % liegen.",
// --- warm-ups counted in volume (#719) ---
"Added before your work sets. They count in your volume (Settings), but stay out of records and progression. Each one closes half the gap to the work weight, never below the bar on a barbell lift, and you can still change any of them mid-session.": "Kommen vor deine Arbeitssätze. Sie zählen in dein Volumen (Einstellungen), aber nicht für Rekorde und Progression. Jeder halbiert den Abstand zum Arbeitsgewicht, bei Langhantelübungen nie leichter als die leere Stange, und im Training kannst du jeden davon trotzdem ändern.",
+ // --- weigh-in undo (#756) ---
+ "Weigh-in deleted": "Wiegung gelöscht",
}
diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js
index af3ed1f67..91ca274ee 100644
--- a/frontend/src/locales/es.js
+++ b/frontend/src/locales/es.js
@@ -2492,4 +2492,6 @@ export default {
"{0} must be between 0 and 100%.": "{0} debe estar entre 0 y 100 %.",
// --- warm-ups counted in volume (#719) ---
"Added before your work sets. They count in your volume (Settings), but stay out of records and progression. Each one closes half the gap to the work weight, never below the bar on a barbell lift, and you can still change any of them mid-session.": "Se añaden antes de tus series de trabajo. Cuentan en tu volumen (Ajustes), pero no para los récords ni la progresión. Cada una reduce a la mitad la distancia hasta el peso de trabajo, sin bajar nunca de la barra vacía en un ejercicio con barra, y puedes cambiar cualquiera durante la sesión.",
+ // --- weigh-in undo (#756) ---
+ "Weigh-in deleted": "Pesaje eliminado",
}
diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js
index 9e2d3984c..9122ba3a0 100644
--- a/frontend/src/locales/fr.js
+++ b/frontend/src/locales/fr.js
@@ -2492,4 +2492,6 @@ export default {
"{0} must be between 0 and 100%.": "{0} doit être compris entre 0 et 100 %.",
// --- warm-ups counted in volume (#719) ---
"Added before your work sets. They count in your volume (Settings), but stay out of records and progression. Each one closes half the gap to the work weight, never below the bar on a barbell lift, and you can still change any of them mid-session.": "Ajoutées avant tes séries de travail. Elles comptent dans ton volume (Réglages), mais restent exclues des records et de la progression. Chacune réduit de moitié l’écart avec la charge de travail, sans jamais descendre sous la barre à vide pour un exercice à la barre, et tu peux toujours les modifier pendant la séance.",
+ // --- weigh-in undo (#756) ---
+ "Weigh-in deleted": "Pesée supprimée",
}
diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js
index 5d7d9949e..f461a81da 100644
--- a/frontend/src/locales/hi.js
+++ b/frontend/src/locales/hi.js
@@ -2492,4 +2492,6 @@ export default {
"{0} must be between 0 and 100%.": "{0} का मान 0 से 100% के बीच होना चाहिए।",
// --- warm-ups counted in volume (#719) ---
"Added before your work sets. They count in your volume (Settings), but stay out of records and progression. Each one closes half the gap to the work weight, never below the bar on a barbell lift, and you can still change any of them mid-session.": "ये आपके वर्क सेट से पहले जुड़ते हैं। ये आपके वॉल्यूम में गिने जाते हैं (सेटिंग्स), लेकिन रिकॉर्ड और प्रोग्रेशन में नहीं। हर सेट वर्क वज़न तक बची दूरी को आधा कर देता है, बारबेल लिफ़्ट में कभी खाली बार से हल्का नहीं होता, और कसरत के बीच भी आप इनमें से किसी को बदल सकते हैं।",
+ // --- weigh-in undo (#756) ---
+ "Weigh-in deleted": "वज़न हटाया गया",
}
diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js
index cb24407d7..7522415b4 100644
--- a/frontend/src/locales/hu.js
+++ b/frontend/src/locales/hu.js
@@ -2495,4 +2495,6 @@ export default {
"{0} must be between 0 and 100%.": "{0} értékének 0 és 100% között kell lennie.",
// --- warm-ups counted in volume (#719) ---
"Added before your work sets. They count in your volume (Settings), but stay out of records and progression. Each one closes half the gap to the work weight, never below the bar on a barbell lift, and you can still change any of them mid-session.": "A munkasorozatok elé kerülnek. Beleszámítanak a volumenedbe (Beállítások), de a rekordokból és a progresszióból kimaradnak. Mindegyik a felére zárja a különbséget a munkasúlyhoz, rúddal végzett gyakorlatnál soha nem könnyebb az üres rúdnál, és edzés közben is bármelyiket módosíthatod.",
+ // --- weigh-in undo (#756) ---
+ "Weigh-in deleted": "Mérés törölve",
}
diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js
index 295553faa..ee52ab5de 100644
--- a/frontend/src/locales/it.js
+++ b/frontend/src/locales/it.js
@@ -2492,4 +2492,6 @@ export default {
"{0} must be between 0 and 100%.": "{0} deve essere tra 0 e 100%.",
// --- warm-ups counted in volume (#719) ---
"Added before your work sets. They count in your volume (Settings), but stay out of records and progression. Each one closes half the gap to the work weight, never below the bar on a barbell lift, and you can still change any of them mid-session.": "Vengono aggiunte prima delle serie di lavoro. Contano nel tuo volume (Impostazioni), ma non per record e progressione. Ognuna dimezza la distanza dal peso di lavoro, senza mai scendere sotto il bilanciere scarico negli esercizi con bilanciere, e puoi comunque modificarle durante la sessione.",
+ // --- weigh-in undo (#756) ---
+ "Weigh-in deleted": "Pesata eliminata",
}
diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js
index 64978571c..f1b008598 100644
--- a/frontend/src/locales/ko.js
+++ b/frontend/src/locales/ko.js
@@ -2492,4 +2492,6 @@ export default {
"{0} must be between 0 and 100%.": "{0} 값은 0~100% 사이여야 합니다.",
// --- warm-ups counted in volume (#719) ---
"Added before your work sets. They count in your volume (Settings), but stay out of records and progression. Each one closes half the gap to the work weight, never below the bar on a barbell lift, and you can still change any of them mid-session.": "작업 세트 앞에 추가됩니다. 볼륨에는 포함되지만(설정), 기록과 진행에는 포함되지 않습니다. 각 세트는 작업 중량까지의 차이를 절반으로 줄이고 바벨 운동에서는 빈 바보다 가벼워지지 않으며, 운동 중에도 언제든 바꿀 수 있어요.",
+ // --- weigh-in undo (#756) ---
+ "Weigh-in deleted": "체중 기록 삭제됨",
}
diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js
index ce30fb79d..d53521b08 100644
--- a/frontend/src/locales/pl.js
+++ b/frontend/src/locales/pl.js
@@ -2492,4 +2492,6 @@ export default {
"{0} must be between 0 and 100%.": "{0} musi mieścić się w zakresie od 0 do 100%.",
// --- warm-ups counted in volume (#719) ---
"Added before your work sets. They count in your volume (Settings), but stay out of records and progression. Each one closes half the gap to the work weight, never below the bar on a barbell lift, and you can still change any of them mid-session.": "Dodawane przed seriami roboczymi. Liczą się do Twojej objętości (Ustawienia), ale nie do rekordów i progresji. Każda zmniejsza o połowę dystans do ciężaru roboczego, przy sztandze nigdy nie schodzi poniżej pustego gryfu, a w trakcie treningu nadal możesz każdą zmienić.",
+ // --- weigh-in undo (#756) ---
+ "Weigh-in deleted": "Ważenie usunięte",
}
diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js
index 82de447fb..4f7bb89a6 100644
--- a/frontend/src/locales/pt-BR.js
+++ b/frontend/src/locales/pt-BR.js
@@ -1598,6 +1598,8 @@ export const PT_BR_OVERRIDES = {
"{0} must be between 0 and 100%.": "{0} deve estar entre 0 e 100%.",
// --- warm-ups counted in volume (#719) ---
"Added before your work sets. They count in your volume (Settings), but stay out of records and progression. Each one closes half the gap to the work weight, never below the bar on a barbell lift, and you can still change any of them mid-session.": "Entram antes das suas séries de trabalho. Contam no seu volume (Ajustes), mas ficam de fora dos recordes e da progressão. Cada uma fecha metade da distância até o peso de trabalho, nunca abaixo da barra vazia em um exercício com barra, e você ainda pode mudar qualquer uma no meio do treino.",
+ // --- weigh-in undo (#756) ---
+ "Weigh-in deleted": "Pesagem excluída",
}
export default { ...pt, ...PT_BR_OVERRIDES }
diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js
index 529bbf81a..3f96669aa 100644
--- a/frontend/src/locales/pt.js
+++ b/frontend/src/locales/pt.js
@@ -2492,4 +2492,6 @@ export default {
"{0} must be between 0 and 100%.": "{0} tem de estar entre 0 e 100 %.",
// --- warm-ups counted in volume (#719) ---
"Added before your work sets. They count in your volume (Settings), but stay out of records and progression. Each one closes half the gap to the work weight, never below the bar on a barbell lift, and you can still change any of them mid-session.": "São acrescentadas antes das tuas séries de trabalho. Contam no teu volume (Definições), mas ficam de fora dos recordes e da progressão. Cada uma reduz a metade a distância até ao peso de trabalho, nunca abaixo da barra vazia num exercício com barra, e podes alterar qualquer uma a meio da sessão.",
+ // --- weigh-in undo (#756) ---
+ "Weigh-in deleted": "Pesagem eliminada",
}
diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js
index 09776da3a..0727da3d1 100644
--- a/frontend/src/locales/ru.js
+++ b/frontend/src/locales/ru.js
@@ -2496,4 +2496,6 @@ export default {
"{0} must be between 0 and 100%.": "Значение «{0}» должно быть от 0 до 100%.",
// --- warm-ups counted in volume (#719) ---
"Added before your work sets. They count in your volume (Settings), but stay out of records and progression. Each one closes half the gap to the work weight, never below the bar on a barbell lift, and you can still change any of them mid-session.": "Добавляются перед рабочими подходами. Они учитываются в вашем объёме (Настройки), но не в рекордах и прогрессии. Каждый вдвое сокращает разрыв до рабочего веса, но в упражнениях со штангой никогда не легче пустого грифа, и любой из них можно изменить прямо во время тренировки.",
+ // --- weigh-in undo (#756) ---
+ "Weigh-in deleted": "Взвешивание удалено",
}
diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js
index ae1b2b9c0..8dfcbad54 100644
--- a/frontend/src/locales/th.js
+++ b/frontend/src/locales/th.js
@@ -2503,4 +2503,6 @@ export default {
"{0} must be between 0 and 100%.": "{0} ต้องอยู่ระหว่าง 0 ถึง 100%",
// --- warm-ups counted in volume (#719) ---
"Added before your work sets. They count in your volume (Settings), but stay out of records and progression. Each one closes half the gap to the work weight, never below the bar on a barbell lift, and you can still change any of them mid-session.": "เพิ่มไว้ก่อนเซ็ตหลัก นับรวมในปริมาณงานของคุณ (การตั้งค่า) แต่ไม่นับในสถิติหรือการเพิ่มน้ำหนัก แต่ละเซ็ตจะลดช่องว่างไปครึ่งหนึ่งจนถึงน้ำหนักเซ็ตหลัก ท่าบาร์เบลจะไม่เบากว่าบาร์เปล่า และยังปรับเปลี่ยนได้ระหว่างออกกำลังกาย",
+ // --- weigh-in undo (#756) ---
+ "Weigh-in deleted": "ลบการชั่งน้ำหนักแล้ว",
}
diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js
index 8299aeeaf..eef60ea2f 100644
--- a/frontend/src/locales/tr.js
+++ b/frontend/src/locales/tr.js
@@ -2492,4 +2492,6 @@ export default {
"{0} must be between 0 and 100%.": "{0}, %0 ile %100 arasında olmalı.",
// --- warm-ups counted in volume (#719) ---
"Added before your work sets. They count in your volume (Settings), but stay out of records and progression. Each one closes half the gap to the work weight, never below the bar on a barbell lift, and you can still change any of them mid-session.": "Çalışma setlerinden önce eklenir. Hacmine sayılır (Ayarlar), ama rekor ve ilerlemeye sayılmaz. Her biri çalışma ağırlığına kalan farkı yarıya indirir, halter hareketlerinde boş barın altına hiç inmez ve antrenman sırasında hâlâ istediğini değiştirebilirsin.",
+ // --- weigh-in undo (#756) ---
+ "Weigh-in deleted": "Tartım silindi",
}
diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.js
index 4234f4646..1a08c7ee8 100644
--- a/frontend/src/locales/uk.js
+++ b/frontend/src/locales/uk.js
@@ -2489,4 +2489,6 @@ export default {
"{0} must be between 0 and 100%.": "Значення «{0}» має бути від 0 до 100%.",
// --- warm-ups counted in volume (#719) ---
"Added before your work sets. They count in your volume (Settings), but stay out of records and progression. Each one closes half the gap to the work weight, never below the bar on a barbell lift, and you can still change any of them mid-session.": "Додаються перед робочими підходами. Вони враховуються у твоєму обсязі (Налаштування), але не в рекордах і прогресії. Кожен удвічі скорочує розрив до робочої ваги, але у вправах зі штангою ніколи не легший за порожній гриф, і будь-який із них можна змінити під час тренування.",
+ // --- weigh-in undo (#756) ---
+ "Weigh-in deleted": "Зважування видалено",
}
diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.js
index a0babe484..9841a4741 100644
--- a/frontend/src/locales/zh-TW.js
+++ b/frontend/src/locales/zh-TW.js
@@ -2485,4 +2485,6 @@ export default {
"{0} must be between 0 and 100%.": "{0}必須介於 0% 到 100% 之間。",
// --- warm-ups counted in volume (#719) ---
"Added before your work sets. They count in your volume (Settings), but stay out of records and progression. Each one closes half the gap to the work weight, never below the bar on a barbell lift, and you can still change any of them mid-session.": "排在正式組之前。會列入你的總訓練量(設定),但不列入個人紀錄與漸進計算。每組都會把與正式重量的差距縮小一半,槓鈴動作不會低於空槓,訓練中仍可隨時修改任何一組。",
+ // --- weigh-in undo (#756) ---
+ "Weigh-in deleted": "已刪除體重紀錄",
}
diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js
index 333ca618a..dae465f1b 100644
--- a/frontend/src/locales/zh.js
+++ b/frontend/src/locales/zh.js
@@ -2492,4 +2492,6 @@ export default {
"{0} must be between 0 and 100%.": "{0}必须在 0% 到 100% 之间。",
// --- warm-ups counted in volume (#719) ---
"Added before your work sets. They count in your volume (Settings), but stay out of records and progression. Each one closes half the gap to the work weight, never below the bar on a barbell lift, and you can still change any of them mid-session.": "加在正式组之前。计入你的容量(设置),但不计入纪录和进阶。每一组都把与正式重量的差距缩小一半,杠铃动作不会低于空杠,训练中仍可随时调整任意一组。",
+ // --- weigh-in undo (#756) ---
+ "Weigh-in deleted": "称重记录已删除",
}
diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx
index 648ddfaf2..1ac9c76fe 100644
--- a/frontend/src/sheets.jsx
+++ b/frontend/src/sheets.jsx
@@ -366,8 +366,22 @@ export function bwSheet(opts = {}) {
// The full list asks first (`confirm`): it is months of history scrolled through on a phone, and a
// stray tap on one of its trash buttons took a past weigh-in with nothing to bring it back. The log
// sheet's three are the ones just typed, where taking back a typo in one tap is the point.
+// Either way the toast offers Undo (#756): the weigh-in comes back as it was, and the store
+// records it as added back (stampDeletions), so a device that synced the removal keeps it too.
function WeighInRow({ b, unit, confirm = false }) {
- const delEntry = () => update(s => { s.bodyweight = s.bodyweight.filter(x => x.d !== b.d) })
+ const delEntry = () => {
+ const kept = { ...b }
+ update(s => { s.bodyweight = s.bodyweight.filter(x => x.d !== b.d) })
+ ui().toast(t('Weigh-in deleted'), {
+ action: t('Undo'),
+ onAction: () => update(s => {
+ // A weigh-in logged for that day since is the newer word on it.
+ if (s.bodyweight.some(x => x.d === kept.d)) return
+ s.bodyweight.push(kept)
+ s.bodyweight.sort((x, y) => (x.d < y.d ? -1 : 1))
+ }),
+ })
+ }
const ask = () => confirmSheet({
title: t('Delete weigh-in?'), message: `${fmtDate(b.d, true)} · ${fmtNum(b.w)} ${unit}`,
confirmText: t('Delete'), danger: true, onConfirm: delEntry,
diff --git a/frontend/src/sheets.weighin-undo.test.jsx b/frontend/src/sheets.weighin-undo.test.jsx
new file mode 100644
index 000000000..58bbfc4c7
--- /dev/null
+++ b/frontend/src/sheets.weighin-undo.test.jsx
@@ -0,0 +1,90 @@
+// @vitest-environment happy-dom
+// #756: deleting a weigh-in could not be taken back. The log sheet deletes in one tap on purpose
+// (a typo just typed), so the safety is an Undo in the toast, the way Plan does it for a routine.
+import React, { act } from 'react'
+import { afterEach, beforeEach, describe, expect, it } from 'vitest'
+import { createRoot } from 'react-dom/client'
+import { DEF, useStore } from './store/useStore.js'
+import { useUI } from './store/useUI.js'
+import { mergeStates } from './lib/sync-merge.js'
+import { bwSheet, weighInsSheet } from './sheets.jsx'
+
+const clone = v => JSON.parse(JSON.stringify(v))
+const mounted = []
+function mountTopSheet() {
+ const sheet = useUI.getState().sheets.at(-1)
+ const host = document.createElement('div')
+ document.body.appendChild(host)
+ const root = createRoot(host)
+ mounted.push(root)
+ act(() => root.render(sheet.render(() => useUI.getState().closeSheet(sheet.id))))
+ return host
+}
+const button = (host, text) => [...host.querySelectorAll('button')].find(b => b.textContent.trim() === text)
+const days = () => useStore.getState().S.bodyweight.map(b => b.d)
+
+const LOG = [
+ { d: '2026-09-01', w: 81, t: 1 }, { d: '2026-09-03', w: 80, t: 2 },
+ { d: '2026-09-07', w: 80.5, t: 3 }, { d: '2026-09-09', w: 79.5, t: 4 }, { d: '2026-09-13', w: 79, t: 5 },
+]
+beforeEach(() => {
+ globalThis.IS_REACT_ACT_ENVIRONMENT = true
+ useUI.setState({ sheets: [], toastMsg: '', toastAction: null })
+ document.body.innerHTML = ''
+ const S = clone(DEF)
+ Object.assign(S, { unit: 'kg', bodyweight: clone(LOG), weekStart: 1, targetW: null })
+ useStore.setState({ S, user: null })
+})
+afterEach(() => { act(() => { mounted.splice(0).forEach(root => root.unmount()) }) })
+
+describe('deleting a weigh-in can be undone (#756)', () => {
+ it('the log sheet\'s one-tap delete offers Undo, and Undo puts the weigh-in back', () => {
+ bwSheet()
+ const log = mountTopSheet()
+ act(() => { log.querySelector('button[aria-label="Delete weigh-in"]').click() })
+ expect(days()).not.toContain('2026-09-13')
+ const ui = useUI.getState()
+ expect(ui.toastMsg).toBe('Weigh-in deleted')
+ expect(ui.toastAction?.label).toBe('Undo')
+ act(() => { useUI.getState().runToastAction() })
+ expect(days()).toEqual(LOG.map(b => b.d))
+ expect(useStore.getState().S.bodyweight.find(b => b.d === '2026-09-13').w).toBe(79)
+ })
+
+ it('the full list asks first, then offers Undo too', () => {
+ weighInsSheet()
+ const host = mountTopSheet()
+ act(() => { host.querySelector('[data-week="2026-08-31"] button[aria-label="Delete weigh-in"]').click() })
+ const ask = mountTopSheet()
+ act(() => { button(ask, 'Delete').click() })
+ expect(days()).not.toContain('2026-09-03')
+ expect(useUI.getState().toastAction?.label).toBe('Undo')
+ act(() => { useUI.getState().runToastAction() })
+ expect(days()).toContain('2026-09-03')
+ })
+
+ // The removal is on record (S.deleted) the moment it happens, and a device that synced it must
+ // not take the weigh-in away again after the Undo.
+ it('survives a merge with a copy that only saw the removal', () => {
+ bwSheet()
+ const log = mountTopSheet()
+ act(() => { log.querySelector('button[aria-label="Delete weigh-in"]').click() })
+ const server = clone(useStore.getState().S)
+ expect(server.deleted.bodyweight['2026-09-13']).toBeGreaterThan(0)
+ act(() => { useUI.getState().runToastAction() })
+ const local = useStore.getState().S
+ expect(local.deleted.bodyweight['2026-09-13']).toBeLessThan(0)
+ expect(mergeStates(local, server).bodyweight.map(b => b.d)).toContain('2026-09-13')
+ expect(mergeStates(server, local).bodyweight.map(b => b.d)).toContain('2026-09-13')
+ })
+
+ it('does not overwrite a weigh-in logged for that day since', () => {
+ bwSheet()
+ const log = mountTopSheet()
+ act(() => { log.querySelector('button[aria-label="Delete weigh-in"]').click() })
+ const run = useUI.getState().toastAction.run
+ useStore.getState().update(s => { s.bodyweight.push({ d: '2026-09-13', w: 78.4, t: Date.now() }) })
+ act(() => { run() })
+ expect(useStore.getState().S.bodyweight.filter(b => b.d === '2026-09-13').map(b => b.w)).toEqual([78.4])
+ })
+})