# Navigation Actions Actions describe non-navigation effects that a user can trigger: send a message, like a post, submit a payment, delete an item. They live in `navigation.declaration.ts` alongside routes and transitions, attached to `uiStates[].actions[]`. ## When to Use an Action | Use `transitions` | Use `actions` | |---|---| | The visible route/UI state changes. | Data changes while the current route may stay the same. | | Tab switch, dialog open, drawer close. | Send, delete, like, follow, save, submit. | Decision rules for ambiguous cases: - **Navigation + side effect on the same tap** → still a `transition`. The URL changes, so it must be a transition; the side effect is observed downstream. - **"Submit then back" (确定 / 完成 / 发表)** → model as `action` with `behavior: 'submit'`. The `onTrigger` performs the side effect, then calls `back()` to close. **Do not** model it as a transition with a hardcoded `to` — that pollutes the graph with a misleading return target. - **Pure back / cancel / close overlay** → use `bindBack()` (`data-trigger="system.back"`). **Do not** declare a transition for it, and **do not** assign it an actionId. ## Action declaration Actions are objects on a `uiState`'s `actions[]`. The full grammar lives in [declaration.md → Actions](declaration.md#actions); this file is the rules reference. ### Required fields | Field | Required | Notes | |---|---|---| | `id` | yes | Must satisfy the ActionId grammar (below). Globally unique within the app. | | `label` | yes | Human-readable Chinese label for graph viewer + task generation. | | `behavior` | yes | `'toggle'` / `'select'` / `'input'` / `'submit'` / `'other'`. Drives DOM tagging and CI validation. | | `scope` | optional | `'item'` for per-list-item actions. Omit for page-scope. | | `paramsSchema` | conditional | Required for `behavior='input'`, `scope='item'`, and any place callers rely on params. See validation rules below. | | `effects` | optional | `ActionEffect[]` — declarative `localState.open` / `localState.close` annotations. Does not generate edges; used for documentation and Agent training metadata. | | `condition` | optional | Data-mode `StateCondition` filtering action visibility. | ## ActionId grammar (hard rules) - **Regex**: `^[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+$` - **Minimum 3 segments**: `..` (recommended `...`). - **No `-` or `_`** — only letters, digits, and dots. CamelCase within a segment is fine. - **App-internal global uniqueness**: every action id must be unique across the entire app's declaration. - **`scope='item'` actions** should include `.item.` in the id: `..item.`. ### Verb suffix by behavior The verb segment is fixed by the action's behavior: | Behavior | Verb suffix | Example | |---|---|---| | `toggle` | `.toggle` | `fastPay.enabled.toggle` | | `select` | `.select.