Skip to content

Streamline typed actions and React-like component APIs - #6

Open
tiye wants to merge 3 commits into
mainfrom
codex/action-listeners
Open

Streamline typed actions and React-like component APIs#6
tiye wants to merge 3 commits into
mainfrom
codex/action-listeners

Conversation

@tiye

@tiye tiye commented Aug 23, 2026

Copy link
Copy Markdown
Member

Summary

  • make Todo, Lab, Effects, and the global Dialog overlay directly composable as functions returning app_view vnode; the app now installs one component runtime instead of merging feature runner tuples
  • add a small component surface: feature_root(group, key) { ... }, component(group, key) { ... }, keyed components(...), and the reusable component_effect<s,e> capability alias
  • use Koka trailing-lambda syntax to make lifecycle boundaries visually distinct, while keeping component props, element attributes, actions, and dispatchers as flat labelled arguments
  • keep reducer-backed local state in the React-like (state, dispatch) = use_store(spec, initial = ...) form and route UI/domain changes through typed on_store_* / on_action_* listeners
  • support reusable feature instances with labelled key; propagate it through Todo/Lab store coordination and derive isolated listener, effect, VDOM, and DOM-marker identities
  • canonicalize component key segments without collisions or selector-unsafe characters while preserving existing non-empty slug and numeric paths
  • keep the app-owned Dialog overlay explicitly singleton and move its runtime cleanup to the app integration boundary
  • remove the old Todo/Lab runner adapter modules and obsolete runtime merge APIs
  • update README, PLAN, and developer guidance with the new component model and follow-up direction

Breaking API changes

  • feature panel APIs now return vnode directly; run_todo_panel, run_lab_panel, and the runner adapter modules are removed
  • component_in(...) is renamed to component(...); persistent absolute roots use feature_root(...)
  • raw hook-scope and runtime-tree mutation helpers are no longer part of the business component surface
  • reset_feature(...) replaces the misleading reset_component(...) lifecycle name
  • use_store(...) returns a (state, dispatch) pair instead of a binding record
  • registered input handlers carry the feature effect row, matching click/Enter dispatch
  • old snapshots that used empty, underscore-leading, or reserved-character component keys may fall back once to initial local state; existing application slug/numeric paths are unchanged

Validation

  • yarn test:koka: 62 / 62 passed
  • yarn build
  • yarn check
  • git diff --check
  • behavior-level two-instance tests: Todo Edit/input/Save and Lab draft/Send reply remain isolated across left, right, and default scopes
  • browser smoke: Todo Add/local edit, Lab Send reply, and Dialog open/close all passed; in-page checks reported 62 / 62 with no console warnings/errors
  • HMR/reload: the keyed Todo editor draft survived the final Koka module replacement and a full page reload through the component-state snapshot

Design note

Algebraic effects remain the implementation mechanism for component scope, state, listeners, scheduled effects, and host capabilities. Persistence and agent-facing replay stay action/store concerns: domain and component actions remain typed inside Koka, while only versioned serializable state/actions cross the dynamic runtime boundary.

Copilot AI lite review requested due to automatic review settings August 23, 2026 18:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces on_action_click(...) / on_action_enter(...) as small helper listeners to dispatch typed domain actions without repeating forwarding closures at component call sites, and updates demos + tests + docs to match the new convention.

Changes:

  • Add on_action_click and on_action_enter helpers in the core listener utilities (explore/react/state.kk).
  • Refactor Todo, Lab, and Route components to use the new helpers instead of fn(owner) dispatch(action, owner) forwarding closures.
  • Add a focused test case covering typed action dispatch via click + Enter, and update documentation to describe when to use on_action_* vs on_local_*.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
README.md Documents on_action_click/on_action_enter as the preferred typed domain-action listener helpers.
PLAN.md Updates the plan to capture the “typed domain-action listeners” convention and API surface.
explore/react/state.kk Adds on_action_click / on_action_enter wrappers over on_local_* to reduce boilerplate.
demo/todo/view.kk Replaces domain-action forwarding closures with on_action_* in Todo UI events.
demo/lab/view.kk Replaces domain-action forwarding closures with on_action_* in Lab UI events.
demo/routebar.kk Switches route navigation buttons to dispatch a typed route_action via on_action_click.
demo/model.kk Adds dispatch_route_action and routes click payload handling through decode_route_action.
demo/tests/statecases.kk Adds typed_action_listener_test to cover click + Enter typed action dispatch registration/execution.
demo/tests.kk Registers the new typed action listener test in the overall demo test suite.
Agents.md Documents the new convention to prefer on_action_* for domain actions and keep on_local_* for custom logic.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@tiye tiye changed the title Simplify typed action listeners in components Streamline typed actions and React-like component APIs Aug 23, 2026
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.

2 participants