instance_id
stringlengths
10
65
repo
stringlengths
5
59
pr_number
int64
1
313k
task_type
stringclasses
1 value
base_commit
stringlengths
40
40
review_commit
stringlengths
40
40
title
stringlengths
2
282
body
stringlengths
7
3k
patch
stringlengths
202
204k
n_defects
int64
1
72
n_supported
int64
1
65
n_major
int64
0
32
defects
stringlengths
140
18.8k
certifier_count
int64
statechannels__go-nitro__1593
statechannels/go-nitro
1,593
defect
59ecd6abec431b4fdf1da951439fc1bbacf674c6
b4b7467c80f0f6f8354d68fff252b4a99a308ba4
`Channel` class: store `stateHash`, `candidate` signed state and `Outcome` following `ChallengeRegistered`
https://docs.statechannels.org/protocol-tutorial/0080-defunding-a-channel/#tracking-on-chain-storage This should be sufficient to allow us to call `transfer` at some later stage. It should also trigger an appropriate notification for the client (same behaviour as receiving the state off chain). Towards #1531...
diff --git a/channel/channel.go b/channel/channel.go index 45aee2180b..1e0bdd0e34 100644 --- a/channel/channel.go +++ b/channel/channel.go @@ -335,7 +335,13 @@ func (c *Channel) UpdateWithChainEvent(event chainservice.Event) (*Channel, erro c.OnChain.Holdings[e.Asset] = e.NowHeld case chainservice.ConcludedEvent: ...
5
4
2
[{"id": "G0", "claim": "The ChallengeRegistered case should probably also construct the candidate state/signature and add it to the channel, as if it were a regular off-chain channel update message.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The...
null
statechannels__go-nitro__1603
statechannels/go-nitro
1,603
defect
3dfba12952845bf0c0659f61581acd14d69a5b81
983dd920769c10b4433d2d78ecdb39312ec75142
Add authentication tokens
This PR adds authentication tokens for the JSON RPC api. Every API method either requires no authentication token or an authentication token with correct permissions. If the direction of this work makes sense, the follow up work is: - [ ] Do not store the token signing key in code. - [x] Wire up tokens in the Types...
diff --git a/go.mod b/go.mod index c9f4513e17..2e91a2c1a2 100644 --- a/go.mod +++ b/go.mod @@ -13,6 +13,7 @@ require ( require ( github.com/BurntSushi/toml v1.3.2 + github.com/golang-jwt/jwt/v5 v5.0.0 github.com/libp2p/go-libp2p-kad-dht v0.24.2 github.com/tidwall/buntdb v1.2.10 github.com/urfave/cli/v2 v2.25...
10
8
0
[{"id": "G0", "claim": "The godoc on generateAuthToken's second line is mismatched (\"verifyPermission ...\" describes a different function than the one below it).", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "checkTokenValidity should return an ...
null
statechannels__go-nitro__1609
statechannels/go-nitro
1,609
defect
b94617abd283b8f9e3d58e34b8652de332802266
01fffc9f73f3dde8f2e76fb5c3cdb6a723d81f7c
Check for missed events when `chainservice` initializes
The `chainservice` should check for any `chainEvents` that occurred since the last time it was online. This will allow us to restart a nitro node without risk of the node's state getting permanently out-of-sync with the on-chain state.
diff --git a/internal/chain/chain.go b/internal/chain/chain.go index 7329c62c9..d4ab8b331 100644 --- a/internal/chain/chain.go +++ b/internal/chain/chain.go @@ -7,11 +7,10 @@ import ( "os/exec" "time" - b "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "...
2
1
1
[{"id": "G1", "claim": "Blocks (or events) mined while checkForMissedEvents executes, before listenForEventLogs starts, could be ignored; the reviewer asks to start listening for events before calling checkForMissedEvents to be safe.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": "intro...
null
statechannels__go-nitro__1619
statechannels/go-nitro
1,619
defect
6975df2d91f6f2c0b5a68ea75982d567a3c47e1a
72f0a718e99b775493663b209fc4ff0b2c59bfdd
Enhance simulated backend chain service test to cover detecting `ChallengeRegistered` events
Closes #1618
diff --git a/node/engine/chainservice/adjudicator/convert_signature.go b/node/engine/chainservice/adjudicator/convert_signature.go deleted file mode 100644 index e2851f9e8f..0000000000 --- a/node/engine/chainservice/adjudicator/convert_signature.go +++ /dev/null @@ -1,21 +0,0 @@ -package NitroAdjudicator - -import "git...
4
4
0
[{"id": "G0", "claim": "Add a comment to eth_chainservice.go explaining why challengeRegisteredTopic is a hard-coded hex hash (since #1592).", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "Rename the generic `expectedEvent` variables in the simulat...
null
statechannels__go-nitro__1651
statechannels/go-nitro
1,651
defect
757eb06d7cdae29c2ebb357664b2dd93d6adbaa7
aed76d880b73b81c2e16ee291cdeec8c2c6a210b
Fix `GetLastConfirmedBlockNum` test failures
* Add informative log for `chainstartblock` work-around when `chainservice` init fails * Add mutex (and use in tests) for `MockChain.BlockNum` to fix `GetLastConfirmedBlockNum` test failures
diff --git a/internal/node/node.go b/internal/node/node.go index dba7b06a2b..11a8a45bd5 100644 --- a/internal/node/node.go +++ b/internal/node/node.go @@ -41,7 +41,7 @@ func InitializeNode(pkString string, chainOpts chain.ChainOpts, chainOpts.ChainStartBlock = storeBlockNum } - slog.Info("Initializing chain serv...
2
2
0
[{"id": "G0", "claim": "The test reaching into the chain and manipulating the mutex directly is a code smell showing the abstraction is broken.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "txMutex may be unnecessary in SubmitTransaction since BlockNumM...
null
statechannels__go-nitro__1652
statechannels/go-nitro
1,652
defect
3dc13590424864a16e3b58a28a30ec275085335f
fffd80c81931ffb23d369e965ef06b23474e9327
Introduce health endpoint to the HTTP server
Use the health endpoint for initializing HttpTransportAsServer. This is work is needed for introducing TLS. With TLS the HTTP RPC server takes longer to initialize. As a result, rpc clients can start to send requests to the server before the server is ready. In theory, even without adding TLS, `node_test` tests can ...
diff --git a/internal/rpc/rpc.go b/internal/rpc/rpc.go index bf140a3479..37b31ffe86 100644 --- a/internal/rpc/rpc.go +++ b/internal/rpc/rpc.go @@ -3,11 +3,13 @@ package rpc import ( "fmt" "log/slog" + "net/http" + "time" "github.com/statechannels/go-nitro/node" "github.com/statechannels/go-nitro/rpc" "gith...
2
2
1
[{"id": "G0", "claim": "It is smelly for the RPC server to send GET requests to itself to decide when part of it is ready; the blockUntilReady helper would more naturally be used by an RPC Client.", "category": "design", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The readin...
null
statechannels__go-nitro__1659
statechannels/go-nitro
1,659
defect
3dc13590424864a16e3b58a28a30ec275085335f
18547ac312e7a4ce0c557aa796fb195fd6981530
Channel class rejects old chain event updates
The `Channel` class should prevent chain events from making updates to the `Channel` if the event is older than the last event that updated the `Channel`. Reference: https://github.com/statechannels/go-nitro/pull/1624
diff --git a/channel/channel.go b/channel/channel.go index d5b1749c8..26bb1b825 100644 --- a/channel/channel.go +++ b/channel/channel.go @@ -32,10 +32,17 @@ type Channel struct { OnChain OnChainData OffChain OffChainData + + LastChainUpdate ChainUpdateData +} + +type ChainUpdateData struct { + BlockNum uint64 + ...
2
2
0
[{"id": "G0", "claim": "The constructor should be named `New` rather than `NewChannel`, since the package name already qualifies calls as `channel.New()`, and such renames belong in a separate tightly-scoped PR.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "clai...
null
statechannels__go-nitro__1683
statechannels/go-nitro
1,683
defect
be822fa8b672094f93e4213d41cf603d5f60f487
d3c69347a0083ec20aa5825e22adef6609997b08
Add TLS to HTTP transport
This PR adds TLS to websocket and http messaging between RPC client and server. TLS is needed in order to secure auth tokens. With this PR, rpc test will pass only if a valid certificate and private key exist in the `tls` directory and are signed by a valid or local certificate authority. These details have been added ...
diff --git a/internal/tls/readme.md b/internal/tls/readme.md new file mode 100644 index 000000000..8def32ba9 --- /dev/null +++ b/internal/tls/readme.md @@ -0,0 +1,7 @@ +# TLS + +This directory contains a TLS private key and self signed certificate. These are used for testing purposes only. To generate another self sign...
2
1
1
[{"id": "G0", "claim": "A private key and self-signed certificate for statechannels.org are checked into the repository, which is questionable even for testing purposes.", "category": "security", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The RPC client always uses https/ws...
null
statechannels__go-nitro__1747
statechannels/go-nitro
1,747
defect
93de7db25c62ff872378347330e14034ee906db3
0f76e7e1927810792d6c918ab43359ea2f0f235e
Cleanup/refactor node code
A few areas of cleanup: 1. Make the `Sent message` log after the message is successfully sent 2. Use `messageOpts` and `storeOpts` when initializing those services. This means we pass a single struct as an input to `NewStore` and `NewMessageService` instead of many individual arguments. This work aligns `messageser...
diff --git a/internal/chain/chain.go b/internal/chain/chain.go index 1f093df67..67ade6504 100644 --- a/internal/chain/chain.go +++ b/internal/chain/chain.go @@ -18,16 +18,6 @@ import ( "github.com/statechannels/go-nitro/types" ) -type ChainOpts struct { - ChainUrl string - ChainStartBlock uint64 - ChainAuth...
1
1
0
[{"id": "G0", "claim": "In executeNRpcTest, the PR adds a commented-out duplicate `PrivateKey: common.Hex2Bytes(sk)` line in the actor struct that should be removed.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}]
null
statechannels__go-nitro__1783
statechannels/go-nitro
1,783
defect
e572762d59f4e4e06ee802542550d25e59d1e4c6
1e774ee4fb001dc91c5e1341ddd738edeb4ab697
Various small tweaks
Closes #1761
diff --git a/node_test/paymentproxy_test.go b/node_test/paymentproxy_test.go index 6b472fe66..0d7154858 100644 --- a/node_test/paymentproxy_test.go +++ b/node_test/paymentproxy_test.go @@ -185,7 +185,7 @@ func createVoucher(t *testing.T, client rpc.RpcClientApi, channelId types.Destin } func expectedPaymentErrorMes...
6
3
0
[{"id": "G0", "claim": "Ideally the payment proxy would not hardcode the units into its error message; maybe it could return a JSON error that the client could parse out.", "category": "design", "verdict": "uncertain", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The Pay & Download button is taking ...
null
statechannels__go-nitro__681
statechannels/go-nitro
681
defect
612c9acbb3cc049b6f5d3a8868c9c211114f1633
d6cbca5bbca123509aef34feca20fe6ccf33509a
Create basic TCP message service
This PR implements a basic message service that works over TCP. The main motivation is allowing us to set up test scenarios that can have client's running in different processes/machines that can communicate with each-other. Currently this message service assumes that the address of all other messages services will...
diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 2721a25b9e..f3a155f6ce 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -24,7 +24,7 @@ jobs: - name: Test timeout-minutes: 1 - run: go test -v ./... -count=2 -shuffle=on + run: go test -v ./... ...
2
1
1
[{"id": "G0", "claim": "The service is constantly reading empty messages, so this pull request should go back to draft until fixed.", "category": "correctness", "verdict": "supported", "priority": "P0", "scope": "introduced"}, {"id": "G3", "claim": "The struct field comments should be moved above their fields, as sugge...
null
statechannels__go-nitro__737
statechannels/go-nitro
737
defect
ea2bb32b1397571d0a2815164c54c015883c6844
bbc1968c1856e12fa52ea1212ef984041a06fdb4
EthChainService adheres to ChainService interface
In this PR: - `EthChainService` interface is modified to adhere to the `ChainService` interface from https://github.com/statechannels/go-nitro/pull/733. - Common logic between `EthChainService` and `MockChain` is factored out.
diff --git a/client/engine/chainservice/chainservice.go b/client/engine/chainservice/chainservice.go index c5427ee7b4..360797a030 100644 --- a/client/engine/chainservice/chainservice.go +++ b/client/engine/chainservice/chainservice.go @@ -2,6 +2,9 @@ package chainservice // import "github.com/statechannels/go-nitro/cl...
1
1
0
[{"id": "G0", "claim": "Add godoc comments to the newly added ChainServiceBase code (e.g. the NewChainServiceBase constructor).", "category": "documentation", "verdict": "supported", "priority": "P3", "scope": "introduced"}]
null
statechannels__go-nitro__783
statechannels/go-nitro
783
defect
a7b7ed64f62cfb91a466cc0f305239ebf2721781
0f98dfba4d300ac1783625540af813f7176bd028
Clean up chainservice events
This PR: - Introduces `asset` struct for the address + amount field pair. - Uses the struct in Deposited and AllocationUpdated events. - Converts exported `CommonEvent` struct to a unexported `commonEvent` - Converts exported `ChainServiceBase` struct to unexported `chainServiceBase`
diff --git a/client/engine/chainservice/chainservice.go b/client/engine/chainservice/chainservice.go index 52f382d94..ac202a81b 100644 --- a/client/engine/chainservice/chainservice.go +++ b/client/engine/chainservice/chainservice.go @@ -16,35 +16,46 @@ type Event interface { ChannelID() types.Destination } -// Com...
2
2
0
[{"id": "G0", "claim": "The CommonEvent struct (exported) should be made unexported, consistent with the pull request's move toward unexported event internals.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "pre_existing"}, {"id": "G2", "claim": "The new bundled asset struct is misnamed (ass...
null
statechannels__go-nitro__788
statechannels/go-nitro
788
defect
a7b7ed64f62cfb91a466cc0f305239ebf2721781
e0529f313148fa34e17b88621c7219c5e2bb1942
Remove panics from ChainService
Fixes https://github.com/statechannels/go-nitro/issues/770. One option is to allow a state channel wallet to continue to operate even if its chain service fails. This allows the wallet to continue to run application channels. This PR enables this mode of operation and includes the following changes: - Calls to the ...
diff --git a/client/engine/chainservice/chainservice.go b/client/engine/chainservice/chainservice.go index 52f382d94..95ee0e938 100644 --- a/client/engine/chainservice/chainservice.go +++ b/client/engine/chainservice/chainservice.go @@ -16,35 +16,46 @@ type Event interface { ChannelID() types.Destination } -// Com...
3
3
0
[{"id": "G0", "claim": "EthChainService's SendTransaction previously returned []*ethTypes.Transaction while the ChainService interface declared no return value, and this mismatch was not a type error only because EthChainService was never used where a ChainService is required.", "category": "design", "verdict": "suppor...
null
statechannels__go-nitro__798
statechannels/go-nitro
798
defect
91dfba76fe250cf7d7e8bea92c6f17ed4d49a6c2
b972610817dafa3810a3a2db416fe6d35ca43ee0
Remove SubscribeToEvents from the ChainService interface
Part of the work needed for https://github.com/statechannels/go-nitro/issues/790. An implementation of the `ChainService` interface is used by the engine to submit transactions to a chain and receive events from the chain. Previously, the `ChainService` included a subscription API to accommodate multiple engines ...
diff --git a/client/engine/chainservice/chainservice.go b/client/engine/chainservice/chainservice.go index a92c5fc9a..343ca78d2 100644 --- a/client/engine/chainservice/chainservice.go +++ b/client/engine/chainservice/chainservice.go @@ -2,11 +2,9 @@ package chainservice // import "github.com/statechannels/go-nitro/cli...
3
2
0
[{"id": "G0", "claim": "Rename the `address` loop variable in the deposit case of MockChainImpl.SubmitTransaction to `assetAddress`, since it is a token address and the current name is unhelpful.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "It...
null
statechannels__go-nitro__844
statechannels/go-nitro
844
defect
81a1fcb2fb0e7fc48f95b38dddda251ff9fcac4d
da7554554e5c5190fde47d178a09ada3249678db
Voucher Manager refactor
Fixes #837 Refactors the `PaymentManager` and `ReceiptManager` into one `VoucherManager`. This simplifies how the engine deals with voucher management as it no longer has to keep track of senders/receivers. I decided to [completely remove the manager interface](https://github.com/statechannels/go-nitro/pull/...
diff --git a/client/engine/engine.go b/client/engine/engine.go index 40ea9cda5a..04958b63ae 100644 --- a/client/engine/engine.go +++ b/client/engine/engine.go @@ -53,8 +53,7 @@ type Engine struct { metrics *MetricsRecorder - pm payments.PaymentManager - rm payments.ReceiptManager + vm *payments.VoucherManager } ...
6
5
1
[{"id": "G0", "claim": "The naming should prefer payer/payee over sender/receiver in the voucher manager.", "category": "maintainability", "verdict": "supported", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "The Register doc comment needs updating to reflect the inclusion of the receiver in the argu...
null
statechannels__go-nitro__881
statechannels/go-nitro
881
defect
1cb1038732116672260fce955dc9aca5720f1120
a5fc96b0aebb2c58f9f1659c44fdda9c42e69802
Make the `client` responsible for nonce management
(Recommend commit-by-commit review) This is a significant change to the `go-nitro` client APi. It is no longer necessary / possible to provide an `AppDefinition`, `AppData` or `Nonce` for a channel. `AppDefinition` -- this is set to the deployed contract address for ledger channels, and shortly something sim...
diff --git a/client/client.go b/client/client.go index 65871202a..df5c61158 100644 --- a/client/client.go +++ b/client/client.go @@ -4,6 +4,7 @@ package client // import "github.com/statechannels/go-nitro/client" import ( "io" "math/big" + "math/rand" "github.com/statechannels/go-nitro/client/engine" "github...
2
2
0
[{"id": "G0", "claim": "Maybe ObjectiveRequestForVirtualPaymentApp (and other structs exposed by the API) should live in the client package instead of virtualfund, or the API could accept parameters instead of a request struct.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"...
null
statechannels__go-nitro__932
statechannels/go-nitro
932
defect
ab7b1a648d10c8a745d502006f893f166cdec92a
f32aca95371fd734a0670a13bc5a944315d246aa
Test the n-hop virtual fund
Towards #904 This PR - modifies `vitualfund_test.go` to create 0, 1, and 2 hop virtually funded channels - modifies `virtualfund.NewObjective()` to allow 0-hop funding (ie, persons with a ledger channel can use that channel to fund a virtual channel between them) --- #### Code quality - [x] I have writ...
diff --git a/client_test/virtualfund_test.go b/client_test/virtualfund_test.go index f85d46bbc..92a3d3ff0 100644 --- a/client_test/virtualfund_test.go +++ b/client_test/virtualfund_test.go @@ -47,11 +47,66 @@ func TestVirtualFundIntegration(t *testing.T) { chainServiceA := chainservice.NewMockChainService(chain, alic...
6
1
0
[{"id": "G0", "claim": "It is questioned whether a 0-hop virtual channel makes sense at all and whether it would be funded by a single guarantee in that case.", "category": "design", "verdict": "opposed", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The PR leaves two awkwardly different ways of doin...
null
statelyai__xstate-tools__129
statelyai/xstate-tools
129
defect
58628f182faeace8e61c995172995f98c9d623af
4c72f86b2af3859534949b13926a2b0aa2033c58
Fixed a bug where children of states entered from transitions would not have their entry actions or invocations typed properly
Fixes #124
diff --git a/.changeset/tame-humans-breathe.md b/.changeset/tame-humans-breathe.md new file mode 100644 index 00000000..08d5acc4 --- /dev/null +++ b/.changeset/tame-humans-breathe.md @@ -0,0 +1,7 @@ +--- +"@xstate/tools-shared": patch +"stately-vscode": patch +"@xstate/cli": patch +--- + +Fixed a bug where children of ...
3
2
1
[{"id": "G0", "claim": "Everything related to the GO_STRING/GO_NUMBER transitions in parallel.ts is redundant and makes analyzing the intent of the test harder, so it should be dropped.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The pull req...
null
statelyai__xstate-tools__405
statelyai/xstate-tools
405
defect
141d41f1c92ab95e762955147dbc5bb86ecd11a3
27ba80032216713cc6500c8cb18c53c7d8875c83
Machine options and support v5 `guard` and `actors`
- Support both `actors` and `guards` in machine implementations and if both are present, merges them into a single object - Support v5 `guard` keyword for transition conditions and choose action conditions. If both `cond` and `guard` are present on a transaction, picks `guard`.
diff --git a/.changeset/fair-steaks-kneel.md b/.changeset/fair-steaks-kneel.md new file mode 100644 index 00000000..eef17466 --- /dev/null +++ b/.changeset/fair-steaks-kneel.md @@ -0,0 +1,5 @@ +--- +'@xstate/machine-extractor': minor +--- + +Include machine options (implementations only) in extracted config diff --git ...
4
4
2
[{"id": "G0", "claim": "The new test uses it.only, which would skip every other test in the suite when run.", "category": "testing", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The eagerly computed options on every FileExtractResult seem unnecessary; specific options should ...
null
statelyai__xstate__1183
statelyai/xstate
1,183
defect
f685e674ac9d57f832df3f932af7de848f1e0d7f
dbc6a161c068a3e12dd12452b68a66fe3f4fb8eb
Ensure actions are executed from a restored initial state.
The issue was that when restoring from an initial state, `state.actions` weren't being resolved against the specified `machine.options.actions` action mapping, so actions weren't being executed. Fixes #1174
diff --git a/.changeset/wet-swans-deny.md b/.changeset/wet-swans-deny.md new file mode 100644 index 0000000000..5c7da98345 --- /dev/null +++ b/.changeset/wet-swans-deny.md @@ -0,0 +1,5 @@ +--- +'xstate': minor +--- + +Actions from a restored state provided as a custom initial state to `interpret(machine).start(initialS...
2
1
0
[{"id": "G0", "claim": "The test name should not say 'initial state' but rather 'restored' or 'rehydrated', since 'initial state' is already used elsewhere in the interpreter with a different meaning.", "category": "maintainability", "verdict": "supported", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim"...
null
statelyai__xstate__1189
statelyai/xstate
1,189
defect
560e28fbb208967d29be0244fe507a021c73f242
a1f1239e20e05e338ed994d031e7ef6f2f09ad68
Fix resolution to never for state.matches(...)
Closes #947
diff --git a/.changeset/seven-gorillas-melt.md b/.changeset/seven-gorillas-melt.md new file mode 100644 index 0000000000..cd27aedc68 --- /dev/null +++ b/.changeset/seven-gorillas-melt.md @@ -0,0 +1,5 @@ +--- +'xstate': minor +--- + +Previously, `state.matches(...)` was problematic because it was casting `state` to `nev...
1
1
1
[{"id": "G0", "claim": "The new `matches` return type makes `.context` resolve to `any` instead of preserving TContext after a `state.matches(...)` narrowing, a regression from the previous signature.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": "introduced"}]
null
statelyai__xstate__1239
statelyai/xstate
1,239
defect
97a2ee60ac995b562d0feca4398a9823b4b8690b
460e8315ebdc42a275725a9d66b1bd1515bc0e50
[@xstate/react] Fix service double initialization in React strict mode.
Fixes #1237 I was able to juggle some things around `useMachine` and get this to work. The only difference (which shouldn't affect apps) is that the first `[state, ...]` that comes from `useMachine(...)` comes from the non-interpreted created `machine`, _not_ the created `service` (but the `service` uses that `mach...
diff --git a/packages/core/src/Actor.ts b/packages/core/src/Actor.ts index 5129d19135..e5cc41907d 100644 --- a/packages/core/src/Actor.ts +++ b/packages/core/src/Actor.ts @@ -4,6 +4,8 @@ import { InvokeDefinition, AnyEventObject } from './types'; +import { StateMachine } from '.'; +import { isMachine } from './u...
17
10
4
[{"id": "G0", "claim": "Postponing service.start() until after the first render creates serious usability issues for invoked/spawned machines in the initial state passed to child components (they are not accessible right away) and creates a problem with effects' execution order between child and parent, which may requi...
null
statelyai__xstate__1290
statelyai/xstate
1,290
defect
61c9a57e37694e466b9521bad9238ca9bcc6449a
5838394680da755888bcd4992ed76718a46e55b7
Ensure that prematurely spawned actors are also deferred. Fixes #1281
This fixes #1281 by essentially adding `.deferred` to spawned actors, and making them behave like prematurely invoked actors would behave.
diff --git a/packages/core/src/Actor.ts b/packages/core/src/Actor.ts index e5cc41907d..50dd908a90 100644 --- a/packages/core/src/Actor.ts +++ b/packages/core/src/Actor.ts @@ -2,9 +2,10 @@ import { EventObject, Subscribable, InvokeDefinition, - AnyEventObject + AnyEventObject, + StateMachine, + Spawnable }...
3
2
1
[{"id": "G0", "claim": "The @xstate/react version should not be bumped in this PR; versions should only be bumped when actually releasing, and the merge may have lost git history for rc.5.", "category": "correctness", "verdict": "uncertain", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The spawner w...
null
statelyai__xstate__1336
statelyai/xstate
1,336
defect
11dba3e971c6f9303647f1920b96423f914f18e6
9ecefca84bfc3db6df09c41b884ac00ef0f6efb1
[@xstate/react] Rehydration should initialize machine first. Fixes #1334
This PR fixes #1334 (in a workaround-ish way) by always reading the `machine.initialState` first, which will trigger `machine._init()` to properly initialize all transitions, which includes resolving delayed transitions. The real fix for this is to do the transition resolution eagerly in the machine's constructor af...
diff --git a/packages/core/src/StateNode.ts b/packages/core/src/StateNode.ts index d9304beab8..24928c2bca 100644 --- a/packages/core/src/StateNode.ts +++ b/packages/core/src/StateNode.ts @@ -425,6 +425,12 @@ class StateNode< .concat(this.invoke) .map((activity) => toActivityDefinition(activity)); thi...
3
2
0
[{"id": "G0", "claim": "Without eager transition resolution, the machine will not throw an error when a transition targets '#green' from a non-child state ('red'), although the author says it should throw.", "category": "correctness", "verdict": "uncertain", "priority": "P1", "scope": "pre_existing"}, {"id": "G1", "cla...
null
statelyai__xstate__1504
statelyai/xstate
1,504
defect
37d5ed8606833f900a87f2a7de8f3f5059cf4deb
72b0880e6444ae009adca72088872bb5c0760ce3
Fixed issue with `useService` returning an initial state for services in their final states
fixes #1503
diff --git a/.changeset/poor-flowers-end.md b/.changeset/poor-flowers-end.md new file mode 100644 index 0000000000..402d6295d8 --- /dev/null +++ b/.changeset/poor-flowers-end.md @@ -0,0 +1,5 @@ +--- +'xstate': patch +--- + +Changed `_status` property on the `Interpreter` to be a public one. diff --git a/.changeset/thin...
2
2
0
[{"id": "G0", "claim": "The Interpreter's `_status` property, which this pull request made public, should instead be named `status`.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "useService.ts should probably import `InterpreterStatus` instead of compar...
null
statelyai__xstate__1566
statelyai/xstate
1,566
defect
d21326b3dcb498ee5c181e201da35b16e2af84c0
602687c235c56cca552c2d5a9d78adf224f522d8
Ensure exit actions are called for finalized invoked machines. Fixes #1109
This PR fixes #1109 by executing exit actions when an invoked machine reaches its final state.
diff --git a/.changeset/chatty-wombats-worry.md b/.changeset/chatty-wombats-worry.md new file mode 100644 index 0000000000..3ae2cac96c --- /dev/null +++ b/.changeset/chatty-wombats-worry.md @@ -0,0 +1,5 @@ +--- +'xstate': patch +--- + +Exit actions will now be properly called when an invoked machine reaches its final s...
3
2
1
[{"id": "G0", "claim": "The changeset entry should link the referenced issue as a markdown link ([#1109](https://github.com/davidkpiano/xstate/issues/1109)) instead of the bare #1109 shorthand.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "An add...
null
statelyai__xstate__1699
statelyai/xstate
1,699
defect
79492479cbc84fa76fe167a4c5a416ef3241f172
ccb83fa634f9d6adcdb95b64f01b93b0f33f01b8
[@xstate/inspect] Handle circular references gracefully in inspector.
This PR fixes stringifying circular reference in `@xstate/inspect` by using [fast-safe-stringify](https://www.npmjs.com/package/fast-safe-stringify) when normal `JSON.stringify(...)` throws. Currently, this will result in the string `"[Circular]"` in the inspect UI, which is much better than completely failing (prev...
diff --git a/jest.config.js b/jest.config.js index e96c6dddfe..63c5dc3c37 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,5 +1,5 @@ module.exports = { - projects: ['<rootDir>/packages/!(xstate-dev|xstate-inspect)'], + projects: ['<rootDir>/packages/!(xstate-dev)'], watchPlugins: [ 'jest-watch-typeahea...
6
2
0
[{"id": "G0", "claim": "Add an assertion that devTools.register(service) does not throw, so the circular-structure handling is asserted rather than only exercised.", "category": "testing", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The mid-test devTools.onRegister(() => don...
null
statelyai__xstate__1710
statelyai/xstate
1,710
defect
a5e4e78c06ddfcaf547c1e84b7df875e93c59288
4194ffe84cfe7910e2c183701e36bc5cac5c9bcc
Do not crash when stopping already stopped interpreter.
Fixes #1697
diff --git a/.changeset/clean-walls-breathe.md b/.changeset/clean-walls-breathe.md new file mode 100644 index 0000000000..33523f75b4 --- /dev/null +++ b/.changeset/clean-walls-breathe.md @@ -0,0 +1,5 @@ +--- +'xstate': patch +--- + +Stopping an already stopped interpreter will no longer crash. See #1697 for details. di...
2
1
0
[{"id": "G0", "claim": "The changeset's plain '#1697' reference should be a proper markdown link to the issue (https://github.com/davidkpiano/xstate/issues/1697).", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "Andarist asks whether stopping an alr...
null
statelyai__xstate__2286
statelyai/xstate
2,286
defect
fa2fdae2ba55ba3300da76adc31c034d2f1d1873
9d296d59295964f231a38ea39e79b5f77c4c941b
Deprecate useService()
With `.getSnapshot()`, the `useService()` hooks are virtually the same as `useActor()`.
diff --git a/.changeset/fresh-carrots-rule.md b/.changeset/fresh-carrots-rule.md new file mode 100644 index 0000000000..4c3fc57bc3 --- /dev/null +++ b/.changeset/fresh-carrots-rule.md @@ -0,0 +1,10 @@ +--- +'@xstate/react': minor +--- + +The `useService(...)` hook will be deprecated, since services are also actors. In ...
6
5
5
[{"id": "G0", "claim": "Removing the `.state` property from the deferred actor is a compatibility risk and both properties should be kept for the time being.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The README should be clarified on whether th...
null
statelyai__xstate__2334
statelyai/xstate
2,334
defect
90ddd4a689ccd28c3ed5f9adcdf5062e2c0b1bee
2151c2fcd97b75be3ca7944e59b8627ea6553fa7
Ensure that context is defined when model type provided to createMachine()
When using a model type in `createMachine<typeof someModel>(...)`, TypeScript will no longer compile machines that are missing the `context` property in the machine configuration: ```ts const machine = createMachine<typeof someModel>({ // missing context - will give a TS error! // context: someModel.initialCo...
diff --git a/packages/core/src/Machine.ts b/packages/core/src/Machine.ts index 47dd89cd8f..283cbc6040 100644 --- a/packages/core/src/Machine.ts +++ b/packages/core/src/Machine.ts @@ -55,7 +55,7 @@ export function createMachine< TEvent extends EventObject = ModelEventsFrom<TModel>, TTypestate extends Typestate<TCo...
2
1
0
[{"id": "G0", "claim": "Add a comment on the second overload explaining that its `TContext extends Model ? never` conditional exists to catch models that fail to match the first overload, preventing the Model from being inferred as TContext with cryptic errors.", "category": "documentation", "verdict": "supported", "pr...
null
statelyai__xstate__2358
statelyai/xstate
2,358
defect
99cc26ae1b69c40f524ccd159b37d276da11268e
3019510fb51788308db5b9a9fa9ae1d12de51866
Add Symbol.observable to interpreter.
Fixes #1997
diff --git a/.changeset/itchy-moles-count.md b/.changeset/itchy-moles-count.md new file mode 100644 index 0000000000..e07cdc0e0e --- /dev/null +++ b/.changeset/itchy-moles-count.md @@ -0,0 +1,9 @@ +--- +'xstate': minor +'@xstate/fsm': minor +'@xstate/inspect': minor +'@xstate/react': minor +'@xstate/vue': minor +--- + ...
3
3
1
[{"id": "G0", "claim": "TypeScript fails to infer the correct type of the resulting observable, always thinking it is an Observable<never> and thus erroring when trying to use its emissions, which callers can only overcome by explicitly stating the typings of the from() call.", "category": "correctness", "verdict": "su...
null
statelyai__xstate__2379
statelyai/xstate
2,379
defect
9b456beb316e5de6a73fb295142f2f935b7f8c65
763f51541bba147835dd858e23941e3ac7dde20e
Add `.preserveActionOrder` machine config option
This PR adds the opt-in `.preserveActionOrder` setting to machine configuration, which is `false` by default (current behavior). When `.preserveActionOrder` is `true`, all actions will be called _in order_ instead of prioritizing `assign(...)` actions. The intermediate `context` result of `assign(...)` actions will ...
diff --git a/packages/core/src/StateNode.ts b/packages/core/src/StateNode.ts index 2c6711d75a..e4bfcbd424 100644 --- a/packages/core/src/StateNode.ts +++ b/packages/core/src/StateNode.ts @@ -1185,7 +1185,8 @@ class StateNode< currentState, currentContext, _event, - actions + actions, + ...
4
3
1
[{"id": "G0", "claim": "The preserveActionOrder handling will have to be ported to v5 as well, since v5 does not yet preserve the order of custom actions.", "category": "correctness", "verdict": "supported", "priority": "P2", "scope": "pre_existing"}, {"id": "G1", "claim": "Why is the newly added `.filter` now needed, ...
null
statelyai__xstate__2508
statelyai/xstate
2,508
defect
a450ee56eb1393ead9f152fe3a36d9bb2290f232
5b70c2ff21cc5d8c6cf1c13b6eb7bb12611a9835
[core] Fix race condition when stopping child of initializing parent machine
This PR fixes #2507 The problem was a classic race condition: 1. Child machine determining initial state (`this.state` is still `undefined`) 2. Grandchild machine immediately stopping, notifying child machine 3. Child machine trying to remove grandchild from `this.state.children` (remember: `this.state` is sti...
diff --git a/.changeset/large-crabs-serve.md b/.changeset/large-crabs-serve.md new file mode 100644 index 0000000000..c06cf8980b --- /dev/null +++ b/.changeset/large-crabs-serve.md @@ -0,0 +1,5 @@ +--- +'xstate': patch +--- + +A race condition occurred when a grandchild service is immediately stopped and the child serv...
7
6
1
[{"id": "G0", "claim": "A potentially simpler test case — a parent and a child instead of a 3-layer actor hierarchy — can be written to validate this behavior.", "category": "testing", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The done-event handling should be guarded in `...
null
statelyai__xstate__2736
statelyai/xstate
2,736
defect
edc64726dbc64ddb485b5e6294c5499d0dd630df
2246ae051663f261b4750d7adba57f008ec28f1d
[@xstate/react] Fix stale actor for `useSelector`
This PR simplifies the `useSelector` hook and fixes the stale actor issue found in #2702 Fixes #2702
diff --git a/.changeset/fast-timers-protect.md b/.changeset/fast-timers-protect.md new file mode 100644 index 0000000000..8c85339fca --- /dev/null +++ b/.changeset/fast-timers-protect.md @@ -0,0 +1,5 @@ +--- +'@xstate/react': patch +--- + +The `useSelector(...)` hook now works as expected when the `actor` passed in cha...
2
2
2
[{"id": "G0", "claim": "The effect that calls updateSelectedIfChanged on [selector, compare] changes is a noop when only the selector changes, even though the effect's inputs imply that a selector change is relevant and should take effect.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": ...
null
statelyai__xstate__2804
statelyai/xstate
2,804
defect
d19e4eb3313a25572d1d1e5f65f4b11a3f04e633
f3caecf5ad384cfe2a843c26333aaa46a77ece68
Optimize `state.can()`
This PR optimizes `state.can()` by reading the transition data before evaluating the actions (such as `assign(...)`), which do not need to be evaluated in order to determine if the state will change. Fixes #2803
diff --git a/.changeset/famous-dryers-build.md b/.changeset/famous-dryers-build.md new file mode 100644 index 0000000000..d5d29ef4c5 --- /dev/null +++ b/.changeset/famous-dryers-build.md @@ -0,0 +1,5 @@ +--- +'xstate': patch +--- + +The `state.can(...)` method no longer unnecessarily executes `assign()` actions and ins...
1
1
1
[{"id": "G0", "claim": "The 'should not execute assignments' test cannot truly verify what its title suggests because a thrown error could be swallowed and the test would still pass, so refactor it to change a variable inside assign and assert that it was not changed.", "category": "testing", "verdict": "supported", "p...
null
statelyai__xstate__2839
statelyai/xstate
2,839
defect
b6a9eb3090435c0eb9ef7be6c44cbb7a63ed29b1
ba8d598c8aad1c4a306f693a6942483535a55361
[core] Add potential fix for failing `state.can` test
This PR potentially fixes #2837, but reveals another problem in which transitions with multiple targets might be incorrect, preventing this fix from working.
diff --git a/packages/core/src/State.ts b/packages/core/src/State.ts index 4d5c3fdbf2..ee8857b2f2 100644 --- a/packages/core/src/State.ts +++ b/packages/core/src/State.ts @@ -335,21 +335,32 @@ export class State< const transitionData = this.machine?.getTransitionData(this, event); + if (!transitionData) { +...
2
2
2
[{"id": "G0", "claim": "The newly added parallel-regions test for `state.can` passes locally but fails on CI.", "category": "correctness", "verdict": "supported", "priority": "P0", "scope": "introduced"}, {"id": "G1", "claim": "Resolving `state.can` correctly with the current complex logic is difficult and another fail...
null
statelyai__xstate__2864
statelyai/xstate
2,864
defect
89fcc6d47f1890f09752d73d086fdd158898c194
c7937c2dcf85874230bc89aebfd12105e46166e1
[core] Do not use `src` in place of missing invoke `id`
This PR replaces the erroneous "id or src" logic for an invocation's `id` with a unique and predictable generated `id`. Fixes #464
diff --git a/packages/core/src/StateNode.ts b/packages/core/src/StateNode.ts index 27872f64b9..0b0ad5ba88 100644 --- a/packages/core/src/StateNode.ts +++ b/packages/core/src/StateNode.ts @@ -414,7 +414,7 @@ class StateNode< return toInvokeDefinition({ ...invokeConfig, - id: invokeConfig.i...
4
3
1
[{"id": "G0", "claim": "The test did not need to add an explicit `id: 'fetchData'`; it could rely on the auto-generated invoke id to keep the change's scope smaller.", "category": "testing", "verdict": "opposed", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "A test case covering the invoke-id change ...
null
statelyai__xstate__2881
statelyai/xstate
2,881
defect
326937415f20a7e1020832f09a1d30f3b379fd46
3c7718600fabc2f4f9576ec8149dc1a5a20bfe09
[v5] Improve target resolution
This PR improves target resolution: - Targeting sibling nodes from the root is no longer valid, since the root node has no siblings ```diff createMachine({ id: 'direction', initial: 'left', states: { left: {}, right: {} }, on: { - LEFT_CLICK: 'left', + LEFT_CLICK: '.left' } });...
diff --git a/.changeset/heavy-apes-tie.md b/.changeset/heavy-apes-tie.md new file mode 100644 index 0000000000..5bd964a773 --- /dev/null +++ b/.changeset/heavy-apes-tie.md @@ -0,0 +1,20 @@ +--- +'xstate': major +--- + +Target resolution improvements: targeting sibling nodes from the root is no longer valid, since the r...
2
2
2
[{"id": "G0", "claim": "Using an id containing a dot ('.dot') in the test should be disallowed — ids with dots should be completely forbidden (leading or middle) because they are ambiguous between a literal id and a path chained from the first segment.", "category": "correctness", "verdict": "supported", "priority": "P...
null
statelyai__xstate__3097
statelyai/xstate
3,097
defect
ab0b98e078f746ca9ec0da18638dee4bd49eaccd
baa3c5285003789a62a4a2b5b132e270e5695819
Fix `state.can()` from restored state
Fixes #3096
diff --git a/.changeset/twenty-timers-cheat.md b/.changeset/twenty-timers-cheat.md new file mode 100644 index 0000000000..d55f868306 --- /dev/null +++ b/.changeset/twenty-timers-cheat.md @@ -0,0 +1,7 @@ +--- +'xstate': patch +--- + +State that is persisted and restored from `machine.resolveState(state)` will now have t...
5
4
0
[{"id": "G0", "claim": "Since `this.machine === this` here, the added line could be simplified to `machine: (this as unknown) as AnyStateMachine`.", "category": "maintainability", "verdict": "opposed", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "The new 'should work with restored state' test belong...
null
statelyai__xstate__3215
statelyai/xstate
3,215
defect
7a698d4e3e6c8d6ee55bde2febd4667166e0f92d
92f6ae2671afad70a1a7a374dfcd4ee3f3e30e03
Allow passing `Infinity` to `waitFor` as timeout
Closes #3214 WIP for now as I need figure out how to write a test for this, any pointers?
diff --git a/.changeset/cool-ducks-pretend.md b/.changeset/cool-ducks-pretend.md new file mode 100644 index 0000000000..9e4092918c --- /dev/null +++ b/.changeset/cool-ducks-pretend.md @@ -0,0 +1,20 @@ +--- +'xstate': minor +--- + +Removing the timeout that's built in to `waitFor` is now supported by explicitly passing ...
3
2
1
[{"id": "G0", "claim": "Other very large timeout values such as Number.MAX_SAFE_INTEGER also seem to make setTimeout fire its callback immediately, so special-casing only `timeout === Infinity` may not cover every value that overflows the timer's maximum delay.", "category": "correctness", "verdict": "uncertain", "prio...
null
statelyai__xstate__3487
statelyai/xstate
3,487
defect
daf7994d541c5be5e0bac563b79f2dd967f97363
3867993f79b523c27ae5b98f30636f4338aaf99c
Make it impossible to exit a root state
closes #3072
diff --git a/.changeset/purple-buses-hug.md b/.changeset/purple-buses-hug.md new file mode 100644 index 0000000000..f98040f09a --- /dev/null +++ b/.changeset/purple-buses-hug.md @@ -0,0 +1,8 @@ +--- +'xstate': patch +--- + +author: @Andarist +author: @davidkpiano + +Make it impossible to exit a root state. For example,...
2
2
0
[{"id": "G0", "claim": "The changeset text misspells \"this\" as \"yhis\" and should be corrected.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The new test for root external transitions should also be covered by a test based on entry/exit actio...
null
statelyai__xstate__3500
statelyai/xstate
3,500
defect
1788590fc70cf527939311bc90421630d15ff655
7aa9362e6b1ee6b36bc38a880a5fcd05e4f488fc
Fixed an issue with `useSelector` always computing fresh snapshots internally for uninitialized services
closes #3497
diff --git a/.changeset/weak-singers-jog.md b/.changeset/weak-singers-jog.md new file mode 100644 index 0000000000..0d80acea8c --- /dev/null +++ b/.changeset/weak-singers-jog.md @@ -0,0 +1,5 @@ +--- +'@xstate/react': patch +--- + +Fixed an issue with `useSelector` always computing fresh snapshots internally for uniniti...
3
1
0
[{"id": "G0", "claim": "The snapshot caching inside defaultGetSnapshot is a hack that is not referentially transparent and cannot be cleanly refactored in v4, since computing the initial snapshot of an uninitialized service could cause side-effects (the problem does not exist in v5).", "category": "design", "verdict": ...
null
statelyai__xstate__3541
statelyai/xstate
3,541
defect
7d5be188f85bca4d25d79888d4e14bdd6811952e
3c702a41d8a1df911e130c7a9b48e345456b075f
Fixed an issue with not being able to read the updated snapshot of a child when receiving and processing events from it and when using `predictableActionArguments` flag
fixes #3533
diff --git a/.changeset/gold-icons-protect.md b/.changeset/gold-icons-protect.md new file mode 100644 index 00000000000..7af89147cc1 --- /dev/null +++ b/.changeset/gold-icons-protect.md @@ -0,0 +1,5 @@ +--- +'xstate': patch +--- + +Fixed an issue that caused `invoke`d actors to be created before resolving `assign` acti...
2
1
0
[{"id": "G0", "claim": "The outgoing queue could be simpler — just an array of functions to be executed (e.g. `this._outgoingQueue.push(() => { target.send(scxmlEvent) })`) instead of `[target, event]` tuples.", "category": "design", "verdict": "uncertain", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim"...
null
statelyai__xstate__3837
statelyai/xstate
3,837
defect
3d31d8eb7a215c6650ef3e1cbf279fabeef3b5a9
20fa1539d50550fe7d0890208a3402ad8b19ba69
[v5] System (receptionist)
This PR creates an implicit system and provides it in the machine implementations: ```ts const machine = createMachine({ id: 'parent', initial: 'a', states: { a: { invoke: [ { src: fromCallback((_, receive) => { receive((event) => { expect(event.t...
diff --git a/packages/core/src/StateNode.ts b/packages/core/src/StateNode.ts index f2a7dfcf08..6a82abaaaf 100644 --- a/packages/core/src/StateNode.ts +++ b/packages/core/src/StateNode.ts @@ -258,7 +258,7 @@ export class StateNode< const generatedId = createInvokeId(this.id, i); const invokeConfig = to...
16
10
7
[{"id": "G0", "claim": "The system should be accessible from the interpreter for outside use, e.g. `service.system.get('receiver')` from code outside the machine, so events can be sent to a specific actor instead of broadcasting to every running statechart.", "category": "design", "verdict": "supported", "priority": "P...
null
statelyai__xstate__3889
statelyai/xstate
3,889
defect
326937415f20a7e1020832f09a1d30f3b379fd46
8c52329f40246065ab5840a5a051c108948ea9b0
[v5] Remove `autoForward`
The recommended pattern moving forward would be to explicitly `sendTo(...)` events to actors. ~~There are still some SCXML tests that depend on `autoForward`.~~ XState will no longer support `autoForward` in SCXML.
diff --git a/.changeset/fresh-garlics-fry.md b/.changeset/fresh-garlics-fry.md new file mode 100644 index 0000000000..25b19af3b4 --- /dev/null +++ b/.changeset/fresh-garlics-fry.md @@ -0,0 +1,22 @@ +--- +'xstate': major +--- + +Autoforwarding events is no longer supported and the `autoForward` property has been removed...
3
3
0
[{"id": "G0", "claim": "The test renamed to 'another forwarding pattern' should just be removed: it was testing autoForward-specific behavior that is no longer relevant and its new title is meaningless.", "category": "testing", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The...
null
statelyai__xstate__3924
statelyai/xstate
3,924
defect
b394cf18885e687910c62f03192952081b1548a5
0bb233ad074de4a1ef865beba89326ed8ed9053b
[v5] Rename reducer -> transition function
This PR renames `fromReducer` to `fromTransition`.
diff --git a/packages/core/src/actors/index.ts b/packages/core/src/actors/index.ts index 315238b037..05cc26c667 100644 --- a/packages/core/src/actors/index.ts +++ b/packages/core/src/actors/index.ts @@ -1,7 +1,7 @@ import type { EventObject, ActorRef, BaseActorRef } from '../types.js'; import { symbolObservable } fro...
2
2
0
[{"id": "G0", "claim": "Some outdated snapshots (e.g. the old 'shortest paths for reducers' / 'simple paths for reducers' blocks) in packages/xstate-graph/test/__snapshots__/graph.test.ts.snap should perhaps be removed.", "category": "testing", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G...
null
statelyai__xstate__3952
statelyai/xstate
3,952
defect
1dbf190127d47df2aec20ea13f0b38c637ecd7e5
19e4aeb8d50979e10c7eaed7599792375f54b86f
[v5] Final `.data` to `.output`
This PR renames `.data` to `.output` on final states: ```diff const machine = createMachine({ // ... states: { // ... success: { - data: { message: 'Success!' } + output: { message: 'Success!' } } } }) ```
diff --git a/.changeset/five-mirrors-join.md b/.changeset/five-mirrors-join.md new file mode 100644 index 0000000000..2b7067c6cf --- /dev/null +++ b/.changeset/five-mirrors-join.md @@ -0,0 +1,21 @@ +--- +'xstate': major +'@xstate/fsm': major +'@xstate/react': major +'@xstate/vue': major +--- + +The output data on final...
3
3
2
[{"id": "G0", "claim": "The changeset should not declare major version bumps for @xstate/fsm, @xstate/react and @xstate/vue, because this change does not affect those libraries.", "category": "documentation", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The internal `doneData...
null
statelyai__xstate__3967
statelyai/xstate
3,967
defect
61db63bf44edf0efe4774ebdec29244d7d024381
e5b1e11f05055039a3c3963a26ba07122e24a1c2
[v5] Throw when sending strings
Event objects should be sent; sending strings is no longer allowed.
diff --git a/.changeset/eighty-trainers-compare.md b/.changeset/eighty-trainers-compare.md new file mode 100644 index 0000000000..0971e0f449 --- /dev/null +++ b/.changeset/eighty-trainers-compare.md @@ -0,0 +1,5 @@ +--- +'xstate': major +--- + +Sending a string event to `actor.send('some string')` will now throw a prop...
2
1
1
[{"id": "G0", "claim": "Whether sending a string event should throw an error or only warn is undecided, and the author asks which behavior is intended.", "category": "design", "verdict": "uncertain", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The same string guard added to Interpreter.send should ...
null
statelyai__xstate__3990
statelyai/xstate
3,990
defect
bfbd1696442d9a76d9cec2a8a007348bb7bc2c6d
dee96fcade13ebf668dbc6705dc44c0342fd17c7
[v5] `systemId` for `spawn()`
This PR adds `systemId` to the 2nd argument of `spawn(logic, options?)`.
diff --git a/.changeset/great-kangaroos-confess.md b/.changeset/great-kangaroos-confess.md new file mode 100644 index 0000000000..330b73dbd1 --- /dev/null +++ b/.changeset/great-kangaroos-confess.md @@ -0,0 +1,19 @@ +--- +'xstate': major +--- + +You can now add a `systemId` to spawned actors to reference them anywhere ...
4
1
0
[{"id": "G0", "claim": "The `--testTimeout=2147483647` in .vscode/launch.json makes any failing test hang for a long time instead of timing out, making it very difficult to determine which test is failing.", "category": "tooling", "verdict": "uncertain", "priority": "P2", "scope": "pre_existing"}, {"id": "G1", "claim":...
null
statelyai__xstate__4020
statelyai/xstate
4,020
defect
4c3169ad2d6c47355ab5f8af54c9d994da2f10a8
da3613c731200f2f07f72b8c2529e99c5d6926a3
[v5] Add `input` support to `fromEventObservable`
Fixes #4019
diff --git a/.changeset/selfish-points-know.md b/.changeset/selfish-points-know.md new file mode 100644 index 0000000000..c4528dc961 --- /dev/null +++ b/.changeset/selfish-points-know.md @@ -0,0 +1,16 @@ +--- +'xstate': major +--- + +The `fromEventObservable` actor logic creator now accepts `input`: + +```ts +const mac...
1
1
0
[{"id": "G0", "claim": "The changeset should declare the 'xstate' bump as patch instead of major.", "category": "correctness", "verdict": "supported", "priority": "P2", "scope": "introduced"}]
null
statelyai__xstate__4065
statelyai/xstate
4,065
defect
754afa022047518ef4813f7aa85398218b39f960
8c1d92e0a460e132e7d5249e9c9510d307f31369
Add support for wildcard transitions to xstate-fsm
After a recent discussion regarding how to handle unexpected events (#4057) brought wildcard transitions to my attention, I wanted to see what it would take to add them to the @xstate/fsm package. Fortunately, it turned out to be pretty straightforward. This PR introduces three behavioral changes, in addition to the...
diff --git a/.changeset/tall-flies-occur.md b/.changeset/tall-flies-occur.md new file mode 100644 index 0000000000..d4295936c0 --- /dev/null +++ b/.changeset/tall-flies-occur.md @@ -0,0 +1,7 @@ +--- +'@xstate/fsm': major +--- + +This change adds support for using "\*" as a wildcard event type in machine configs. + +Bec...
3
3
2
[{"id": "G0", "claim": "The value position of the mapped `on` type still filters TEvent with `TEvent extends { type: K } ? TEvent : never`, so for the '*' key the transition's event type narrows to never; it must route through a conditional that forwards the whole TEvent for '*'.", "category": "correctness", "verdict":...
null
statelyai__xstate__4157
statelyai/xstate
4,157
defect
4df574405f8fa412acbd2f5ee6eb87825d9ef4f7
020d3073ffc70f490ab8ece8bfba9e7f776b9f4b
[v5] Invoke callback as single object arg
Merge `sendBack` and `receive` with other properties on `InvokeCallback` type. ```ts const callbackLogic = fromCallback(({ input, system, self, sendBack, receive }) => { ... }); ``` ### Previously ```ts const callbackLogic = fromCallback((sendBack, receive, { input, self, system }) => { ... }); ``` Fr...
diff --git a/.changeset/beige-schools-smash.md b/.changeset/beige-schools-smash.md new file mode 100644 index 00000000000..1dd952e45d6 --- /dev/null +++ b/.changeset/beige-schools-smash.md @@ -0,0 +1,9 @@ +--- +'xstate': minor +--- + +Merge `sendBack` and `receive` with other properties of `fromCallback` logic creator....
2
2
0
[{"id": "G0", "claim": "Move the InvokeCallback and Receiver types out of packages/core/src/types.ts into packages/core/src/actors/callback.ts (keeping them exported).", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "Rename the local variables `se...
null
statelyai__xstate__4172
statelyai/xstate
4,172
defect
8163d1962b6ea022e4ede40ae8e8f85fa2badb93
97cf4ebd1d3699ac5d2effdb1cde6756defb4c9d
[v5] `onSnapshot` for all actors
This PR adds `onSnapshot: { ... }` support for all supported invoked actor logic.
diff --git a/.changeset/mean-pianos-explode.md b/.changeset/mean-pianos-explode.md new file mode 100644 index 0000000000..2488db6ad5 --- /dev/null +++ b/.changeset/mean-pianos-explode.md @@ -0,0 +1,45 @@ +--- +'xstate': minor +--- + +The `onSnapshot: { ... }` transition object is now supported for invoked machines, obs...
12
9
5
[{"id": "G0", "claim": "The restructure of `getStatus` in StateMachine.ts (adding `as const` and renaming `data` to `error`) is an unrelated change that should not be part of this PR.", "category": "design", "verdict": "uncertain", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The new `subscribe` fla...
null
statelyai__xstate__4179
statelyai/xstate
4,179
defect
2e176b0b95eefddb7231f7dd40c18e3022ec9706
14b172779e4f61f0ec0f82c7b71cf62a05e35ad5
[v5] Output types
Output types can now be specified in the machine: ```ts const machine = createMachine({ types: {} as { output: { result: 'pass' | 'fail'; score: number; }; } // ... }); const actor = createActor(machine); // ... const snapshot = actor.getSnapshot(); if (snapshot.output)...
diff --git a/.changeset/swift-stingrays-notice.md b/.changeset/swift-stingrays-notice.md new file mode 100644 index 0000000000..d88f43c2a7 --- /dev/null +++ b/.changeset/swift-stingrays-notice.md @@ -0,0 +1,30 @@ +--- +'xstate': minor +--- + +Output types can now be specified in the machine: + +```ts +const machine = c...
1
1
1
[{"id": "G0", "claim": "The TOutput generic added to StateNodeConfig doesn't achieve what it meant to — the machine's output has to be configured on a final state that is a direct child of the root, and the parameter wrongly suggests TOutput might be passed down to inner StateNodeConfigs — so it should be removed from ...
null
statelyai__xstate__4184
statelyai/xstate
4,184
defect
1710ace037547b73091a05181534bea9c0a6500a
a028ff8a86514e36e774d4fae38689bb226f2e04
[v5] Routable states
Added routable states. States with `route: {}` and an explicit `id` can be navigated to from anywhere via a single `{ type: 'xstate.route', to: id }` event. ```ts const machine = setup({}).createMachine({ id: 'app', initial: 'home', states: { home: { id: 'home', route: {} }, dashboard: { i...
diff --git a/.changeset/three-sails-rhyme.md b/.changeset/three-sails-rhyme.md new file mode 100644 index 0000000000..5f931ec8da --- /dev/null +++ b/.changeset/three-sails-rhyme.md @@ -0,0 +1,37 @@ +--- +'xstate': minor +--- + +Added routable states. States with `route: {}` can be navigated to from anywhere via `xstate...
7
5
2
[{"id": "G0", "claim": "The PR should emit a route event whenever a state is entered (e.g. via actor.send of a route event) so the route stays in sync with the active state.", "category": "design", "verdict": "opposed", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "The route config should have a way ...
null
statelyai__xstate__4198
statelyai/xstate
4,198
defect
d3d72b1f8b06fa5c7608d47dca581b53c257ca50
0c2e56270c884abba5d5c200fbede11f071ad2a2
`toPromise(actorRef)`
This PR introduces `toPromise(actor)`, which creates a promise from an actor that resolves with `output` when the actor is done. ```ts import { createMachine, createActor, toPromise } from 'xstate'; const actor = createActor(createMachine({ // ... states: { // ... done: { type: 'final', output: 4...
diff --git a/packages/core/src/StateMachine.ts b/packages/core/src/StateMachine.ts index bb849505f4..6002da96bb 100644 --- a/packages/core/src/StateMachine.ts +++ b/packages/core/src/StateMachine.ts @@ -362,7 +362,11 @@ export class StateMachine< > { return getPersistedState(state); } - + public getOutput( ...
3
3
2
[{"id": "G0", "claim": "Instead of adding yet another getOutput method to the logic interface, the status handling should be standardized so that output can be read from the existing getStatus return value.", "category": "design", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "...
null
statelyai__xstate__4231
statelyai/xstate
4,231
defect
0b08a605b331cfb8adcb14ca14f39dafec1238d2
5cf0fce0f30ff0901312ab81018d135379d2a983
Allow optional actor in `useSelector`
This PR allows an actor to be `undefined` here, with proper typing: ```ts const someState = useSelector(maybeActor, (snapshot) => ...); someState; // derived state or undefined ```
diff --git a/.changeset/beige-donuts-grab.md b/.changeset/beige-donuts-grab.md new file mode 100644 index 0000000000..9a230fad5d --- /dev/null +++ b/.changeset/beige-donuts-grab.md @@ -0,0 +1,14 @@ +--- +'@xstate/react': minor +--- + +The `actor` passed to `useSelector(actor, selector)` is now allowed to be `undefined`...
4
4
1
[{"id": "G0", "claim": "The declared types say the selector may receive `undefined`, but the implementation backs the missing actor with `createEmptyActor`, so the selector actually receives `Snapshot<undefined>`; the implementation should let the selector see actual `undefined` instead.", "category": "correctness", "v...
null
statelyai__xstate__4233
statelyai/xstate
4,233
defect
189fa2466add7e9e6ed56ae0f82c8ed9c3018115
b3746427135993323a5f1b119eb08c807cedf271
Remove getMachineShortestPaths and getMachineSimplePaths
Remove `getMachineShortestPaths` and `getMachineSimplePaths` ```diff import { - getMachineShortestPaths, + getShortestPaths, - getMachineSimplePaths, + getSimplePaths } from '@xstate/graph'; -const paths = getMachineShortestPaths(machine); +const paths = getShortestPaths(machine); -const paths = getMach...
diff --git a/.changeset/config.json b/.changeset/config.json index 07bf7522c1..cc0cd40e5a 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -7,7 +7,6 @@ "baseBranch": "main", "ignore": [ "@xstate/analytics", - "@xstate/graph", "@xstate/immer", "@xstate/inspect", "@xstate/s...
2
1
0
[{"id": "G0", "claim": "The changesets config change (unignoring @xstate/graph) should be kept out of this PR and made in a separate follow-up PR instead, and @xstate/test should be considered for removal from the ignore list there too.", "category": "process", "verdict": "supported", "priority": "P2", "scope": "introd...
null
statelyai__xstate__4488
statelyai/xstate
4,488
defect
d90a5954b91ed774babf39b5ce3873efe05fe600
d134a0d78a61d03d9f1850db1be99684267d57f1
[v5] Rename `spawn(...)` action creator to `spawnChild(...)`
The `spawn(...)` action creator has been renamed to `spawnChild(...)` to avoid confusion. ```ts import { spawnChild, assign } from 'xstate'; const childMachine = createMachine({ on: { someEvent: { actions: [ // spawnChild(...) instead of spawn(...) spawnChild('someSrc'), ...
diff --git a/.changeset/mean-cows-taste.md b/.changeset/mean-cows-taste.md new file mode 100644 index 0000000000..fb53c6b8b6 --- /dev/null +++ b/.changeset/mean-cows-taste.md @@ -0,0 +1,25 @@ +--- +'xstate': minor +--- + +The `spawn(...)` action creator has been renamed to `spawnChild(...)` to avoid confusion. + +```ts...
8
7
1
[{"id": "G0", "claim": "The action object returned by the renamed action creator still carries the old `xstate.spawn` type tag; it should be `xstate.spawnChild`.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The file packages/core/src/actions/spawn...
null
statelyai__xstate__4596
statelyai/xstate
4,596
defect
138c9e4e374ae9123eb1f286dce48f2b35c6bcd9
3ed0e05127c7c04a0435529c02abedf5aabfd401
[core] `getNextSnapshot(...)`
Introduce `getNextSnapshot(...)`, which determines the next snapshot for the given `actorLogic` based on the given `snapshot` and `event`. If the `snapshot` is `undefined`, the initial snapshot of the `actorLogic` is used. ```ts import { getNextSnapshot } from 'xstate'; import { trafficLightMachine } from './tr...
diff --git a/.changeset/khaki-monkeys-clap.md b/.changeset/khaki-monkeys-clap.md new file mode 100644 index 0000000000..d21bd17ab6 --- /dev/null +++ b/.changeset/khaki-monkeys-clap.md @@ -0,0 +1,30 @@ +--- +'xstate': minor +--- + +Introduce `getNextSnapshot(...)`, which determines the next snapshot for the given `actor...
7
5
3
[{"id": "G0", "claim": "It would make sense to position the `snapshot` parameter last so that it can be omitted at the call site instead of passing `undefined`.", "category": "design", "verdict": "opposed", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "The new module should not import types and `crea...
null
statelyai__xstate__4597
statelyai/xstate
4,597
defect
138c9e4e374ae9123eb1f286dce48f2b35c6bcd9
4e0cc5697aa960e0690ebff07b2f28e1c8b8d142
[core] Add `self` and `system` to `enqueueActions(...)`
Updates the argument object of `enqueueActions(...)` to include a `self` property: ```ts // ... entry: enqueueActions(({ self }) => { // ... }); ```
diff --git a/.changeset/strong-jobs-unite.md b/.changeset/strong-jobs-unite.md new file mode 100644 index 0000000000..04acaacfc5 --- /dev/null +++ b/.changeset/strong-jobs-unite.md @@ -0,0 +1,12 @@ +--- +'xstate': patch +--- + +Update the argument object of `enqueueActions(...)` to include a `self` property: + +```ts +...
1
1
0
[{"id": "G0", "claim": "The changeset only documents the new `self` property of `enqueueActions(...)` and should also cover the `system` property the PR adds.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}]
null
statelyai__xstate__4685
statelyai/xstate
4,685
defect
40ec4fab867d150f71fcd15ce248cbc7f95fe87a
98faec4608dddb291000a8abf0bf00932df5ad1d
Allow escaped periods in state IDs
State IDs that have periods in them are now supported if those periods are escaped. The motivation is that external tools, such as [Stately Studio](https://stately.ai/studio), may allow users to enter any text into the state ID field. This change allows those tools to escape periods in state IDs, so that they don't ...
diff --git a/.changeset/brave-llamas-hammer.md b/.changeset/brave-llamas-hammer.md new file mode 100644 index 0000000000..188c6aa498 --- /dev/null +++ b/.changeset/brave-llamas-hammer.md @@ -0,0 +1,9 @@ +--- +'xstate': patch +--- + +State IDs that have periods in them are now supported if those periods are escaped. + +...
5
5
4
[{"id": "G0", "claim": "The new test titled 'should work with IDs that have escaped periods' actually focuses on a state key containing escaped dots, so it should be renamed (and maybe moved), and a separate test case with that exact title is needed covering ID targets like '#xyz\\.bar' vs '#xyz.bar2'.", "category": "t...
null
statelyai__xstate__4695
statelyai/xstate
4,695
defect
04d22fe7f11058c45ce41b87f4b694f5aa4d2e15
430e308e05b9c6f27d348acb601c9ed25e3dd8b7
Merge `createActorContext` options with Provider options
Options in `createActorContext` are now properly merged with provider options. Previously, provider options replaced the actor options. ```tsx const { inspect } = createBrowserInspector(); const SomeContext = createActorContext(someMachine, { inspect }); // ... // Options are now merged: // { inspect: inspe...
diff --git a/.changeset/honest-spoons-drum.md b/.changeset/honest-spoons-drum.md new file mode 100644 index 0000000000..16164c6979 --- /dev/null +++ b/.changeset/honest-spoons-drum.md @@ -0,0 +1,18 @@ +--- +'@xstate/react': patch +--- + +Options in `createActorContext` are now properly merged with provider options. Pre...
2
2
1
[{"id": "G0", "claim": "The `options: providedOptions = actorOptions` default should be removed (e.g. via the attached suggestion) because with it the provider often merges an options object with itself, producing redundant copies.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}...
null
statelyai__xstate__4731
statelyai/xstate
4,731
defect
54a2b01e666a705c643ff7b1a7b0bf7a074aa9c1
0d5fddc655300d3e405bd8ae8f61a5f40c663cf8
Expose getInitialSnapshot
You can now import `getInitialSnapshot(…)` from `xstate` directly: ```ts import { getInitialSnapshot } from 'xstate'; ```
diff --git a/.changeset/clean-brooms-yell.md b/.changeset/clean-brooms-yell.md new file mode 100644 index 0000000000..274b2adb34 --- /dev/null +++ b/.changeset/clean-brooms-yell.md @@ -0,0 +1,9 @@ +--- +'xstate': patch +--- + +You can now import `getInitialSnapshot(…)` from `xstate` directly: + +```ts +import { getInit...
1
1
0
[{"id": "G0", "claim": "The changeset should mention what getInitialSnapshot is even useful for.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}]
null
statelyai__xstate__4739
statelyai/xstate
4,739
defect
91549ce8a6a5105b3d354ca442ea5c058e58e206
da476c176eeeae453ba3d8e47c18692c6f7b2c1a
#4734 bugfix: removed `this` from snapshot methods
Resolves https://github.com/statelyai/xstate/issues/4734. I tested locally using the same scenario as used in the issue and the types behaved as expected. I couldn't really figure out a way to programmatically prove work and test the types directly. Please advise if there is something you'd like to see there.
diff --git a/.changeset/fifty-beds-love.md b/.changeset/fifty-beds-love.md new file mode 100644 index 0000000000..d42680f23e --- /dev/null +++ b/.changeset/fifty-beds-love.md @@ -0,0 +1,5 @@ +--- +'xstate': patch +--- + +Removed `this` from actor snapshot methods to resolve [#4734](https://github.com/statelyai/xstate/i...
2
2
1
[{"id": "G0", "claim": "The PR ships the type-level fix with no test proving it, and a test case should be added in packages/core/test/types.test.ts.", "category": "testing", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G4", "claim": "The changeset description should be reworded to say `thi...
null
statelyai__xstate__4890
statelyai/xstate
4,890
defect
63ac3ad713ddb651d3efc9202c5c98128c4093c5
394d5458d458dea00ab778e6e3bffc029a935472
[@xstate/store] Fix `createStoreWithProducer(…)` types
The `context` type for `createStoreWithProducer(producer, context, transitions)` will now be properly inferred. ```ts const store = createStoreWithProducer( produce, { count: 0 }, { // ... } ); store.getSnapshot().context; // BEFORE: StoreContext // NOW: { count: number } ```
diff --git a/.changeset/nice-spiders-perform.md b/.changeset/nice-spiders-perform.md new file mode 100644 index 0000000000..0c4a2e09eb --- /dev/null +++ b/.changeset/nice-spiders-perform.md @@ -0,0 +1,21 @@ +--- +'@xstate/store': patch +--- + +The `context` type for `createStoreWithProducer(producer, context, transitio...
1
1
1
[{"id": "G0", "claim": "Requiring the producer parameter to be generic (`producer: <T>(context: T, recipe: (context: T) => void) => T`) breaks passing non-generic producers, which worked before the change, and the producer parameter should be `NoInfer<(context: TContext, recipe: (context: TContext) => void) => TContext...
null
statelyai__xstate__4905
statelyai/xstate
4,905
defect
01cfc0a8ee5ef6e96ae00cf400f03a260b168d90
72532828a88cdd6ec3e91366585509003eb6bc1d
[core] Wildcard emitted event listener
You can now use a wildcard to listen for _any_ emitted event from an actor: ```ts actor.on('*', (emitted) => { console.log(emitted); // Any emitted event }); ```
diff --git a/.changeset/big-ghosts-develop.md b/.changeset/big-ghosts-develop.md new file mode 100644 index 0000000000..1be8dbbe1b --- /dev/null +++ b/.changeset/big-ghosts-develop.md @@ -0,0 +1,11 @@ +--- +'xstate': patch +--- + +You can now use a wildcard to listen for _any_ emitted event from an actor: + +```ts +act...
1
1
1
[{"id": "G0", "claim": "Removing the `on` method from the `ActorRef` interface could easily be seen as a breaking change.", "category": "design", "verdict": "supported", "priority": "P1", "scope": "introduced"}]
null
statelyai__xstate__4932
statelyai/xstate
4,932
defect
e79d480c0183ad00ce0d5902f58a77526a08925e
273321c5d8e14b6931cc661d3a5a28550f16af2f
[core] Fix type issues with emitted events
Fixes #4931
diff --git a/.changeset/nervous-chicken-eat.md b/.changeset/nervous-chicken-eat.md new file mode 100644 index 0000000000..97f36c0655 --- /dev/null +++ b/.changeset/nervous-chicken-eat.md @@ -0,0 +1,5 @@ +--- +'xstate': patch +--- + +Actors with emitted events should no longer cause type issues: https://github.com/state...
6
5
0
[{"id": "G0", "claim": "The public `ref` field on Actor looks unused in any practical sense and appears to be a backwards-compat leftover that could be removed.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The unused type args (`infer _TEvent`...
null
statelyai__xstate__4935
statelyai/xstate
4,935
defect
2d77f14da8e1df9f744efce2a7abc1a64ffcd00a
1835497d18ec820409d4aab5cecbacaa99ba9433
[core] Add emit support for all actor logic creators
This PR adds support for emitting events from all actor logic types: **Promise actors** ```ts const logic = fromPromise(async ({ emit }) => { // ... emit({ type: 'emitted', msg: 'hello' }); // ... }); ``` **Transition actors** ```ts const logic = fromTransition((state, event, { emi...
diff --git a/.changeset/smooth-crabs-dress.md b/.changeset/smooth-crabs-dress.md new file mode 100644 index 0000000000..687af911a3 --- /dev/null +++ b/.changeset/smooth-crabs-dress.md @@ -0,0 +1,60 @@ +--- +'xstate': minor +--- + +All actor logic creators now support emitting events: + +**Promise actors** + +```ts +con...
2
2
1
[{"id": "G0", "claim": "Add a test that successfully emits from a rehydrated callback actor (create a machine with a callback actor, persist the root actor, rehydrate from the persisted snapshot, and verify the rehydrated actor can correctly use emit).", "category": "testing", "verdict": "supported", "priority": "P1", ...
null
statelyai__xstate__4979
statelyai/xstate
4,979
defect
8aa4c2b90c6a07a4678202181420b5ddd33edacf
6de31d371739edbdfaab4fcbf59574942b5ac302
[core] Strongly-typed meta keys
This PR introduces: - Internal types for computing state IDs from a state schema (the machine configuration) - Strongly-typing `snapshot.getMeta()` to use those state IDs as keys
diff --git a/packages/core/src/State.ts b/packages/core/src/State.ts index 78156a13a8..da9a6a4a7f 100644 --- a/packages/core/src/State.ts +++ b/packages/core/src/State.ts @@ -16,7 +16,9 @@ import type { Snapshot, ParameterizedObject, IsNever, - MetaObject + MetaObject, + StateSchema, + StateId } from './t...
7
6
0
[{"id": "G0", "claim": "The temporary `Test = Compute<StateId<...>>` type alias should be removed from packages/core/src/types.ts.", "category": "maintainability", "verdict": "supported", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "The test assertion should use the '(machine).a' key instead of '(ma...
null
statelyai__xstate__5011
statelyai/xstate
5,011
defect
eac555ec418dd988f22619685073e31d61766a7d
4272deaa94c6bc6014da9fbabe6d1631ae3d0974
[core] Fix `Actor<T>` not assignable to `ActorRef<T>` problem
There is a new type helper: `ActorRefFromLogic<TLogic>`. This type is a stricter form of `ActorRefFrom<TLogic>` that only accepts actor logic types. See https://github.com/statelyai/xstate/issues/4997 for more details.
diff --git a/packages/core/test/types.test.ts b/packages/core/test/types.test.ts index d9691411dd..4eee9c8ed5 100644 --- a/packages/core/test/types.test.ts +++ b/packages/core/test/types.test.ts @@ -25,7 +25,12 @@ import { stateIn, setup, toPromise, - UnknownActorRef + UnknownActorRef, + AnyActorLogic, + A...
1
1
1
[{"id": "G0", "claim": "In a generic class (class ActorThing<T extends AnyActorLogic>), the actor returned by createActor(actorLogic) is not assignable to ActorRefFrom<typeof actorLogic>, even though it is assignable at top level.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": "introduc...
null
statelyai__xstate__5034
statelyai/xstate
5,034
defect
12bde7a3ff47be6bb5a54b03282a77baf76c2bd6
5182a5febbea40e7c7e2e8d085ca41e7d7a8cf18
[core] Fix `EventFrom` and `ContextFrom`
Fixes #5031
diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 1f132dab3b..15aa4198ed 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -2467,6 +2467,22 @@ export type ToChildren<TActor extends ProvidedActor> = export type StateSchema = { id?: string; states?: Record<string,...
3
3
0
[{"id": "G0", "claim": "The test title 'EventFrom should work' should be renamed to 'EventFrom should work with a machine that has transitions defined on a state' to say what the test actually covers.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim"...
null
statelyai__xstate__5042
statelyai/xstate
5,042
defect
3e5424d7a4bd6dde63c2ada6b6a85f55ae42f7ee
804874f365f48de5b18a345dfbcfb5f1867260dd
feat(core): add signal option to waitFor
This PR adds a `signal?: AbortSignal` option to `WaitForOptions`, so that a call to `waitFor()` can be externally aborted.
diff --git a/packages/core/src/waitFor.ts b/packages/core/src/waitFor.ts index d125788d715..c4ddc490162 100644 --- a/packages/core/src/waitFor.ts +++ b/packages/core/src/waitFor.ts @@ -9,6 +9,9 @@ interface WaitForOptions { * @defaultValue Infinity */ timeout: number; + + /** A signal which stops waiting wh...
1
1
1
[{"id": "G0", "claim": "The abort listener should also be removed when the waitFor promise times out, not only in the dispose path.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": "introduced"}]
null
statelyai__xstate__5055
statelyai/xstate
5,055
defect
3e5424d7a4bd6dde63c2ada6b6a85f55ae42f7ee
10ed0484e8d3c4f36c125b2c1d7bfdd4770aba20
Required `input` when defined inside `types`
This PR updates the types to require `input` when defined inside `types/input` when using `useActor`, `useMachine`, and `useActorRef`. ## Rationale With the current types even if `types/input` is defined, when using hooks like `useActor` the `input` option [remains optional](https://stackblitz.com/edit/vitejs-vite-...
diff --git a/packages/core/src/createActor.ts b/packages/core/src/createActor.ts index 3ad250edcc3..afd4d26e901 100644 --- a/packages/core/src/createActor.ts +++ b/packages/core/src/createActor.ts @@ -746,7 +746,7 @@ export class Actor<TLogic extends AnyActorLogic> } } -type RequiredOptions<TLogic extends AnyActo...
6
5
2
[{"id": "G0", "claim": "The exported `RequiredOptions` type should be renamed to something more specific if it is going to be exported.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "useActorRef in @xstate/react and @xstate/vue should make `opti...
null
statelyai__xstate__5064
statelyai/xstate
5,064
defect
f91eb141211715d6a5bf1c0f328ebfd1ee8d3d3e
0bf2c928e593f887fcdbbfc7b2728a1c4519809c
[@xstate/store] Event emitter
You can now emit events from a store: ```ts import { createStore } from '@xstate/store'; const store = createStore({ context: { count: 0 }, on: { increment: (context, event, { emit }) => { emit({ type: 'incremented' }); return { count: context.count + 1 }; } } }); sto...
diff --git a/.changeset/silver-maps-grab.md b/.changeset/silver-maps-grab.md new file mode 100644 index 0000000000..3552069211 --- /dev/null +++ b/.changeset/silver-maps-grab.md @@ -0,0 +1,45 @@ +--- +'@xstate/store': minor +--- + +You can now emit events from a store: + +```ts +import { createStore } from '@xstate/sto...
4
4
3
[{"id": "G0", "claim": "The `setup` generic's `emitted` schema record should require zod-like values (`{ _output: unknown }`) so that mistakes like passing a plain object such as `{ not: 'zod' }` are caught by the type checker.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": "introduced"...
null
statelyai__xstate__5100
statelyai/xstate
5,100
defect
42304daf7ea47d2630788c04f7d6ace8f531b37b
3ff295d906eae63eb45be9765e880797d03a664c
[@xstate/solid] Fix context mutation with new values nested in arrays
Fix new array index value not being cloned before insertion into store - Fixes #5099 * [`packages/xstate-solid/src/createImmutable.ts`](diffhunk://#diff-189122ca05a9c2d9e0559f05565de61a9b74b5c74be087a09f71dd6970a4b564R56-L71): Refactored the `updateStore` function to deep clone new elements in the array, ensuring i...
diff --git a/.changeset/strong-keys-work.md b/.changeset/strong-keys-work.md new file mode 100644 index 0000000000..2ab9429c08 --- /dev/null +++ b/.changeset/strong-keys-work.md @@ -0,0 +1,5 @@ +--- +'@xstate/solid': patch +--- + +Deep clone values in new array indexes to prevent mutation of original machine context di...
1
1
0
[{"id": "G0", "claim": "The reviewer questioned whether deep cloning is needed only when inserting into a new array index, musing that it might only have to be done once upfront, and asked whether objects are deep cloned anywhere else during other types of updates, specifically how adding a new property to an object is...
null
statelyai__xstate__5200
statelyai/xstate
5,200
defect
5e05d5908093bfd3435dc2243e066e4e91b3ebc5
236c0e513b270e0a5d9fdcb418421727f7c18afd
[@xstate/store] Store select
Added selectors to @xstate/store that enable efficient state selection and subscription: - `store.select(selector)` function to create a "selector" entity where you can: - Get current value with `.get()` - Subscribe to changes with `.subscribe(callback)` - Only notify subscribers when selected value actuall...
diff --git a/.changeset/six-foxes-deny.md b/.changeset/six-foxes-deny.md new file mode 100644 index 0000000000..75e31ebdf2 --- /dev/null +++ b/.changeset/six-foxes-deny.md @@ -0,0 +1,37 @@ +--- +'@xstate/store': minor +--- + +Added selectors to @xstate/store that enable efficient state selection and subscription: + +- ...
3
3
1
[{"id": "G0", "claim": "The selector API should live on the store object as `store.select(...)` rather than being a standalone `select(store, selector)` function (raised as: why not `store.select(...)`?).", "category": "design", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "Th...
null
statelyai__xstate__5205
statelyai/xstate
5,205
defect
08ade1aad2eba4fbe086e0d1b41b4520147d2509
ed865c684e5099c1baeff94be800d3e870cfa9eb
[@xstate/store] `useStore()` and other improvements
There is now a `useStore()` hook that allows you to create a local component store from a config object. ```tsx import { useStore, useSelector } from '@xstate/store/react'; function Counter() { const store = useStore({ context: { name: 'David', count: 0 }, on: { inc: (ctx, ...
diff --git a/.changeset/modern-scissors-bow.md b/.changeset/modern-scissors-bow.md new file mode 100644 index 0000000000..0a1afc4ddd --- /dev/null +++ b/.changeset/modern-scissors-bow.md @@ -0,0 +1,29 @@ +--- +'@xstate/store': minor +--- + +Added `createStoreConfig` to create a store config from an object. This is an i...
3
3
0
[{"id": "G0", "claim": "The changeset's reusable-config example should instead show using a reusable hook for the two-component case.", "category": "design", "verdict": "supported", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "Perhaps createStoreCore should just accept the config object rather than ...
null
statelyai__xstate__5215
statelyai/xstate
5,215
defect
a7ed7f249fb36e4fbf1893b49a8235d684001e87
0aa9cef34d69287b2458c28c5dfba5c890b10a3f
[@xstate/store] Add `store.transition(…)` API
Added `store.transition(state, event)` method which is a pure function that returns the next state and effects for a given state and event as a tuple, without actually updating the store. This is useful for computing state changes before committing them, or controlling the execution of effects. Example: ```ts co...
diff --git a/.changeset/dry-walls-poke.md b/.changeset/dry-walls-poke.md new file mode 100644 index 0000000000..2743e357a4 --- /dev/null +++ b/.changeset/dry-walls-poke.md @@ -0,0 +1,14 @@ +--- +'@xstate/store': minor +--- + +Added `store.transition(state, event)` method that returns the next state and effects for a gi...
1
1
0
[{"id": "G0", "claim": "The `transition` method should be defined as a shorthand property (`transition,`) instead of wrapping it in a redundant arrow function.", "category": "maintainability", "verdict": "supported", "priority": "P3", "scope": "introduced"}]
null
statelyai__xstate__5230
statelyai/xstate
5,230
defect
5279ce6cddde03904c2807653fb355a0204704fe
00ff8a70527b5f72d1870bde2fe85a0899718805
[xstate/store] Fix types for emitting with no payload
The types for emitting events with no payload have been fixed so that the following code works: ```ts const store = createStore({ emits: { incremented: () => {} }, on: { inc: (ctx, ev, enq) => { // No payload is expected enq.emit.incremented(); } } }); ``` Previously, t...
diff --git a/.changeset/wild-shoes-eat.md b/.changeset/wild-shoes-eat.md new file mode 100644 index 0000000000..a7ff8601c3 --- /dev/null +++ b/.changeset/wild-shoes-eat.md @@ -0,0 +1,21 @@ +--- +'@xstate/store': patch +--- + +The types for emitting events with no payload have been fixed so that the following code works...
2
2
1
[{"id": "G0", "claim": "The test declares an emit callback whose payload type has all-optional fields (`_: { payload?: string }`) but does not pin down what arguments such an emit accepts, leaving the intended API for that case unspecified and untested.", "category": "design", "verdict": "supported", "priority": "P2", ...
null
statelyai__xstate__5247
statelyai/xstate
5,247
defect
93b7a12714390a3c13e6adcbae385217ddfd3ca4
fadc4f5353ce78fe9ccfb0dae4909c3cee93a9b4
[@xstate/store] Fix distributive event payload types
This PR fixes type inference for discriminated union event types in the `trigger` and `emit` object. Previously, using `Omit` with union types would incorrectly combine event types, breaking type inference for discriminated unions. This has been fixed by introducing a `DistributiveOmit` type that correctly preserves th...
diff --git a/.changeset/long-moons-trade.md b/.changeset/long-moons-trade.md new file mode 100644 index 0000000000..9ef0c0a94f --- /dev/null +++ b/.changeset/long-moons-trade.md @@ -0,0 +1,5 @@ +--- +'@xstate/store': patch +--- + +Fix type inference for discriminated union event types in the `trigger` and the `emit` ob...
1
1
1
[{"id": "G0", "claim": "In the trigger signature, the empty-object branch should return a no-arg function (() => void) instead of () => DistributiveOmit<E, 'type'>, since the IsEmptyObject check already establishes the payload has no properties.", "category": "correctness", "verdict": "supported", "priority": "P1", "sc...
null
statelyai__xstate__5266
statelyai/xstate
5,266
defect
a1adbc04a638bab0755decfc324d6d2cfb851d94
2eabc40b9c342fc2ff47a3353972d10f76e6f4d7
[@xstate/store] Async atoms
Added async atoms: ```ts const atom = createAsyncAtom(async () => { const response = await fetch(`/api/something`); return response.json(); }); atom.subscribe((state) => { // Status can be 'pending', 'fulfilled', or 'rejected' if (state.status === 'fulfilled') { console.log(state.data); } }...
diff --git a/.changeset/nine-starfishes-hunt.md b/.changeset/nine-starfishes-hunt.md new file mode 100644 index 0000000000..476d58628b --- /dev/null +++ b/.changeset/nine-starfishes-hunt.md @@ -0,0 +1,19 @@ +--- +'@xstate/store': minor +--- + +Added async atoms: + +```typescript +const atom = createAsyncAtom(async () =...
10
10
2
[{"id": "G0", "claim": "The rejection handler should be the second argument of .then() (a nit: that 'wraps' the minimal thing) so that only errors from getValue() are caught, not errors thrown by the then callback.", "category": "correctness", "verdict": "supported", "priority": "P3", "scope": "introduced"}, {"id": "G1...
null
statelyai__xstate__5269
statelyai/xstate
5,269
defect
a1adbc04a638bab0755decfc324d6d2cfb851d94
3cb71f8c24b563e276d123754e17471f267fca04
[core]: bugfix restoring historyValue | feature reviveHistoryValue
This is a fix for issue here: https://github.com/statelyai/xstate/issues/5178 featuring new helper functions to restore _StateNode class instances deeply.
diff --git a/.changeset/rude-keys-grab.md b/.changeset/rude-keys-grab.md new file mode 100644 index 00000000000..2af7865f06f --- /dev/null +++ b/.changeset/rude-keys-grab.md @@ -0,0 +1,5 @@ +--- +'xstate': patch +--- + +[core]: bugfix restoring historyValue | feature reviveHistoryValue diff --git a/packages/core/src/St...
2
2
1
[{"id": "G0", "claim": "The new tests should not use `require` and should focus on testing behaviors through public-facing APIs alone.", "category": "testing", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "reviveHistoryValue need not recurse because a historyValue is defined a...
null
statelyai__xstate__5299
statelyai/xstate
5,299
defect
acc285d3a928d9731b496f0632fce50ac1adc264
76f8bd87a84550e37521ccfb83f0b9c0927914bc
Actor select
The select function in @xstate/store is very useful. This PR adds a similar select function to the actor. This is to make the transition from @xstate/store to an xstate machine easier. I've used the same naming of types as in @xstate/store to make it consistent. I used the tests in @xstate/store as inspiration to wh...
diff --git a/.changeset/tough-brooms-grin.md b/.changeset/tough-brooms-grin.md new file mode 100644 index 0000000000..6ae4d29790 --- /dev/null +++ b/.changeset/tough-brooms-grin.md @@ -0,0 +1,5 @@ +--- +'xstate': minor +--- + +Add actor select function simliar to @xstate/store diff --git a/packages/core/src/createActor...
2
2
1
[{"id": "G0", "claim": "The `Selection<TSelected>` type alias added by this PR is unused and could probably be dropped.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The `TSnapshot` type parameter on `ActorRef.select` is unnecessary because `TS...
null
statelyai__xstate__5302
statelyai/xstate
5,302
defect
f10575ac6de6fdcbce143e3acf1de968ccfb8966
c737af8f771cd43a505034d6c2544c751330fabf
[@xstate/store] Add `useAtom(atom)` + fix vitest config
This PR adds the `useAtom` hook for reading the value of an atom or selecting a value from the atom. It is meant for the common use-case where the entire value of the atom (usually granular data) is needed. ```tsx const atom = createAtom(0); const Component = () => { const count = useAtom(atom); retur...
diff --git a/.changeset/fresh-mails-shake.md b/.changeset/fresh-mails-shake.md new file mode 100644 index 0000000000..03dbe72ec5 --- /dev/null +++ b/.changeset/fresh-mails-shake.md @@ -0,0 +1,32 @@ +--- +'@xstate/store': minor +--- + +The `useAtom` hook is now available for reading the value of an atom or selecting a v...
2
2
1
[{"id": "G0", "claim": "The optional `compare` parameter of `useAtom`'s selector overload should be typed `(a: T, b: T) => boolean` instead of `(a: T | undefined, b: T) => boolean`, since the first selected value never has a previous value to compare against.", "category": "correctness", "verdict": "supported", "priori...
null
statelyai__xstate__5305
statelyai/xstate
5,305
defect
15fb9690631868480f30f50578a6a42d2f65769d
ced1f99eec96341298c0693d938464e4e1cca5e6
[@xstate/store] Undo redo
Added undo/redo functionality to XState Store via the `undoRedo` higher-order store logic: - Adds `undo` and `redo` events to stores - Supports grouping related events into transactions using `transactionId` - Maintains event history for precise state reconstruction - Automatically clears redo stack when new ...
diff --git a/.changeset/warm-tips-cut.md b/.changeset/warm-tips-cut.md new file mode 100644 index 0000000000..12e21250c6 --- /dev/null +++ b/.changeset/warm-tips-cut.md @@ -0,0 +1,39 @@ +--- +'@xstate/store': minor +--- + +Added undo/redo functionality to XState Store via the `undoRedo` higher-order store logic: + +- A...
1
1
0
[{"id": "G0", "claim": "The duplicated pop/unshift/push block in undoRedo's undo branch could be squeezed into a single loop with a break condition.", "category": "maintainability", "verdict": "supported", "priority": "P3", "scope": "introduced"}]
null
statelyai__xstate__5307
statelyai/xstate
5,307
defect
15fb9690631868480f30f50578a6a42d2f65769d
48955a2bc736abd96e5b22525babea067e083fdc
[@xstate/store] Fix `useAtom` to accept `ReadonlyAtom`
This PR fixes the types for `useAtom` to accept `ReadonlyAtom` values. Fixes #5306
diff --git a/.changeset/fine-apes-switch.md b/.changeset/fine-apes-switch.md new file mode 100644 index 0000000000..d95f271c59 --- /dev/null +++ b/.changeset/fine-apes-switch.md @@ -0,0 +1,7 @@ +--- +'@xstate/store': patch +--- + +Fix the types for `useAtom` to accept `ReadonlyAtom` values. + +See #5306 diff --git a/pa...
1
1
0
[{"id": "G0", "claim": "Remove the redundant \"See #5306\" line from the changeset entry, since the entry is pretty much self-explanatory without it.", "category": "documentation", "verdict": "supported", "priority": "P3", "scope": "introduced"}]
null
statelyai__xstate__5323
statelyai/xstate
5,323
defect
dcac5b2ae6baa1ca89e7fc3e0bb63449772911ab
5eda50b381d016e637bb8fcba8b923dd99f43e90
[@xstate/store] Refactor store logic to improve context updates and snapshot handling
- Removed unused setter function and associated recipe parameter. - Updated transition logic to prevent unnecessary updates when the snapshot remains unchanged. - Enhanced tests to verify behavior of effect-only and emit-only transitions, ensuring no updates trigger when the snapshot is the same.
diff --git a/.changeset/proud-bananas-do.md b/.changeset/proud-bananas-do.md new file mode 100644 index 0000000000..a719a87afa --- /dev/null +++ b/.changeset/proud-bananas-do.md @@ -0,0 +1,30 @@ +--- +'@xstate/store': minor +--- + +Added support for effect-only transitions that don't trigger state updates. Now, when a ...
5
3
1
[{"id": "G0", "claim": "The new early return in receive() skips emitting '@xstate.snapshot' inspection events for events that leave the snapshot unchanged, diverging from XState's behavior where a snapshot inspection event is emitted for every event.", "category": "correctness", "verdict": "supported", "priority": "P1"...
null
statelyai__xstate__5329
statelyai/xstate
5,329
defect
dcac5b2ae6baa1ca89e7fc3e0bb63449772911ab
90956da2b28f12e8bc90e45f9b1f590e61a69079
[@xstate/store] Fix `createAsyncAtom` propagation
Fix: `createAsyncAtom` now properly propagates status updates after promise resolves/rejects. Fixes #5327
diff --git a/.changeset/dirty-donuts-clean.md b/.changeset/dirty-donuts-clean.md new file mode 100644 index 0000000000..6e2285b52b --- /dev/null +++ b/.changeset/dirty-donuts-clean.md @@ -0,0 +1,5 @@ +--- +'@xstate/store': patch +--- + +Fix: `createAsyncAtom` now properly propagates status updates after promise resolve...
2
1
0
[{"id": "G0", "claim": "The new test 'should work with the exact example from the bug report' is redundant because the first new test already covers exactly the same scenario, so it should be removed.", "category": "testing", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "Asks ...
null
statelyai__xstate__5347
statelyai/xstate
5,347
defect
12b443746488fa1f1153e73f381e5c40ceda3563
76f229e2377448bfa1edd2500947e4a6b8484a16
[@xstate/store] Fix TS error localization
Fix TS error localization in `createStore(…)` overloads Previously, TS errors in transitions would appear on the `createStore` call itself rather than on the specific transition. This was caused by the 3rd overload (for `StoreLogic`) interfering with overload resolution. ```ts createStore({ context: {...
diff --git a/.changeset/odd-ravens-fold.md b/.changeset/odd-ravens-fold.md new file mode 100644 index 0000000000..15ce5e675e --- /dev/null +++ b/.changeset/odd-ravens-fold.md @@ -0,0 +1,7 @@ +--- +'@xstate/store': patch +--- + +Fix TypeScript error localization in `createStore(…)` overloads + +Previously, TS errors in ...
2
2
0
[{"id": "G0", "claim": "The extra sentence in the changeset explaining that the mislocalization was caused by the 3rd overload interfering with overload resolution is probably not important for the CHANGELOG and should be dropped, keeping only the first sentence.", "category": "documentation", "verdict": "supported", "...
null
statelyai__xstate__5351
statelyai/xstate
5,351
defect
adc3183096933a6ee88da5a8d4d474e9f5c77a39
21d416593d5c7c84ba4e748b8d754b7ff1b1c189
[core] Fix emit callback error crashing actor
Fix: Emit callback errors no longer crash the actor ```ts actor.on('event', () => { // Will no longer crash the actor throw new Error('oops'); }); ```
diff --git a/.changeset/polite-bugs-lose.md b/.changeset/polite-bugs-lose.md new file mode 100644 index 0000000000..10ae78d9c1 --- /dev/null +++ b/.changeset/polite-bugs-lose.md @@ -0,0 +1,12 @@ +--- +'xstate': patch +--- + +Fix: Emit callback errors no longer crash the actor + +```ts +actor.on('event', () => { + // W...
1
1
0
[{"id": "G0", "claim": "The emit-callback-error tests added in emit.test.ts should be moved to packages/core/test/errors.test.ts.", "category": "testing", "verdict": "supported", "priority": "P2", "scope": "introduced"}]
null
statelyai__xstate__5364
statelyai/xstate
5,364
defect
7dddf177a61e86efec88f39c6d12fb80b9a4335f
704efe30b282cd9baef0cf9d827ceea178e100fa
[core] Add `.createStateConfig(…)` to machine setup
Added `.createStateConfig(…)` to the setup API. This makes it possible to create state configs that are strongly typed and modular. ```ts const lightMachineSetup = setup({ // ... }); const green = lightMachineSetup.createStateConfig({ //... }); const yellow = lightMachineSetup.createStateConfig({ /...
diff --git a/.changeset/four-horses-shine.md b/.changeset/four-horses-shine.md new file mode 100644 index 0000000000..50ac6f6d77 --- /dev/null +++ b/.changeset/four-horses-shine.md @@ -0,0 +1,32 @@ +--- +'xstate': minor +--- + +Added `.createStateConfig(…)` to the setup API. This makes it possible to create state confi...
2
2
1
[{"id": "G0", "claim": "createStateConfig should be made generic so the returned config has a strict/strong shape, allowing state.matches and similar to keep producing specific types.", "category": "design", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The NoInfer wrapper on ...
null
statelyai__xstate__5367
statelyai/xstate
5,367
defect
b41308885de5796cec0082b786a3a45f6d05c76b
23dda3076f319c3ee338441ae314caf943d5a672
[core] Add `setup().createAction(…)`
Add `setup().createAction(…)` helper for type-safe custom actions. Allow wrapping built-ins with `createAction` (e.g. `createAction(assign(...))` or `createAction(raise(...))`). ```ts const machineSetup = setup({ types: {} as { context: { count: number; }; events: { type: 'inc'; value: num...
diff --git a/.changeset/dry-cows-stare.md b/.changeset/dry-cows-stare.md new file mode 100644 index 0000000000..4a539c3fdc --- /dev/null +++ b/.changeset/dry-cows-stare.md @@ -0,0 +1,30 @@ +--- +'xstate': minor +--- + +Add `setup().createAction(…)` helper for type-safe custom actions. +Allow wrapping built-ins with `cr...
2
2
0
[{"id": "G0", "claim": "The changeset is outdated given the latest changes to this PR and needs updating.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The type-bound forwardTo and sendParent helpers should probably be removed from setup(); they ...
null
statelyai__xstate__5383
statelyai/xstate
5,383
defect
c9c726d1ffacb0b8ae8ace15c65dca3983c496ef
1ef13abab768a7c341627b3aacb82c1af84e772b
[@xstate/store] Fix event type overwriting
- Fix: `trigger` methods now work when passed directly as event handlers, even for events with no payload. Before, the React `event.type` would overwrite the intended event type.
diff --git a/.changeset/kind-regions-mate.md b/.changeset/kind-regions-mate.md new file mode 100644 index 0000000000..e355123c8b --- /dev/null +++ b/.changeset/kind-regions-mate.md @@ -0,0 +1,5 @@ +--- +'@xstate/store': patch +--- + +- Fix: `trigger` methods now work when passed directly as event handlers, even for eve...
1
1
0
[{"id": "G0", "claim": "The changeset entry should be a plain one-line description without a leading markdown bullet, per the suggested wording.", "category": "maintainability", "verdict": "supported", "priority": "P3", "scope": "introduced"}]
null
statelyai__xstate__5387
statelyai/xstate
5,387
defect
cd9af1938ed4d8495cb0de0db9958057a06d1e09
8ac744f7a7e5c41b4fbbde76fc78ba7e66d279a0
Get list of currently running actors in system
This PR adds `system.getAll` that returns a record of running actors within the system by their system id. This is very helpful for a tool to visualize active actors in a system given the system reference.
diff --git a/.changeset/nice-teeth-lead.md b/.changeset/nice-teeth-lead.md new file mode 100644 index 0000000000..5389a69e6c --- /dev/null +++ b/.changeset/nice-teeth-lead.md @@ -0,0 +1,21 @@ +--- +'xstate': minor +--- + +Adds `system.getRunningActors` that returns a record of running actors within the system by their ...
3
3
2
[{"id": "G0", "claim": "The new method `getRunningActors` returns all registered actors, not only running ones, so it should be renamed to `getAll`.", "category": "design", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The declared return type `T['actors']` of `getAll` overcla...
null
statelyai__xstate__5393
statelyai/xstate
5,393
defect
cf9bbee4416a4e397b90927f2d498a4bdd4214dd
31db20d3b152aa73be6a540a2bcca560f14e03fd
[@xstate/store] Skip events from undo/redo
Add `skipEvent` option to `undoRedo()` to exclude certain events from undo/redo history. ```ts const store = createStore( undoRedo( { context: { count: 0 }, on: { inc: (ctx) => ({ count: ctx.count + 1 }), log: (ctx) => ctx // No state change } }, { ski...
diff --git a/.changeset/tangy-spies-study.md b/.changeset/tangy-spies-study.md new file mode 100644 index 0000000000..4bb833b6f0 --- /dev/null +++ b/.changeset/tangy-spies-study.md @@ -0,0 +1,22 @@ +--- +'@xstate/store': minor +--- + +Add `skipEvents` option to `undoRedo()` to exclude certain events from undo/redo hist...
4
3
1
[{"id": "G0", "claim": "The undo empty-history guard should test snapshot.events.length, and the events/undoStack .slice() calls should be moved below that check so nothing is copied when undo is a no-op.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim"...
null
statelyai__xstate__5406
statelyai/xstate
5,406
defect
462e0b222d8a455c48e976cc88d41bdacba86b48
8999adb35916fc86e9c03e34cc93e77fd8a52206
[core] Add `getNextTransitions(state)`
Add `getNextTransitions(state)` utility to get all transitions available from current `state`. ```ts import { getNextTransitions } from 'xstate'; // ... const state = actor.getSnapshot(); const transitions = getNextTransitions(state); transitions.forEach((t) => { console.log(`Event: ${t.eventType}, Sou...
diff --git a/.changeset/slow-horses-stop.md b/.changeset/slow-horses-stop.md new file mode 100644 index 0000000000..c02352c26c --- /dev/null +++ b/.changeset/slow-horses-stop.md @@ -0,0 +1,18 @@ +--- +'xstate': minor +--- + +Add `getPotentialTransitions(state)` utility to get all transitions available from current `sta...
3
2
1
[{"id": "G0", "claim": "The new export should be reconciled with the similar `__unsafe_getAllOwnEventDescriptors` utility — either maintain that naming scheme or make that one \"safe\".", "category": "design", "verdict": "uncertain", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "The order of transiti...
null
statelyai__xstate__5414
statelyai/xstate
5,414
defect
45d97de0a174b274aea69d02e27a59b224c2b855
bfa86efd966041af35e32456c281c7a874979c83
[@xstate/store] Computed atom previous value access
Computed atoms can now access their previous value via an optional second parameter: ```ts const count = createAtom(1); const double = createAtom<number>((_, prev) => count.get() + (prev ?? 0)); ```
diff --git a/.changeset/whole-days-design.md b/.changeset/whole-days-design.md new file mode 100644 index 0000000000..a3a3b11703 --- /dev/null +++ b/.changeset/whole-days-design.md @@ -0,0 +1,10 @@ +--- +'@xstate/store': minor +--- + +Computed atoms can now access their previous value via an optional second parameter: ...
2
1
1
[{"id": "G0", "claim": "The changeset example should read the count atom via read(count) instead of count.get() so the read atom is tracked properly.", "category": "design", "verdict": "opposed", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "Deprecating the first parameter of the computed getter woul...
null
statelyai__xstate__5422
statelyai/xstate
5,422
defect
2eb82745dbdf4ac8dfbcc3c426ed4d81c732844b
b1d7e801c42829677d48007b75fe03b453ff0b16
[core] Add support for partial event descriptors in `assertEvent(…)`
Add partial descriptor support to `assertEvent(…)` ```ts // Matches any event with a type that starts with `FEEDBACK.` assertEvent(event, 'FEEDBACK.*'); ```
diff --git a/.changeset/shy-worms-sniff.md b/.changeset/shy-worms-sniff.md new file mode 100644 index 0000000000..b61fbff9f8 --- /dev/null +++ b/.changeset/shy-worms-sniff.md @@ -0,0 +1,10 @@ +--- +'xstate': minor +--- + +Add partial descriptor support to `assertEvent(…)` + +```ts +// Matches any event with a type that...
2
2
0
[{"id": "G0", "claim": "The wildcard/partial descriptor matching logic added in assertEvent duplicates a good chunk of what getCandidates already does, and it would be great if that logic were shared between both places.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, ...
null