Conversation
When `AppConfig` schema evolves (fields renamed, removed, or typed differently), old conversation streams fail to deserialize because `PartialConfig` types use `deny_unknown_fields`. This causes jp to refuse to open any conversation that was saved with a now-removed config field. A new `compat` module in `jp_conversation` adds schema-aware stripping before deserialization: the raw JSON for each `config_delta` event is walked alongside the current `AppConfig` schema and any keys not present in the schema are removed. Structs with flattened fields (e.g. `ToolsConfig`, which holds per-tool overrides as sibling keys) are skipped during stripping to avoid wiping valid data. If deserialization still fails after stripping (e.g. a field's type changed), the delta falls back to an empty one with just the timestamp preserved, so the stream as a whole continues to load. To support this, `AppConfig` now exposes a `schema()` method returning the full `Schema` tree via `Schematic::build_schema`, and the relevant `schematic` types are re-exported from `jp_config`. Signed-off-by: Jean Mertz <git@jeanmertz.com>
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.
When
AppConfigschema evolves (fields renamed, removed, or typed differently), old conversation streams fail to deserialize becausePartialConfigtypes usedeny_unknown_fields. This causes jp to refuse to open any conversation that was saved with a now-removed config field.A new
compatmodule injp_conversationadds schema-aware stripping before deserialization: the raw JSON for eachconfig_deltaevent is walked alongside the currentAppConfigschema and any keys not present in the schema are removed. Structs with flattened fields (e.g.ToolsConfig, which holds per-tool overrides as sibling keys) are skipped during stripping to avoid wiping valid data. If deserialization still fails after stripping (e.g. a field's type changed), the delta falls back to an empty one with just the timestamp preserved, so the stream as a whole continues to load.To support this,
AppConfignow exposes aschema()method returning the fullSchematree viaSchematic::build_schema, and the relevantschematictypes are re-exported fromjp_config.