Skip to content

Intents, flows & manager

This chapter covers what the UI asks for (OmegaIntent), who coordinates (OmegaFlow), and who routes work (OmegaFlowManager).


OmegaIntent

An intent is a named request with optional payload.

  1. Enum + optional DTOOmegaIntent.fromName<YourDto>(AppIntent.someCase, payload: dto) (static method). The generic YourDto checks the payload at compile time when you pass it.
  2. One object = wire + data — implement OmegaTypedIntent (same name as the matching AppIntent / module intent wire). UI calls flowManager.handleTypedIntent(myTypedIntent); flows read ctx.intent?.typedPayloadAs<MyTypedIntent>().

The UI (or tests) send intents through flowManager.handleIntent(…) or flowManager.handleTypedIntent(…) — the manager forwards to every flow in OmegaFlowState.running (see example/lib/auth/ui/auth_page.dart).


OmegaFlow

Subclass OmegaFlow, pass super(id: …), and implement:

  • onIntent — react to intents routed while this flow is running (login submit, refresh, …).
  • onEvent — react to channel events (often emitted by agents).

Emit expressions for UI state via emitExpression(type, payload) and drive navigation by emitting the same navigation events / intents the OmegaNavigator listens for (see Navigation & routes).

Lifecycle: idlerunning (via activate / switchTo) → paused / sleeping / ended. Only running flows receive intents in the default routing.


OmegaFlowManager

MethodUse
registerFlowRegister once at bootstrap.
activate(id)Add a flow to the running set (multi-flow).
switchTo(id)Single “main” flow: activates one and pauses others.
handleIntentEntry point from UI with a built OmegaIntent.
handleTypedIntentSame, but argument implements OmegaTypedIntent — wire + payload are one object (API).
wireNavigatorCalled by OmegaRuntime.bootstrap — connects navigation traffic on the channel.

Lightweight handlers (optional)

For small features you can register registerIntentHandler, Omega.handle, OmegaIntentReducer, or OmegaIntentHandlerPipeline via OmegaConfig.intentHandlerRegistrars — handlers run before intents reach running flows; consumeIntent: true skips flow delivery.


UI rule of thumb

Widgets emit intents and listen to expressions (or OmegaFlowExpressionBuilder). They do not call repositories or imperative services for feature coordination — that belongs in flows and agents.


Full example

Walk through example/lib/auth/auth_flow.dart, auth_page.dart, and omega_setup.dart on GitHub.


Next