Skip to content

Phase 11.2.2 - Bounded Widget-Local State Infrastructure - #132

Merged
pcharbon70 merged 1 commit into
mainfrom
phase-11.2.2-widget-local-state
Apr 18, 2026
Merged

Phase 11.2.2 - Bounded Widget-Local State Infrastructure#132
pcharbon70 merged 1 commit into
mainfrom
phase-11.2.2-widget-local-state

Conversation

@pcharbon70

Copy link
Copy Markdown
Collaborator

Summary

Implements the bounded widget-local state infrastructure for Phase 11.2.2. This allows widget components to own bounded local UI lifecycle and ephemeral state while remaining subordinate to server-authoritative screen or application state.

Added Functions:

Runtime.State

  • widget_local_state/2 - Get widget-local state by widget identity key
  • put_widget_local_state/3 - Set widget-local state for a widget
  • update_widget_local_state/3 - Update widget-local state with a function
  • delete_widget_local_state/2 - Delete widget-local state (for cleanup)
  • handle_widget_event/2 - Route widget events to widget's handle_widget_event/3 callback

Integration Points

  • LiveUi.Component.mount/1 - Fetches and passes widget-local state to widget components
  • LiveUi.Runtime.ScreenComponent - Handles "widget_component_event" events and updates widget-local state

Error Types

  • Error.widget_event_failed/1 - Widget event handler failed
  • Error.invalid_widget_event_payload/0 - Invalid event payload

Tests

  • 14 new tests in widget_local_state_test.exs covering:
    • Getting, setting, updating, and deleting widget-local state
    • Widget event handling and state updates
    • Error cases for invalid payloads and components

All 169 tests pass (155 original + 14 new)

Completes Phase 11.2.2 requirement.

Added widget-local state support to the runtime:
- Runtime.State now includes widget_local_state map
- widget_local_state/2 - Get widget-local state by identity
- put_widget_local_state/3 - Set widget-local state
- update_widget_local_state/3 - Update widget-local state with function
- delete_widget_local_state/2 - Delete widget-local state for cleanup
- handle_widget_event/2 - Route widget events to handle_widget_event callback

Integration points:
- Component.mount/1 now fetches and passes widget-local state to widgets
- ScreenComponent handles "widget_component_event" events
- Event routing converts string event names to atoms for callbacks

Tests:
- 14 new tests covering widget-local state CRUD operations
- Tests verify state isolation, event handling, and error cases

Completes Phase 11.2.2 requirement.
@pcharbon70
pcharbon70 merged commit d0148a0 into main Apr 18, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant