Skip to content

fix(SDK-1211): freeze PaySchedule's initial routing decision - #2703

Merged
mariechatfield merged 1 commit into
mainfrom
fix/marie/SDK-1211-pay-schedule-state-machine
Sep 4, 2026
Merged

fix(SDK-1211): freeze PaySchedule's initial routing decision#2703
mariechatfield merged 1 commit into
mainfrom
fix/marie/SDK-1211-pay-schedule-state-machine

Conversation

@mariechatfield

Copy link
Copy Markdown
Contributor

Summary

  • PaySchedule.tsx recomputed initialState/initialComponent from live query data every render, so the moment the first schedule is created and the query refetches, the machine gets a new reference mid-session.
  • robot-hooks' useMachine treats any machine-reference change as a full reset, and the reset permanently orphans the interpreter — every click after that point (Edit, Add another, etc.) becomes a silent no-op.
  • Freeze the routing decision on mount instead, matching the pattern already used in Compensation.tsx.

Test plan

  • Added a regression test (remains interactive after creating the first schedule) that starts with zero schedules, creates one, and confirms Edit still works afterward. Fails on main, passes with this fix.
  • npm run test -- --run src/components/Company/PaySchedule/PaySchedule.test.tsx — 28/28 passing
  • npm run test -- --run src/components/Company src/components/Flow — 224/224 passing, no regressions
  • npx tsc --noEmit / npx eslint clean on changed files

🤖 Generated with Claude Code

Recomputing initialState/initialComponent from live query data on every
render mints a new machine reference the moment the first schedule is
created, which causes robot-hooks to reset and permanently orphan the
interpreter — every click after that point becomes a silent no-op.
Freeze the decision on mount instead, matching the pattern already used
in Compensation.tsx.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
defaultValues,
}),
),
[companyId, defaultValues, initialState, initialComponent],

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The dependencies already existed, but before they were on values that would change at render after the first schedule was created -- and that would break the state machine

However, due to some funk with StrictMode, this sometimes locally appeared to work while it always appeared broken in production, or with strict mode off 🤷🏻

@mariechatfield
mariechatfield marked this pull request as ready for review September 3, 2026 23:26
@mariechatfield
mariechatfield requested a review from a team as a code owner September 3, 2026 23:26
@wiz-gusto-organization

wiz-gusto-organization Bot commented Sep 4, 2026

Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings -
Software Management Finding Software Management Findings -
Total -

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try the Wiz Code extension for VS Code, JetBrains, or Visual Studio.

@dmortal dmortal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@mariechatfield
mariechatfield added this pull request to the merge queue Sep 4, 2026
Merged via the queue into main with commit 2312267 Sep 4, 2026
42 checks passed
@mariechatfield
mariechatfield deleted the fix/marie/SDK-1211-pay-schedule-state-machine branch September 4, 2026 17:04
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