Skip to content

feat(onboarding): expose hasUnsavedChanges on the daily schedule edit state - #1594

Merged
gabrielseco merged 10 commits into
mainfrom
feat/daily-schedule-has-unsaved-changes
Oct 16, 2026
Merged

gabrielseco merged 10 commits into
mainfrom
feat/daily-schedule-has-unsaved-changes

Conversation

@gabrielseco

@gabrielseco gabrielseco commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Custom daily schedule editors can now tell whether closing the editor would discard edits, and read the saved and draft weekly totals straight from the edit state.

Why

isDirty compares the draft against the country default, not against the saved schedule. A partner building their own "Discard changes?" prompt can't use it: it is true when nothing was edited but a custom schedule is saved, and false after editing back to the default. close() discards edits silently, so partners need a reliable signal. Partners also had to recalculate the weekly totals themselves to show a live total next to the saved one.

What changed

Toggle details

Public API (additive only, no breaking change) on DailyScheduleEditState:

  • hasUnsavedChanges: the draft differs from the saved schedule (or from the default when nothing is saved).
  • hasDifferencesFromCountryDefault: same value as isDirty, under a name that says what it compares against.
  • draftWeeklyHours / savedWeeklyHours: weekly totals of the draft and of the saved schedule. They follow subtractBreaksFromWorkHours and are 0 while a time is incomplete, like the per-row hours.
  • isDirty is unchanged; only its JSDoc now says what it compares against.

Internally the existing default-comparison helper was generalised to isSameSchedule and reused for both comparisons. Break minutes are compared as numbers, so a saved "030" doesn't read as changed, but a cleared break is never equal to a saved 0.

The prebuilt edit form reads hasDifferencesFromCountryDefault. The custom example now also shows the draft and saved totals and asks for confirmation before discarding when hasUnsavedChanges is true.

Screenshots

N/A

Related Resources

Testing

Flag tests live in DailySchedule.test.tsx: saved custom schedule, editing start time and break, toggling a day, edits to an unchecked day, clearing a saved 0-minute break, close(), reset(), save() (including a break with leading zeros), and the saved vs draft weekly totals.

Removing the saved-schedule comparison makes six of the flag tests fail, computing savedWeeklyHours from the draft rows makes the weekly totals test fail, and the previous numeric-only break comparison makes the 0-minute-break test fail. I confirmed each and restored the code.

  • Tested against the example/ app in a browser
  • Feature flag: N/A

🤖 Generated with Claude Code


Note

Low Risk
Additive public API on onboarding schedule editing with clarified semantics; isDirty behavior is unchanged and covered by new tests.

Overview
Extends the headless Daily Schedule edit API so custom UIs can distinguish draft vs saved from draft vs country default, and show weekly totals without reimplementing math.

DailyScheduleEditState gains hasUnsavedChanges (closing would discard edits), hasDifferencesFromCountryDefault (same meaning as existing isDirty, now documented), plus draftWeeklyHours and savedWeeklyHours. The built-in form and example use the explicit default flag for Reset to default; the example also prompts on cancel/close when hasUnsavedChanges is true and displays draft vs saved weekly hours.

Comparison logic is generalized to isSameSchedule, with break minutes compared numerically (e.g. 030 vs 30) and edits on unchecked days ignored for unsaved detection. New tests cover these flags through edit, toggle, close(), reset(), and save().

Reviewed by Cursor Bugbot for commit 24b3c57. Bugbot is set up for automated code reviews on this repo. Configure here.

… state

Add hasUnsavedChanges (draft vs saved schedule) and
hasDifferencesFromCountryDefault (same value as isDirty, clearer name) so
custom UIs can tell whether closing would discard edits.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

📦 Bundle Size Report

Metric Current Previous Change Status
Total (gzip) 230.93 kB 230.8 kB +132 B (+0.1%) 🔴
Total (raw) 642.93 kB 642.63 kB +299 B (+0.0%) 🔴
CSS (gzip) 21.95 kB 21.95 kB 0 B (0%) 🟢
CSS (raw) 114.51 kB 114.51 kB 0 B (0%) 🟢

Size Limits

  • ✅ Total gzipped: 230.93 kB / 350 kB (66.0%)
  • ✅ Total raw: 642.93 kB / 850 kB (75.6%)
  • ✅ CSS gzipped: 21.95 kB / 25 kB (87.8%)

Largest Files (Top 5)

  1. index.esm-wIkXrqU6.js - 11.4 kB (0 B (0%))
  2. styles.css - 10.97 kB (0 B (0%))
  3. index.css - 10.97 kB (0 B (0%))
  4. internals-BOZceErx.js - 6.13 kB (0 B (0%))
  5. hooks-ThU7CDLI.js - 5.85 kB (0 B (0%))
View All Files (291 total)
File Size (gzip) Change
index.esm-wIkXrqU6.js 11.4 kB 0 B (0%)
styles.css 10.97 kB 0 B (0%)
index.css 10.97 kB 0 B (0%)
internals-BOZceErx.js 6.13 kB 0 B (0%)
hooks-ThU7CDLI.js 5.85 kB 0 B (0%)
sdk.gen-BRPiw4M1.js 5.58 kB 0 B (0%)
index.js 5.51 kB 0 B (0%)
flows/Onboarding/hooks.js 4.67 kB 0 B (0%)
utils-CUgvJHl4.js 4.07 kB 0 B (0%)
FieldSetField-D0HdSLTs.js 4.04 kB 0 B (0%)

✅ Bundle size check passed

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Deploy preview for adp-cost-calculator ready!

Project:adp-cost-calculator
Status: ✅  Deploy successful!
Preview URL:https://adp-cost-calculator-nnhi7apcq-remotecom.vercel.app
Latest Commit:24b3c57

Deployed with vercel-action

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Deploy preview for remote-flows ready!

Project:remote-flows
Status: ✅  Deploy successful!
Preview URL:https://remote-flows-mncpz2cg3-remotecom.vercel.app
Latest Commit:24b3c57

Deployed with vercel-action

…edule form and demo

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

📊 Coverage Report

✅ Coverage increased! 🎉

Metric Current Previous Change Status
Lines 89.59% 89.58% +0.01% 🟢
Statements 89.47% 89.45% +0.01% 🟢
Functions 88.49% 88.48% +0.01% 🟢
Branches 81.20% 81.21% -0.01% 🔴

Detailed Breakdown

Lines Coverage
  • Covered: 5404 / 6032
  • Coverage: 89.59%
  • Change: +0.01% (8 lines)
Statements Coverage
  • Covered: 5469 / 6113
  • Coverage: 89.47%
  • Change: +0.01% (8 statements)
Functions Coverage
  • Covered: 1430 / 1616
  • Coverage: 88.49%
  • Change: +0.01% (2 functions)
Branches Coverage
  • Covered: 3356 / 4133
  • Coverage: 81.20%
  • Change: -0.01% (6 branches)

✅ Coverage check passed

gabrielseco and others added 2 commits October 16, 2026 06:25
…ule change flags

A saved break like "030" is rebuilt as "30", so hasUnsavedChanges stayed true after saving. Move the flag tests into DailySchedule.test.tsx and cover save(), unchecked days and break edits.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ad3c132. Configure here.

gabrielseco and others added 5 commits October 16, 2026 06:34
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ule flags

An empty break was compared as 0, so clearing a saved 0-minute break left
hasUnsavedChanges and hasDifferencesFromCountryDefault false even though
the field is required and closing would restore 0.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…hedule edit state

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…tom daily schedule

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@gabrielseco
gabrielseco merged commit 91a5eb4 into main Oct 16, 2026
14 checks passed
@gabrielseco
gabrielseco deleted the feat/daily-schedule-has-unsaved-changes branch October 16, 2026 09:59
@gabrielseco gabrielseco mentioned this pull request Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants