Skip to content

WIP: Replace robot3 with local useReducer-based state machine - #2555

Draft
serikjensen wants to merge 1 commit into
mainfrom
claude/sdk-state-machine-refactor-2c4e9d
Draft

WIP: Replace robot3 with local useReducer-based state machine#2555
serikjensen wants to merge 1 commit into
mainfrom
claude/sdk-state-machine-refactor-2c4e9d

Conversation

@serikjensen

Copy link
Copy Markdown
Member

Summary

  • Replaces robot3 (v1.2.0) and react-robot (v1.2.1) with a local state machine library at src/lib/state-machine/
  • Built entirely on React's useReducer, eliminating mutable service objects and manual re-render tricks
  • Resolves machine lifecycle issues causing AMEX and BQE partner bugs (stale state, swallowed events, race conditions on machine identity changes)
  • Adds dev-mode console.warn for unhandled events (robot3 swallowed silently)
  • Zero external dependencies, ~2KB vs ~6KB for robot3 + react-robot

Test plan

  • All 3770 existing tests pass
  • TypeScript compiles with zero errors
  • Production build succeeds
  • SDK dev app loads and renders flows
  • New library unit tests: 14 core engine tests + 7 React hook tests
  • Manual QA of multi-step flows (onboarding, payroll, contractor)
  • Verify AMEX/BQE reproduction scenarios are resolved

🤖 Generated with Claude Code

…e machine

Replace the external robot3 (v1.2.0) and react-robot (v1.2.1) dependencies
with a local state machine library built on React's useReducer. This resolves
machine lifecycle issues causing partner bugs (AMEX, BQE) where robot3's
interpreter mishandled machine identity changes and silently swallowed events.

The new implementation at src/lib/state-machine/ provides the same DSL
(state, transition, guard, reduce, createMachine) with:
- useReducer as the React integration (no mutable service objects)
- Dev-mode console.warn for unhandled events (robot3 swallowed silently)
- Clean re-initialization when machine reference changes
- Zero external dependencies

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@serikjensen
serikjensen force-pushed the claude/sdk-state-machine-refactor-2c4e9d branch from bbcd200 to f2fff79 Compare August 13, 2026 15:32
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.

1 participant