change(web): prepare suggestion-application for whitespace fat-finger handling 🚂#15775
Conversation
User Test ResultsTest specification and instructions User tests are not required |
0e29439 to
938d5ed
Compare
aa03f2b to
3802382
Compare
… handling Build-bot: skip build:web Test-bot: skip
3802382 to
0e33686
Compare
| const resultingTransition = new ContextTransition(baseState, transformToApply.id); | ||
| resultingTransition.finalize(resultingState, inputDistribution); | ||
| resultingTransition.revertableTransitionId = suggestion.transformId; | ||
| resultingTransition._transitionId = transformToApply.id; |
There was a problem hiding this comment.
devin.ai notes this:
_transitionId now uses suggestion.transform.id instead of suggestion.transformId
The old code set resultTransition._transitionId = suggestion.transformId (old line 173). The new code at context-transition.ts:188 sets resultingTransition._transitionId = transformToApply.id where transformToApply = suggestion.transform. These are semantically different fields: transformId is the suggestion-level transition identifier, while transform.id is the ID on the transform object itself. They are aligned by the new code in finalizeSuggestions at predict-helpers.ts:1049-1051 (except when the reported bug with transformId == 0 applies). This creates a coupling between the two codepaths: applySuggestion now implicitly requires that finalizeSuggestions was called first to establish transform.id == transformId. This coupling is fragile if suggestions are constructed without going through finalizeSuggestions (as some tests do).
There was a problem hiding this comment.
I've added documentation as to why this is done.
In particular, this PR prepares suggestion-application for operation in whitespace fat-fingering scenarios. Since these scenarios may support multiple different ways to tokenize the active context, the engine should track the tokenization pattern that matches what the user sees and ensure that suggestions are applied to that pattern, rather than to others.
Suggestions should always apply to the context the user actually sees, modifying the context to match the result from applying the suggestion to the state underlying the suggestion. (The suggestion should be constructed with this in mind; prep work for this can be found in #15781 and #15782, among other PRs.)
No 'insert' or 'delete' edit alternatives should be considered when applying suggestions - only the suggestion-application itself.
Build-bot: skip build:web
Test-bot: skip