fix(lang-core): update pristine declaration defaults during streaming (#767) - #1153
Open
justonemorenight wants to merge 1 commit into
Open
justonemorenight wants to merge 1 commit into
justonemorenight wants to merge 1 commit into
Conversation
…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.
|
@justonemorenight is attempting to deploy a commit to the thesys-devs Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #767
In
@openuidev/lang-core's reactive state store (createStore().initialize()), declaration defaults previously only applied to keys not yet present instate(!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,initializeskipped updating the key because it already existed instate, leaving the UI stuck at the truncated value until a full reload.Changes
packages/lang-core/src/runtime/store.ts:defaultsthat have not been modified bystore.set()or initialized viapersisted).initialize(defaults, persisted)runs:pristineand updatestate.stateand markedpristine.pristine(unmodified by the user) update to the latest declaration default if it changed.set()removes frompristine) and persisted values remain untouched.store.dispose()clears thepristinetracking set.packages/lang-core/src/runtime/__tests__/store.test.tsverifying:store.set()are never overwritten by subsequent default updates.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.