Skip to content

change(web): stage construction of CorrectionPredictionTuple instances - #16429

Merged
jahorton merged 2 commits into
masterfrom
change/web/stage-correctpredicttuple-construction
Sep 3, 2026
Merged

change(web): stage construction of CorrectionPredictionTuple instances#16429
jahorton merged 2 commits into
masterfrom
change/web/stage-correctpredicttuple-construction

Conversation

@jahorton

Copy link
Copy Markdown
Contributor

Build-bot: skip build:web
Test-bot: skip

@keymanapp-test-bot

keymanapp-test-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown

User Test Results

Test specification and instructions

User tests are not required

Test Artifacts

@keymanapp-test-bot keymanapp-test-bot Bot added this to the A19S36 milestone Aug 24, 2026
@github-actions github-actions Bot added web/ web/predictive-text/ change Minor change in functionality, but not new labels Aug 24, 2026
@jahorton
jahorton marked this pull request as ready for review August 26, 2026 13:38

@mcdurdin mcdurdin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is a fair bit of stuff moving around here but I am not entirely sure why. Why did you extract matchLevel and preservationTransform into a separate PredictionMetadata interface? It seems like additional it adds extra verbosity to the code but the interface is not used outside that one place.

Why is CorrectionPredictionTuple separated from CorrectionPredictionTupleCore? Why can't metadata just be an optional property of CorrectionPredictionTuple as it was before? What is the benefit? Does this restructuring make the code more robust, or easier to understand, or faster?

(FWIW, we usually try to avoid using terms like Tuple because it doesn't add useful information about the type. CorrectionPredictionProbability seems closer? or SuggestionProbability? But I'm not entirely sure if those suggestions are right.)

Otherwise, the changes LGTM

Comment thread web/src/engine/predictive-text/worker-thread/src/main/predict-helpers.ts Outdated
@jahorton

Copy link
Copy Markdown
Contributor Author

There is a fair bit of stuff moving around here but I am not entirely sure why. Why did you extract matchLevel and preservationTransform into a separate PredictionMetadata interface? It seems like additional it adds extra verbosity to the code but the interface is not used outside that one place.

For this PR, yes. The next PR - #16436 - will do a little more with the extracted type. Furthermore, epic/boundary-correction already has the type, which is part of why I decided to go ahead and leverage similar structure for this purpose.

Why is CorrectionPredictionTuple separated from CorrectionPredictionTupleCore? Why can't metadata just be an optional property of CorrectionPredictionTuple as it was before? What is the benefit? Does this restructuring make the code more robust, or easier to understand, or faster?

It becomes clearer where and when the .metadata property should and should not be optional. In particular, the inner-most core of prediction-generation doesn't have access to the values needed to populate .metadata, and now it is clearly a different code section's responsibility. (.matchLevel's value there is merely a default, to be overwritten later.) This will now be enforced by the TS type-inference engine.

New fields added to the .metadata type in the next PR - #16436 - similarly were only reasonable to initialize outside of that "inner-most core".

Co-authored-by: Marc Durdin <marc@durdin.net>
@keyman-server keyman-server modified the milestones: A19S36, B19S1 Aug 30, 2026
@jahorton
jahorton merged commit b659a28 into master Sep 3, 2026
8 checks passed
@jahorton
jahorton deleted the change/web/stage-correctpredicttuple-construction branch September 3, 2026 13:16
@github-project-automation github-project-automation Bot moved this from Todo to Done in Keyman Sep 3, 2026
@keyman-server

Copy link
Copy Markdown
Collaborator

Changes in this pull request will be available for download in Keyman version 19.0.279-alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change Minor change in functionality, but not new web/predictive-text/ web/

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants