From harness-claude
Models concurrent, independent state regions active simultaneously in XState machines. Use for UIs with orthogonal concerns like bold/italic toggles or parallel processes like upload/validation.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Model concurrent, independent state regions that are active simultaneously within a single machine
Spawn and manage XState child actors for independent concurrent state machines communicating via message passing. Use for dynamic collections like file uploads, chat rooms, or player sessions.
Builds, tests, and debugs event-driven state machines with EventMachine Laravel package for declarative workflows, parallel states, child delegation, event sourcing, timers, and HTTP endpoints.
Models complex UI flows as finite state machines with states, events, transitions, actions, and guards. Useful for forms, data fetching, authentication flows, and wizards.
Share bugs, ideas, or general feedback.
Model concurrent, independent state regions that are active simultaneously within a single machine
type: 'parallel' on the parent state node. All direct child states become active simultaneously.initial property — all children start in their own initial states simultaneously.onDone on the parallel parent to react when ALL child regions reach their final states.// text-editor.machine.ts
import { createMachine } from 'xstate';
const textEditorMachine = createMachine({
id: 'editor',
type: 'parallel',
states: {
bold: {
initial: 'off',
states: {
off: { on: { TOGGLE_BOLD: 'on' } },
on: { on: { TOGGLE_BOLD: 'off' } },
},
},
italic: {
initial: 'off',
states: {
off: { on: { TOGGLE_ITALIC: 'on' } },
on: { on: { TOGGLE_ITALIC: 'off' } },
},
},
underline: {
initial: 'off',
states: {
off: { on: { TOGGLE_UNDERLINE: 'on' } },
on: { on: { TOGGLE_UNDERLINE: 'off' } },
},
},
},
});
// State value when bold is on, italic off, underline on:
// { bold: 'on', italic: 'off', underline: 'on' }
// Multi-step upload with parallel validation
const uploadMachine = createMachine({
id: 'upload',
initial: 'preparing',
states: {
preparing: {
on: { START: 'processing' },
},
processing: {
type: 'parallel',
states: {
upload: {
initial: 'uploading',
states: {
uploading: {
invoke: { src: 'uploadFile', onDone: 'done', onError: 'error' },
},
done: { type: 'final' },
error: {},
},
},
validation: {
initial: 'validating',
states: {
validating: {
invoke: { src: 'validateFile', onDone: 'done', onError: 'error' },
},
done: { type: 'final' },
error: {},
},
},
},
// Fires when BOTH upload and validation reach 'done'
onDone: 'complete',
},
complete: { type: 'final' },
},
});
State values: For parallel states, state.value is an object where each key is a region name and each value is that region's current state. For nested parallels, values nest further.
Event handling: When an event is received, it is processed by ALL active regions. If both bold and italic handle RESET, both will transition. Be intentional about event naming to avoid unintended cross-region effects.
onDone completion: A parallel state's onDone fires only when every child region has reached a final state. If any region stays active, the parallel state stays active.
Without parallel states (combinatorial explosion): Modeling bold + italic + underline without parallel states would require 8 atomic states (off-off-off, on-off-off, ...). With parallel states, you need 6 (2 per region). This scales linearly instead of exponentially.
Transitions between regions: A region can target another region's state via a full ID path, but this is generally a code smell. If regions need tight coordination, they may not be truly parallel — consider a compound state instead.
Testing parallel machines: Check state.value as an object: expect(state.value).toEqual({ bold: 'on', italic: 'off' }).
https://stately.ai/docs/parallel-states