Pending actions and failures
API
| Hook | Contract |
|---|---|
usePending() |
{ pending: PendingView | null; deferred: string[] }. PendingView is { id; kind: "decision" | "undo"; predicted: boolean; historyId? }. deferred lists ids whose result the connection lost. |
useFailures() |
{ failures: CoreFailure[]; dismiss: (id: string) => void }. |
Decisions on their way
usePending().pending is the one decision or undo on its way. When its predicted is true, the board already shows the result. When it is false, the step draws randomness or reveals: show that the move is on its way, and the board updates when Boardweaver answers.
Failures
useFailures().failures keeps every failed step and refused decision until the client calls dismiss(id). Show each one and let the player dismiss it. When Boardweaver refuses a decision, its steps that are still legal come back as the draft, and the player confirms again.
An offer's label and the reason the game logic refused a step (a refusal of GAME, which a REFUSED failure and a SERVER_REFUSED one can both carry) are messages from your catalogs. useMessageText() gives the function that writes one as text in the language the frame shows your game in, each player it names by name:
const text = useMessageText();
const refusal = "refusal" in failure.reason ? failure.reason.refusal : null;
const why = refusal?.refused === "GAME" ? text(refusal.reason) : null;