From bad5764cdfcbfb89c32dae1b26c81140467bd0da Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Mar 2026 08:03:25 +0000 Subject: [PATCH 1/2] Fix expressed feeds showing duration instead of ml amount MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The display logic checked duration_seconds before amount_ml regardless of feed type. When an expressed feed was edited and times changed, the backend recalculated duration_seconds (intended only for breast feeds), causing the UI to show a duration instead of the ml amount. - Frontend: use entry.type to decide display format (breast → duration, formula/expressed → ml) - Backend: only recalculate duration_seconds for breast feed entries https://claude.ai/code/session_01HMNC1Vw48E32d6qkNrWzke --- src/pages/Feed.tsx | 6 ++++-- worker/routes/feed.ts | 28 +++++++++++++++------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/pages/Feed.tsx b/src/pages/Feed.tsx index c4e3e4b..15a8e40 100644 --- a/src/pages/Feed.tsx +++ b/src/pages/Feed.tsx @@ -316,8 +316,10 @@ export default function Feed() { )} - {entry.duration_seconds - ? formatDuration(entry.duration_seconds) + {entry.type === "breast" + ? entry.duration_seconds + ? formatDuration(entry.duration_seconds) + : "-" : entry.amount_ml ? `${entry.amount_ml}ml` : "-"} diff --git a/worker/routes/feed.ts b/worker/routes/feed.ts index af4a294..55d3129 100644 --- a/worker/routes/feed.ts +++ b/worker/routes/feed.ts @@ -158,19 +158,21 @@ feed.put("/:id", zValidator("json", editSchema), async (c) => { if (body.amount_ml !== undefined) updates.amount_ml = body.amount_ml; if (body.notes !== undefined) updates.notes = body.notes; - // Recalculate duration if times changed (breast feeds) - const startedAt = (updates.started_at as string) ?? entry.started_at; - const endedAt = (updates.ended_at as string) ?? entry.ended_at; - if ( - (body.started_at !== undefined || body.ended_at !== undefined) && - endedAt - ) { - const pauses: Pause[] = JSON.parse(entry.pauses); - updates.duration_seconds = calculateElapsedSeconds( - startedAt, - pauses, - endedAt, - ); + // Recalculate duration if times changed (breast feeds only) + if (entry.type === "breast") { + const startedAt = (updates.started_at as string) ?? entry.started_at; + const endedAt = (updates.ended_at as string) ?? entry.ended_at; + if ( + (body.started_at !== undefined || body.ended_at !== undefined) && + endedAt + ) { + const pauses: Pause[] = JSON.parse(entry.pauses); + updates.duration_seconds = calculateElapsedSeconds( + startedAt, + pauses, + endedAt, + ); + } } await repo.update(id, updates); From 8430237c0aedaf8d7d81ebe1f1d760c527b54b1c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Mar 2026 08:23:18 +0000 Subject: [PATCH 2/2] Sync ended_at with started_at when editing formula/expressed feeds Formula and expressed feeds are instant events where started_at and ended_at are set to the same timestamp on creation. When editing the time, only started_at was updated, leaving ended_at stale. Now the backend keeps them in sync for non-breast feed types. https://claude.ai/code/session_01HMNC1Vw48E32d6qkNrWzke --- worker/routes/feed.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/worker/routes/feed.ts b/worker/routes/feed.ts index 55d3129..9c61ad7 100644 --- a/worker/routes/feed.ts +++ b/worker/routes/feed.ts @@ -158,8 +158,8 @@ feed.put("/:id", zValidator("json", editSchema), async (c) => { if (body.amount_ml !== undefined) updates.amount_ml = body.amount_ml; if (body.notes !== undefined) updates.notes = body.notes; - // Recalculate duration if times changed (breast feeds only) if (entry.type === "breast") { + // Recalculate duration if times changed const startedAt = (updates.started_at as string) ?? entry.started_at; const endedAt = (updates.ended_at as string) ?? entry.ended_at; if ( @@ -173,6 +173,9 @@ feed.put("/:id", zValidator("json", editSchema), async (c) => { endedAt, ); } + } else if (body.started_at !== undefined) { + // Formula/expressed are instant events — keep ended_at in sync + updates.ended_at = body.started_at; } await repo.update(id, updates);