fix(rawcli): raw byte-line autocomplete fires in hex and binary

The digit key handler applied each keystroke as `buf.document = Document(...)`.
Assigning the buffer document resets prompt_toolkit's complete_state and never
re-fires completion, so the live autocomplete menu never appeared during raw byte
entry -- in BOTH hex and binary (only command-name completion worked, since that
path already used insert_text).

type_digit only ever appends the digit (optionally after an auto-space) or drops it,
so the change is always a pure suffix. Apply it with buf.insert_text, which triggers
completion exactly like an ordinary keystroke.

Verified by driving the real key binding: the completion menu now populates on every
digit in hex and binary (before: complete_state None, start_completion never called).
Adds a regression test asserting the handler routes through insert_text; updates the
rawcli roadmap.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
michael
2026-07-16 12:31:28 -07:00
parent c675f6b278
commit 6e46916dd9
3 changed files with 43 additions and 12 deletions

View File

@@ -11,17 +11,20 @@ dropdown** — never on the bottom bar, never in command output.
- **Must work in both hex AND binary entry modes**, rendering in the active base.
- Function-call args are base-10 (`READ(4)`); raw bytes are hex, `0b` to intermix binary.
## BUG — binary-mode autocomplete does not fire in the live prompt
## FIXED — raw byte-line autocomplete now fires in hex AND binary
The completer logic is correct when fed the text directly (hex and binary), but in the running
REPL the completion menu doesn't reliably appear while entering **binary**.
- Prime suspect: `entry._regroup_after` sets `buf.document = Document(...)` directly on
auto-spacing, which resets prompt_toolkit's `complete_state` and cancels the menu. Binary
regroups every 8 digits, so it bites almost immediately.
- Fix direction: regroup via a completion-preserving path (don't replace `buf.document`
wholesale); re-arm `complete_while_typing` after regroup. Also confirm the Ctrl-t / Ctrl-_
toggle actually flips the breadcrumb to `0b`.
- Verify on hardware in binary mode (needs a tag on the antenna).
Root cause: `entry._digit` applied each keystroke as `buf.document = Document(...)`, which resets
prompt_toolkit's `complete_state` and never re-fires completion — so the live menu never appeared
during raw byte entry. This hit **both** hex and binary (the earlier "hex works, binary doesn't"
was inaccurate; only command-name completion worked, because that path already used `insert_text`).
Fixed by appending the per-keystroke delta via `buf.insert_text` instead — `type_digit` only ever
appends (optionally after an auto-space) or drops, so the change is always a pure suffix, and
`insert_text` triggers completion exactly like an ordinary keystroke. Verified by driving the real
key handler: the menu now populates on every digit in both modes. Regression:
`TestKeyBindings::test_digit_binding_fires_completion_trigger_for_raw_bytes`.
Still worth a quick live-REPL eyeball with a tag on the antenna, and confirming the Ctrl-t / Ctrl-_
toggle flips the breadcrumb to `0b` (separate from the completion trigger, not yet re-verified).
## Priority 1 — MIFARE Classic (do this first)