Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Display difficulties when splitting machine into multible files #497

Open
3flippa opened this issue Nov 12, 2024 · 5 comments
Open
Labels
bug Something isn't working

Comments

@3flippa
Copy link

3flippa commented Nov 12, 2024

XState version

XState version 5

Description

i have a very complex global state machine. to make it more readable and editable i want to split the code into multible files, import the independet parts and init the machine.
when i have all parts in one big file it works fine and the xstate extension can easyly show me what my statechart looks like but when i put the parts in different files and import them it just shows me an empty box.

ps: i dont want to invoke or spwan actors to split the machine. i already tried this and because context between actors is isolated this does not work for me.

ps: im using xstate with react

basic example:

export const authenticationStates = {
	initial: 'unauthenticated',
	states: {
		unauthenticated: {
			on: { REGISTER_USER: 'authenticated' }
		},
		authenticated: {
			on: { LOGOUT_USER: 'unauthenticated' }
		}
	}
};
setup({
	types: {
		events: {} as authEvents,
		context: {} as {
			auth: authenticationContextType;
		}
	}
}).createMachine({
	id: 'global',
	type: 'parallel',
	context: { auth: authenticationContext },
	states: {
		auth: authenticationStates
	}
});

Expected result

image

Actual result

image

Reproduction

i dont think that is nessesary in this case. if needed i submit later

Additional context

i cannot tell yet but i think it still works but the xstate extenstion defently has problems to display the statechart

@3flippa 3flippa added the bug Something isn't working label Nov 12, 2024
@davidkpiano davidkpiano transferred this issue from statelyai/xstate Nov 12, 2024
@davidkpiano
Copy link
Member

davidkpiano commented Nov 19, 2024

The VSCode extension does not currently support state machines spread out in multiple files.

@3flippa 3flippa changed the title Bug: Display difficulties when Bug: Display difficulties when splitting machine into multible files Nov 28, 2024
@3flippa
Copy link
Author

3flippa commented Nov 28, 2024

ok i can now surely say that the state machine is still working. its just not displayed by xstate tooling

@vamsi-lz
Copy link

Is there a plan to add it anytime?

@davidkpiano
Copy link
Member

Is there a plan to add it anytime?

Not with the current tooling, which works via static analysis of the AST, and it gets much more complicated if the machine definition is spread out in multiple files.

The recommended way moving forward is to use Stately Inspect to visualize machines in real-time without having to parse the AST. Much more future-proof and avoids the issue of having to predict the many, many different ways machines can be authored (partial definitions, across files, dynamic keys, etc. etc.)

@3flippa
Copy link
Author

3flippa commented Dec 18, 2024

i tryed to use inspect but because i use react native i got this problem

partykit/partykit#516

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants