Skip to content

Conversation

@drborges
Copy link
Owner

Implement a new internal data structure called Observable State Tree to better streamline Arbor's internals.

drborges added 30 commits March 29, 2025 09:05
Variables referencing OST nodes should be prefixed with '$' to indicate they are reactive, e.g. mutations triggered on them will trigger the subscription system to notify subscribers.
Detached properties do not exist in the OST, thus, when changes are made to them subscribers of the OST are not notified.
@codesandbox
Copy link

codesandbox bot commented Sep 29, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@drborges drborges marked this pull request as draft September 29, 2025 12:39
@drborges drborges requested a review from Copilot September 29, 2025 12:40
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 implements a new internal data structure called Observable State Tree (OST) to better streamline Arbor's internals. The key changes involve refactoring from a path-based system to a seed-based system and creating a new modular handler architecture.

  • Replaces the existing Seed.plant() method with a new plantSeedFor() approach
  • Implements a comprehensive OST architecture with handlers for different data types
  • Adds extensive test coverage for the new OST implementation

Reviewed Changes

Copilot reviewed 106 out of 113 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/arbor-store/src/arbor.ts Refactors seed management to use WeakMap-based tracking and new plantSeedFor method
packages/arbor-store/src/handlers/default.ts Updates to use new tree-based seed planting approach
packages/arbor-store/tests/arbor.test.ts Adds it.only to focus testing on state tree updates
packages/arbor-ost/ New OST package with complete implementation including handlers, visitors, and comprehensive test suite
Various config files Updates to project configuration including TypeScript version and tooling

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


visit({ ost, target, $node }) {
return (...args: unknown[]) => {
let unshifted: unknown[]
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

The unshift method returns a number (the new length), but the variable is typed as unknown[]. The assignment should be unshifted = target.unshift(...args) and the return type should be number.

Suggested change
let unshifted: unknown[]
let unshifted: number

Copilot uses AI. Check for mistakes.
visit({ ost, target, $node }) {
return () => {
if (target.size === 0) {
return false
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

The clear method should return void like the native Map.clear(), not a boolean. Remove the return statements or return undefined.

Copilot uses AI. Check for mistakes.
}
})

return true
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

The clear method should return void like the native Map.clear(), not a boolean. Remove the return statements or return undefined.

Copilot uses AI. Check for mistakes.
Comment on lines +177 to +180
this.#seeds.set(value, new Seed())
}

return this.#seeds.get(value)
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

The method creates a new seed but doesn't return it. The logic should return the newly created seed: if (!seed) { const newSeed = new Seed(); this.#seeds.set(value, newSeed); return newSeed; }

Suggested change
this.#seeds.set(value, new Seed())
}
return this.#seeds.get(value)
const newSeed = new Seed();
this.#seeds.set(value, newSeed);
return newSeed;
}
return seed;

Copilot uses AI. Check for mistakes.
thisArg?: unknown
) {
for (const [key] of target.entries()) {
cb($node.get(key), key, thisArg || $node)
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

The third parameter should be the map itself, not thisArg. The call should be cb.call(thisArg, $node.get(key), key, $node).

Suggested change
cb($node.get(key), key, thisArg || $node)
cb.call(thisArg, $node.get(key), key, $node)

Copilot uses AI. Check for mistakes.
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