T-310: numpad digits select prompt-card options

The prompt card's number-key shortcuts matched only digit1..digit9
(the number row); numpad 1-9 fell through to ignored. Add a
parallel _numpadKeys list and check it in _onKey so the keypad
maps to the same 1-9 selection for Allow/Deny and question
options. numpadEnter was already handled. The hasPrimaryFocus
guard still lets digits type into a focused note field.

Adds four widget tests (numpad Allow/Deny, question option,
focused-note swallow). Closes T-310 (under UI epic T-276).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-10 12:07:35 +02:00
co-authored by Claude Opus 4.8
parent cb86346234
commit b680df2b24
6 changed files with 86 additions and 1 deletions
+37
View File
@@ -547,5 +547,42 @@ void main() {
await tester.pump();
expect(d, isNull, reason: 'typing in the note must not trigger Allow');
});
// Numpad twins map to the same selection as the number row (T-310).
testWidgets('numpad 1 = Allow', (tester) async {
ToolDecision? d;
await pumpCard(tester, permissionPrompt(), (x) => d = x);
await tester.sendKeyEvent(LogicalKeyboardKey.numpad1);
await tester.pump();
expect(d, isA<AllowTool>());
});
testWidgets('numpad 2 = Deny when there is no remember button', (tester) async {
ToolDecision? d;
await pumpCard(tester, permissionPrompt(), (x) => d = x);
await tester.sendKeyEvent(LogicalKeyboardKey.numpad2);
await tester.pump();
expect(d, isA<DenyTool>());
});
testWidgets('numpad selects a question option just like the number row', (tester) async {
ToolDecision? d;
await pumpCard(tester, questionPrompt(), (x) => d = x);
await tester.sendKeyEvent(LogicalKeyboardKey.numpad2); // Dogs (option 2)
await tester.pump();
await tester.tap(find.text('Submit'));
await tester.pump();
expect((d as AllowTool).updatedInput['answers']['Do you prefer cats or dogs?'], 'Dogs');
});
testWidgets('a focused note field swallows numpad digits too', (tester) async {
ToolDecision? d;
await pumpCard(tester, permissionPrompt(), (x) => d = x);
await tester.tap(find.byType(EditableText)); // focus the note field
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.numpad1);
await tester.pump();
expect(d, isNull, reason: 'typing in the note must not trigger Allow');
});
});
}