Repository navigation
Conversation
calculateTotalHours split each time on ":" and checked Number.isNaN on the resulting hour/minute pair, but an empty or partial time string (e.g. "") produces a one-element array, leaving the minute undefined rather than NaN. Number.isNaN(undefined) is false, so the guard let it through and undefined arithmetic turned the total into NaN. Switch the guard to Number.isFinite, which catches both NaN and undefined. Also give the default time entry actual values (08:00-16:30) instead of empty strings, so a fresh form shows "Total Hours: 8.5" as expected instead of relying on placeholder text that was never written to the form state. Moved calculateTotalHours into its own utils module so it can be unit tested without pulling in useWorkLogForm's full dependency graph (react-query hooks, offline sync, etc). Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
Test Results0 tests 0 ✅ 0s ⏱️ Results for commit 5694671. |
This was referenced Jul 17, 2026
Closed
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #380.
Root cause
calculateTotalHoursinuseWorkLogForm.tssplit each time entry on":"and guarded againstNumber.isNaNon the resulting hour/minute values. But an empty or partial time string (e.g."") produces a one-element array from.split(":"), leaving the minuteundefinedrather thanNaN.Number.isNaN(undefined)isfalse, so the guard let it through, andundefinedarithmetic downstream turned the total intoNaN.Fix
Number.isNaNtoNumber.isFinite, which correctly rejects bothNaNandundefined.08:00–16:30) instead of empty strings, so a fresh form immediately shows "Total Hours: 8.5" as the issue's acceptance criteria expects, rather than relying on placeholder text that was never written to form state.calculateTotalHoursinto its ownutils/time-entries.tsmodule so it can be unit tested directly, without pulling inuseWorkLogForm's full dependency graph (react-query hooks, offline sync, etc).Testing
packages/scf-core/features/work-logs/utils/__tests__/time-entries.test.ts(5 cases: default entry, multiple entries, empty strings, partial strings, invalid end-before-start) — all pass.pnpm exec biome lintclean on changed files.tsc --noEmitshows no new errors introduced by this change (pre-existing errors in this sandbox are all from the@scaffald/ui/@scaffald/sdkgit submodules not being checked out — an environment limitation, not something from this diff).Note: I wasn't able to run the full
pnpm prepush(nx affected -t build) in this sandbox because thepackages/uiandpackages/sdkgit submodules aren't initialized here (no access toScaffald/ui/Scaffald/sdk), which breaks the Nx project graph repo-wide regardless of this change. Verified correctness via targeted unit tests, typecheck, and lint instead.🤖 Opened by the Friday weekly-improvement routine.
Generated by Claude Code