Skip to content

fix(lang-core): update pristine declaration defaults during streaming (#767) - #1153

Open
justonemorenight wants to merge 1 commit into
thesysdev:mainfrom
justonemorenight:fix/lang-core-streaming-binding-defaults
Open

justonemorenight wants to merge 1 commit into
thesysdev:mainfrom
justonemorenight:fix/lang-core-streaming-binding-defaults

Conversation

@justonemorenight

Copy link
Copy Markdown

Summary

Fixes #767

In @openuidev/lang-core's reactive state store (createStore().initialize()), declaration defaults previously only applied to keys not yet present in state (!state.has(key)).

During streaming parse recovery, a $binding (e.g. $title = "...") can first materialize with a truncated string default when the lexer auto-closes an incomplete open quote. When the stream progresses and the full declaration arrives, initialize skipped updating the key because it already existed in state, leaving the UI stuck at the truncated value until a full reload.

Changes

  • In packages/lang-core/src/runtime/store.ts:
    • Track pristine keys (keys seeded from defaults that have not been modified by store.set() or initialized via persisted).
    • When initialize(defaults, persisted) runs:
      • Persisted entries remove keys from pristine and update state.
      • New keys are added to state and marked pristine.
      • Existing keys that are still in pristine (unmodified by the user) update to the latest declaration default if it changed.
      • User-modified values (set() removes from pristine) and persisted values remain untouched.
    • store.dispose() clears the pristine tracking set.
  • Added comprehensive unit tests in packages/lang-core/src/runtime/__tests__/store.test.ts verifying:
    • Pristine defaults update as streaming declarations grow.
    • User edits via store.set() are never overwritten by subsequent default updates.
    • Persisted values are never overwritten by subsequent default updates.
    • Listeners are notified only when values actually change.
    • Dispose clears state and pristine sets cleanly.

Testing

  • pnpm --filter @openuidev/lang-core test — all 8 test files (118 tests) passed.
  • pnpm --filter @openuidev/react-lang test — all 3 test files (12 tests) passed.
  • pnpm --filter @openuidev/vue-lang test — all 4 test files (36 tests) passed.
  • Lint and Prettier checks passed cleanly.

…thesysdev#767)

In `createStore().initialize()`, declaration defaults previously only applied to newly encountered keys (`!state.has(key)`).

During streaming, an incomplete `$binding` declaration (e.g. truncated by lexer auto-closing an open quote) would initialize the key with the partial default, and subsequent `initialize` calls with the completed declaration would ignore it because the key already existed.

This commit tracks pristine keys (keys initialized from defaults that have not been modified via `set()` or `persisted`). When `initialize` runs again with updated defaults, pristine keys are safely updated to the latest declaration default, while user-modified and persisted values remain untouched.
@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

@justonemorenight is attempting to deploy a commit to the thesys-devs Team on Vercel.

A member of the Team first needs to authorize it.

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.

bug(lang-core): streaming $binding defaults stick at truncated value (store.initialize skips existing keys)

1 participant