Repository navigation
Action Separation And Registry
github-actions[bot] edited this page Nov 20, 2026
·
1 revision
abeta-dev/kmp isolates UI rendering from action execution using wire descriptors (ActionRef / ActionTrigger) in Layer 1 and an Open/Closed action engine (action-engine) in Layer 2.
-
Server emits
ActionTrigger(bff/pkg/sdui/actions) -> deserialized asActionRef(id,type,payload,validations,secondary_actions) insdui-contracts. -
Atom emits
ActionRefviaonAction: (ActionRef) -> Unit(attached toon_click,on_change,on_value_change,on_submit,on_increment,on_decrement) without interpretingtypeorpayload. -
Orchestrator (
LayoutControllerorWatchCompanionController) forwardsActionReftoDefaultActionDispatcher.dispatch(actionRef, context). -
Dispatcher pipeline:
- Guards recursion depth (
DEFAULT_MAX_DEPTH = 16). - Runs
ActionValidator(DefaultActionValidator) overActionRef.validations([{field_id, rule, value, message}]). - Decodes
ActionRef.payloadviaActionDecoderRegistry(BuiltInActionDecoders). - Executes the matching
ActionHandlerfromActionRegistry(BuiltInActionHandlers) or expandsBatchPayload. - Dispatches follow-up actions (
ApiCallResult.followUpActions,CallApiPayload.onError) andsecondary_actions.
- Guards recursion depth (
-
Layer 3 Host & Bridge Handling (
sdui-layout,watch-companion):-
PlatformBridgeOutcomeExecutorroutesClipboardCopyRequested,OpenUrlRequested,ShareRequested,PermissionRequested(onGranted/onDeniedfollow-ups), andBiometricAuthRequested(onAuthenticated/onFailedfollow-ups) toPlatformBridgeBundle(coreOS ports). -
OverlayRequestedsupportsOverlayPresentation("dialog"->AlertDialogor"bottom_sheet"->ModalBottomSheetinSduiOverlays.kt). -
FeedbackTriggeredroutesFeedbackEffect.CART_BOUNCEtoFloatingCartDockHost,FeedbackEffect.CELEBRATIONtoUiCelebrationOverlay(dismissed viaLayoutController.dismissFeedback()),FeedbackEffect.SHAKE_ERRORtoerrorShakeSequence/errorShakeTargetId(drivingModifier.shakeOnError), and triggersHapticEnginefeedback. - Failed
call_apiactions due to offline or transient network failures are queued byOfflineActionCoordinator(OfflineMutationQueue) for replay viaLayoutController.flushOfflineActions().
-
| Action Type | Payload Class (action-engine) |
Outcome (ActionOutcome) |
|---|---|---|
navigate |
NavigatePayload |
NavigationRequested |
back_press |
BackPressPayload |
BackRequested |
open_dialog |
OpenDialogPayload (OverlayPresentation) |
OverlayRequested |
dismiss_overlay |
DismissOverlayPayload |
OverlayDismissed |
show_toast |
ShowToastPayload |
ToastRequested |
call_api |
CallApiPayload |
ApiCallResult |
save_state |
SaveStatePayload |
StateMutated |
delete_state |
DeleteStatePayload |
StateMutated |
track_event |
TrackEventPayload |
TrackingRequested |
refresh_page |
RefreshPagePayload |
RefreshRequested |
copy_to_clipboard |
CopyToClipboardPayload |
ClipboardCopyRequested |
update_snippets |
UpdateSnippetsPayload |
SnippetsUpdated |
batch |
BatchPayload |
Aggregated child outcomes |
trigger_feedback |
TriggerFeedbackPayload (FeedbackEffect) |
FeedbackTriggered |
open_url |
OpenUrlPayload |
OpenUrlRequested |
share |
SharePayload |
ShareRequested |
request_permission |
RequestPermissionPayload (OsPermissionKind) |
PermissionRequested |
biometric_auth |
BiometricAuthPayload |
BiometricAuthRequested |
-
Define Payload (
@Serializableimplementing open marker interfaceActionPayload):@Serializable data class RateOrderPayload( val orderId: String, val stars: Int, ) : ActionPayload
-
Register Decoder in
ActionDecoderRegistry:val decoders = BuiltInActionDecoders.createDefaultRegistry().toBuilder() .register("rate_order", kotlinxActionDecoder<RateOrderPayload>()) .build()
-
Register Handler in
ActionRegistry:val handlers = BuiltInActionHandlers.createDefaultRegistry(apiExecutor).toBuilder() .register<RateOrderPayload> { payload, _ -> AppResult.Success(ActionOutcome.ToastRequested("Rated ${payload.orderId}: ${payload.stars}★")) } .build()
Notice zero changes are required in design-tokens, sdui-contracts, ui-atoms, or DefaultActionDispatcher.