Skip to content

fix: Esc on a blank new rule discards it instead of trapping the user - #4

Open
Ruivalim wants to merge 6 commits into
clankercode:masterfrom
Ruivalim:fix/esc-cancels-blank-new-rule
Open

fix: Esc on a blank new rule discards it instead of trapping the user#4
Ruivalim wants to merge 6 commits into
clankercode:masterfrom
Ruivalim:fix/esc-cancels-blank-new-rule

Conversation

@Ruivalim

@Ruivalim Ruivalim commented Sep 1, 2026

Copy link
Copy Markdown

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).

Ruivalim and others added 6 commits September 1, 2026 18:51
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.
feat: Match IDs lists only the rule provider's models
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant