# Show activity (https://effetch-query.monarcode.dev/docs/mutations/activity)

A mutation's state belongs to the component that runs it, but a saving
notice or a progress bar often sits somewhere else in the app. To show
what's saving anywhere, read the client's activity instead. This page
shows how to list one mutation's runs, and how to count everything in
progress.

The examples import `toggle-todo.ts` from
[Getting started](https://effetch-query.monarcode.dev/docs/getting-started).

## List the runs of one mutation

`useMutationState` lists a mutation's runs in progress, oldest first,
with their variables, whichever component or Effect started them:

```tsx
import { useMutationState } from "@monarcode/effetch-query/react";

import { toggleTodo } from "./toggle-todo.js";

export function SavingNotice() {
  const saving = useMutationState(toggleTodo);

  return saving.length === 0 ? null : (
    <p role="status">
      Saving {saving.map((run) => `#${run.variables.params.id}`).join(", ")}
    </p>
  );
}
```

Each entry is a `UseMutationStateRun`, with the `variables` the run was
started with and its `result`, a waiting `Initial`. A run is listed from
when it starts until it settles, however it ends. Two kinds of run wait
before they start, and are listed differently:

- A run `concurrent: "queue"` holds back is listed while it waits.
- A run that `concurrent: false` makes wait for the run it replaces to
  roll back is listed after that's done.

## Count fetches and runs

`useIsFetching` counts the queries fetching on the provider's client, and
`useIsMutating` the mutation runs in progress. Together they drive an
app-wide progress bar:

```tsx
import { useIsFetching, useIsMutating } from "@monarcode/effetch-query/react";

export function ProgressBar() {
  const busy = useIsFetching() + useIsMutating() > 0;

  return <div role="progressbar" aria-label="Loading" hidden={!busy} />;
}
```

Both count background refetches, and runs that any component or
`Mutation.run` started. Pass a target to count fewer:
`useIsFetching(["todos"])` counts the todos queries, and
`useIsMutating(toggleTodo)` the runs of one mutation.

A server render counts nothing in progress, and so does the first render
as the page hydrates, so the markup matches; the counts show right after.
All three hooks throw a `MissingQueryProviderError` outside a
`QueryProvider`.

## What's next

- [Optimistic updates](https://effetch-query.monarcode.dev/docs/mutations/optimistic): show the change
  itself, not only that something is saving.
- [When runs overlap](https://effetch-query.monarcode.dev/docs/mutations/run#when-runs-overlap): how
  `"queue"` and `false` decide when a run starts.
- [Mutation options](https://effetch-query.monarcode.dev/docs/mutations/options): every option a mutation
  takes.