Skip to content

Conversation

@forketyfork
Copy link
Owner

Introduce a new src/state/ module with reactive primitives:

  • Signal(T): Observable state with change notifications
  • Computed(T): Derived values with automatic dependency tracking
  • Effect: Side effects that re-run when dependencies change
  • ObservableArray/ObservableMap: Reactive collections
  • Transaction: Batched updates for atomic state changes

Add comprehensive refactoring plan in docs/state-management-refactor.md
with status quo analysis, migration phases, and acceptance criteria.

This is a foundational prototype - no existing code is modified to use
the new system yet. Migration will proceed incrementally per the plan.

Introduce a new `src/state/` module with reactive primitives:
- Signal(T): Observable state with change notifications
- Computed(T): Derived values with automatic dependency tracking
- Effect: Side effects that re-run when dependencies change
- ObservableArray/ObservableMap: Reactive collections
- Transaction: Batched updates for atomic state changes

Add comprehensive refactoring plan in docs/state-management-refactor.md
with status quo analysis, migration phases, and acceptance criteria.

This is a foundational prototype - no existing code is modified to use
the new system yet. Migration will proceed incrementally per the plan.
@forketyfork forketyfork requested a review from Copilot January 18, 2026 07:31
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d0c77f9953

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

Copilot AI left a comment

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 foundational reactive state management system inspired by MobX, adding new primitives (Signal, Computed, Effect, ObservableArray, ObservableMap, Transaction) in the src/state/ module. It includes comprehensive documentation of the migration plan without modifying existing application code.

Changes:

  • Implemented core reactive primitives with automatic dependency tracking
  • Added comprehensive unit tests for all new state management components
  • Documented migration strategy and integration plan in docs/state-management-refactor.md

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
src/state/tracker.zig Implements dependency tracking context with batching support for reactive updates
src/state/signal.zig Core observable primitive with subscriber notifications and equality-based change detection
src/state/computed.zig Derived reactive values with lazy evaluation and automatic dependency tracking
src/state/effect.zig Side effects that automatically re-run when tracked dependencies change
src/state/store.zig Higher-level constructs including reactive collections and transaction batching
src/state/mod.zig Public module exports and API documentation with usage examples
docs/state-management-refactor.md Comprehensive migration plan detailing phased refactoring approach
docs/architecture.md Updated architecture documentation to include new reactive state module

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Restore prior tracking context after recompute to support nested
  computed evaluations
- Add dependency subscription so computeds/effects automatically react
  to signal changes via a global registry
- Fix ArrayList initializations to use proper allocator-based init
- Expose generateNodeId() and use it directly to avoid memory leaks
  from temporary Signal creation
- Make node ID generation thread-safe with std.atomic.Value
- Make tracking context thread-local for multi-threaded safety
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.

3 participants