statelyai / xstate-viz

Visualizer for XState machines
https://stately.ai/viz
MIT License
434 stars 102 forks source link

Feature: Custom State Title/Names (AKA keyText) overriding the unique identified in visualizer #400

Open Glavin001 opened 1 year ago

Glavin001 commented 1 year ago

See https://github.com/statelyai/xstate/discussions/1641#discussioncomment-4623313 for more context.

Use Case

I want to replace the state's title/name. Also helpful when the original state unique identified is too long (see https://github.com/statelyai/xstate-viz/issues/397 ).

image

Example:

const fetchMachine = createMachine<Context>({
  // ...
  states: {
    theRawId: {
      meta: {
        title: "The Nice Title", // Override theRawId
        description: "# Description\nAllows screenshots:\n![](https://upload.wikimedia.org/wikipedia/commons/thumb/b/bd/Web_Page.png/800px-Web_Page.png)"
      }
    },
  }
});