Skip to content

fix(logs): NaN hours, off-brand list UI, missing work-log API endpoints - #403

Merged
thinkclay merged 1 commit into
mainfrom
fix/logs-hardening
Jul 21, 2026
Merged

thinkclay merged 1 commit into
mainfrom
fix/logs-hardening

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

Summary

Logs feature hardening — fixes the two browser-verifiable bugs from the 2026-07-16 mobile smoke test and wires up the missing work-log API endpoints the UI actually calls (from the "Wire up missing public-API endpoints" dogfood idea task).

Fixes #380
Fixes #386

#380 — "Total Hours: NaN"

  • Root cause: default time entry was {start: "", end: ""} (the 08:00/16:30 were placeholders). "".split(":") yields one element, so the minute part is undefined — which slips past Number.isNaN and poisons the sum into NaN.
  • calculateTotalHours now parses strictly (HH:MM regex); partial input while typing contributes 0, never NaN.
  • Default entry now actually pre-fills 08:00–16:30 → fresh form shows Total Hours: 8.50.
  • Helper exported + 8 unit tests; WorkLogDetailScreen.computeEntryHours had the same latent leak and now reuses it.

#386 — off-brand Logs list at 375×812

  • "New Work Log" / "Record Work Log" / form submit: color="primary" (teal) instead of default gray/black.
  • Sort: single ResponsiveSelect (sheet on mobile) replaces the Dropdown-in-a-pill that read as 2–3 controls.
  • Status filters: horizontally scrollable beyond-ui Chips with full labels ("Pending", "Disputed") replace the truncating SegmentedControl.
  • Header copy stacks above a full-width CTA on non-desktop via useResponsive.

API (packages/supabase/functions/api/routes/work-logs.ts)

  • New: GET /v1/work-logs/overview — status summary + totals + recent activity; feeds the Quick summary banner (previously 404 on every list load). All four status keys always emitted (banner dereferences them unguarded).
  • New: GET /{id}/conversation + POST /{id}/comments — detail-screen thread, enriched with user {display_name, username}. Access via extracted resolveAccessibleWorkLog (RLS first, org-member fallback — same semantics as getById, now shared). parentCommentId accepted-and-ignored (no DB column yet).
  • Fixed: list pagination — SDK/UI paginate 0-based but the route computed a 1-based offset, so page 0 queried range(-20,-1) and the org Logs list always rendered empty (totalCount: 40, workLogs: []).

Verification

  • Unit: 8 new vitest cases for calculateTotalHours pass; scf-core typecheck clean.
  • Browser at 375×812 as [email protected] → org unicorn → Logs: teal CTAs, single sort select, full-label scrollable chips, stacked header; list now populated; Quick summary shows real counts (5 logs / 27.50h). Fresh form shows 8.50; typing "08:" shows inline validation + 0.00, no NaN; no phantom draft created (draft count unchanged).
  • API: GET /overview 200 with real aggregates; conversation GET/POST round-trip verified (comment appears in UI thread); worker without access gets 404 on conversation read + comment post; own overview still 200.
  • Desktop width spot-checked (header row layout, populated list).

🤖 Generated with Claude Code

…386)

Logs feature hardening pass:

- #380: Total Hours NaN — strict HH:MM parsing in calculateTotalHours
  (empty/partial input no longer poisons the sum via undefined minutes),
  default time entry now actually pre-fills 08:00–16:30, helper exported
  with unit tests; WorkLogDetailScreen.computeEntryHours reuses it.
- #386: Logs list restyle at 375×812 — brand-primary CTAs, single
  ResponsiveSelect sort control (was Dropdown-in-pill), horizontally
  scrollable full-label status Chips (was truncating SegmentedControl),
  header copy stacks above the CTA on non-desktop via useResponsive.
- API: add GET /v1/work-logs/overview (feeds the Quick summary banner),
  GET /{id}/conversation and POST /{id}/comments (detail-screen thread),
  sharing an extracted resolveAccessibleWorkLog access helper.
- API: fix list pagination — SDK/UI paginate 0-based but the route
  computed a 1-based offset, so page 0 queried range(-20,-1) and the org
  Logs list always rendered empty.

Co-Authored-By: Claude Fable 5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

📊 Performance Benchmark Results


@github-actions

Copy link
Copy Markdown
Contributor

Test Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit 20831eb.

@thinkclay
thinkclay merged commit 4e88c89 into main Jul 21, 2026
12 of 18 checks passed
@thinkclay
thinkclay deleted the fix/logs-hardening branch July 21, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant