Skip to content

收敛 domain 与 component-store transition / Simplify domain and component-store transitions - #15

Merged
tiye merged 1 commit into
mainfrom
codex/action-store-transition
Aug 30, 2026
Merged

tiye merged 1 commit into
mainfrom
codex/action-store-transition

Conversation

@tiye

@tiye tiye commented Aug 30, 2026

Copy link
Copy Markdown
Member

中文

使用者可见结果

  • 新增与 DOM event 无关的 action_store_transition(...),表达“先发送一个完整 domain action,再按条件发送一个 component-store action”。
  • Todo 的开始编辑、保存、取消三个 handler 从 15 行手写 owner-threading closure 收敛为 3 个声明式调用。
  • Lab 的发送回复 handler 从 5 行 closure 收敛为 1 个声明式调用。
  • click 与 Enter 继续复用同一个 transition 和现有 on_local_* listener,不新增按 event kind 排列的 helper 家族。
  • 普通 domain-only 与 store-only 事件继续使用 on_action_* 和 on_store_*。

顺序与边界

  • domain dispatch 永远先运行,因此 domain action payload、reducer effect 和 observation 顺序保持显式。
  • store_when 只决定是否发送后续 component-store action,不会抑制 domain intent。
  • 返回的 owner 始终来自 domain dispatch;domain reducer/workflow 仍然不能读取或修改 child store。
  • 多个 store actions、effect response、复杂分支和直接 model 更新继续使用手写 on_local_* handler。

文档

  • 新增 docs/action-store-transitions.md,分别说明中文和 English 的选择规则、顺序契约、示例与非目标。
  • 更新 README、Agents.md 与 PLAN.md,补充推荐 API、公共 authoring surface 和 GitHub 跟踪状态。

验证

  • yarn test:koka:70 项通过。
  • yarn check 通过。
  • 新增无真实浏览器依赖的 transition 顺序测试,验证 domain → component observation,以及 store_when = False 只跳过 component action。
  • 浏览器 Todo:Enter 保存会提交 title 并结束 session;空 title 保持编辑;Cancel 正常恢复。
  • 浏览器 Lab:Enter 回复会更新 incident,并清空 component draft。
  • 浏览器无 warning 或 error。

English

User-visible outcome

  • Add the DOM-event-independent action_store_transition(...) builder for one complete domain action followed conditionally by one component-store action.
  • Collapse the three Todo start/save/cancel handlers from 15 lines of manual owner-threading closures into three declarative calls.
  • Collapse the Lab send-reply handler from a five-line closure into one declarative call.
  • Keep click and Enter on the same transition and existing on_local_* listeners instead of adding an event-kind helper family.
  • Keep ordinary domain-only and store-only events on on_action_* and on_store_*.

Ordering and boundaries

  • The domain dispatch always runs first, keeping the domain action payload, reducer effects, and observation order explicit.
  • store_when controls only the following component-store action; it never suppresses the domain intent.
  • The returned owner always comes from the domain dispatch. Domain reducers and workflows still cannot read or mutate child stores.
  • Multiple store actions, effect responses, complex branching, and direct model updates remain handwritten on_local_* handlers.

Documentation

  • Add docs/action-store-transitions.md with separate Chinese and English decision guides, ordering contracts, examples, and non-goals.
  • Update README, Agents.md, and PLAN.md with the preferred API, public authoring surface, and GitHub tracking state.

Verification

  • yarn test:koka: 70 passing.
  • yarn check passes.
  • Add a browser-independent transition ordering test for domain → component observation and for store_when = False skipping only the component action.
  • Browser Todo: Enter saves the title and finishes the session; an empty title keeps editing active; Cancel restores normally.
  • Browser Lab: Enter submits the reply and clears the component draft.
  • No browser warnings or errors.

Closes #12

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 a small public helper in explore/react/state to express the common “dispatch one complete domain action, then optionally advance one component store action” pattern as a reusable, DOM-event-independent transition. It then migrates existing Todo/Lab handlers to this abstraction, and documents the intended decision/ordering contract.

Changes:

  • Add action_store_transition(...) as an event-independent builder for domain → (optional) component-store transitions, preserving explicit ordering.
  • Refactor Todo and Lab view handlers to reuse the new transition instead of handwritten owner-threading closures.
  • Add documentation and a browser-independent test that asserts observation ordering and store_when = False behavior.

Reviewed changes

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

Show a summary per file
File Description
README.md Documents the new transition helper and clarifies when to use it vs on_local_*.
PLAN.md Updates the authoring/API plan and status notes to reflect the new abstraction and rollout.
explore/react/state.kk Adds action_store_transition(...) implementation alongside existing on_action_* / on_store_* helpers.
docs/action-store-transitions.md New decision guide + ordering contract in Chinese and English with examples.
demo/todo/view.kk Replaces start/save/cancel edit closures with action_store_transition(...) usage.
demo/tests/statecases.kk Adds action_store_transition_test() to verify domain→component observation ordering and store_when semantics.
demo/tests.kk Registers the new transition test in the demo test suite.
demo/lab/view.kk Refactors send-reply handler to the new transition helper.
Agents.md Updates contributor guidance to recommend action_store_transition(...) for the 1 domain + 1 store pattern.

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

@tiye
tiye merged commit 86d40ae into main Aug 30, 2026
2 checks passed
@tiye
tiye deleted the codex/action-store-transition branch August 30, 2026 11:45
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.

简化组件事件中的 domain 与 local-store transition / Simplify domain and local-store transitions in component events

2 participants