# Request lifecycle

> Understand URL state, partial reloads, cancellation, and result reconciliation.

Source: https://docs.inertiax.dev/table/guide/request-lifecycle/

When a user changes a table control, InertiaX updates local state, requests the matching data, and accepts the latest result. Your Laravel definition is rebuilt for each request.

## One interaction

1. A control sends the change through the table controller.
2. InertiaX validates state and schedules the table’s URL update.
3. The Inertia adapter partially reloads the named prop.
4. Laravel validates state, then applies built-in query operations or calls the custom source’s `fetch()` with the complete request. It serializes the returned rows into cells.
5. The frontend accepts the latest response and reconciles selection and visibility.

## URL and local state

| State                                     | Persistence and requests                                       |
| ----------------------------------------- | -------------------------------------------------------------- |
| Page, page size, sorting, filters, search | Namespaced URL parameters; changes request data                |
| Selection                                 | Local IDs for the current result page; no URL write or request |
| Column visibility                         | Local presentation state; no URL write or request              |

Parameters use the table ID as their namespace. Values equal to structural defaults are omitted, and unrelated query parameters are preserved. Browser history navigation to valid table parameters updates state and requests the result immediately.

The Inertia adapter batches URL changes made in the same JavaScript turn and skips unchanged URLs. Controller state updates immediately; browser URL publication can wait briefly during heavy activity. Read the controller’s state when you need a command’s result synchronously. Pending URL changes are published before Inertia visits. A native `router.reload()` includes pending changes from connected tables; explicit reload `data` still overrides the request’s URL parameters. Back and Forward restore the last published URL.

Temporarily hiding a table with React Activity retains its unpublished changes for reconnection. Navigating to another history entry supersedes those changes.

## Request timing

Search and applied filter changes share a 300 ms debounce. State updates immediately; repeated changes during the delay produce one request for the latest state. Override it with `<AppTable prop="users" debounceMs={250} />`; use `0` for immediate dispatch.

Page, page-size, sorting, browser-location, refresh, and retry requests have no debounce. Search, filters, page-size, and sorting changes reset pagination to page 1.

With the default browser integration, sustained rapid interactions can briefly delay native reload startup to leave room for browser history updates. Tables on the same page share this limit. Controller state continues to update while a reload waits; a newer change cancels queued work. Queued browser work also waits while a native page navigation is pending and is discarded if it belongs to the previous navigation.

A newer request supersedes scheduled or in-flight work. The adapter cancels the old Inertia reload when a cancellation token is available. Stale successes and errors are ignored even when the transport still finishes. Only accepted requests emit success or error events.

## Result reconciliation

A server result prunes selected IDs that are absent from the current result and enforces the current selection mode. Column visibility survives while the definition is unchanged; changes to columns, filters, capabilities, or row key reset it to the new defaults.

These reconciliations emit `stateChange` with `source: 'result'`, not separate `selectionChange` or `columnVisibilityChange` events. See [Controller & events](https://docs.inertiax.dev/table/guide/controller-events/).

## Status, refresh, and retry

| Status          | Meaning                                                           |
| --------------- | ----------------------------------------------------------------- |
| `idle`          | No request scheduled or sent                                      |
| `scheduled`     | Waiting for the debounce delay                                    |
| `pending`       | Request in progress                                               |
| `success`       | Latest accepted request succeeded                                 |
| `error`         | Latest accepted request failed; retry is available                |
| `problem`       | Table URL state needs correction; explicit reset may be available |
| `externalError` | An external page-envelope update could not be applied             |
| `disposed`      | Session ended                                                     |

The built-in UI handles loading and request errors. `refresh()` requests the current state. `retry()` is available only in `error` and replays the failed request with a new identity, including a failed explicit reset. Invalid table URL state produces a table-local `problem`; use the [reset control or `resetProblem()`](https://docs.inertiax.dev/table/guide/url-recovery/) when reset is available. For `externalError`, correct the prop or integration input; retry cannot repair it.

Hide the default refresh control with `UsersTable::make('users')->refreshButton(false)`. Custom UI can use [React hooks and the controller](https://docs.inertiax.dev/table/guide/controller-events/#read-reactive-state).

## Package responsibilities

| Package                    | Responsibility                                                           |
| -------------------------- | ------------------------------------------------------------------------ |
| `inertiax/laravel`         | Shared Laravel factory dispatch; installed by component packages         |
| `inertiax/laravel-table`   | Table definitions, queries, state validation, and response serialization |
| `@inertiax/protocol`       | Common JSON types and schema validation primitives                       |
| `@inertiax/table-protocol` | Serialized schema and runtime validation                                 |
| `@inertiax/core`           | Component-neutral catalogs, pipelines, and diagnostics                   |
| `@inertiax/table-core`     | Client state, requests, controllers, and result reconciliation           |
| `@inertiax/react`          | App-owned services read by your application binding                      |
| `@inertiax/react-table`    | Table UI and customization                                               |
| `@inertiax/react-inertia`  | Inertia props, partial reloads, and browser location                     |

For data formats, see [Protocol reference](https://docs.inertiax.dev/table/protocol/).
