fix: Esc on a blank new rule discards it instead of trapping the user - #4
Open
Ruivalim wants to merge 6 commits into
Open
fix: Esc on a blank new rule discards it instead of trapping the user#4Ruivalim wants to merge 6 commits into
Ruivalim wants to merge 6 commits into
Conversation
handleInput() dereferenced this.selectList after SelectList.handleInput(), but Enter (single-select) and Escape callbacks close the submenu and set selectList to null, throwing 'TypeError: null is not an object'. Guard the post-input index tracking and return early: the input was already consumed by the closed submenu. Adds submenu tests covering Enter-select, Esc-cancel and Esc-apply.
Previously, editing a rule with provider '*' listed every model from every provider in the Match IDs picker, mixing ids that can never match the rule together. Now the picker always uses getModelsForProvider(rule.provider). When the rule still has provider '*', Match IDs refuses to open and shows 'Pick a provider first' instead of an everything-list. Adds menu tests: provider-scoped listing, and the '*' refusal.
Esc in the edit view always tried to commit. A new rule with no match
fields failed validation ('Rule must have at least one match field'),
so Esc did nothing visible and the user was stuck: a blank new rule
could neither be saved nor cancelled.
Now Esc/left on a blank new rule discards it and returns to the rules
list. Validation still blocks saving when editing an existing rule.
Adds menu tests: blank-new-rule cancel, and save-with-match still works.
fix: crash on Enter/Esc in submenu
feat: Match IDs lists only the rule provider's models
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.
Bug
In the edit view of a new rule with no match fields set (Match IDs none, Patterns none, Reasoning either), pressing Esc or ← does nothing visible. The user is stuck: a blank rule can be neither saved nor cancelled.
Cause
Esc in the edit view always calls
commitEdit(), which validates that the rule has at least one match field. A blank new rule fails validation (Rule must have at least one match field), the commit aborts, and the menu stays in edit mode with no way out.Fix
When the rule being edited is new and has no match fields, Esc/← discards it and returns to the rules list. Validation still blocks saving when editing an existing rule.
Tests
Two new menu tests: blank-new-rule Esc discards and returns to rules; Esc with a match field set still saves. Suite: 88 passed.
Depends on #1 (the reasoning-submenu Enter in the second test crashes without the null-guard).