Repository navigation
WIP: feat(repl): unified keymap registry + dropped-bind reminders (K1+K2, #630/#631) - #632
Conversation
Implements the K1 registry spine and K2 listing/reminder/topic faces of the keymap remap layer (niubash#630, niubash#631), per ~/workspace/keymap-remap/DESIGN.md §5/§6/§8 and the 2026-10-28 rulings on #630/#631. K1 — registry spine: - New keymap_registry module: one effective-table snapshot per editor build (entries with winning source + shadowed layer, dropped records), built by observing the existing add_* passes layer by layer (defaults < host baseline < bundle < script < user). The default layer is the actually-built reedline table, never a hand-copied list. - Build-order fix: user bindings (NIU_BINDKEYS) are applied AFTER the engine pass now — a startup script no longer silently overrides the user's own bindings (the old order was a priority inversion, ruled a defect, not a baseline). - Dropped records are persistent and queryable: the #612 coarse classes refine by payload shape into ChainedSequence / ModeToggleFunction / ScriptMacro / ResponseSequence / UnparseableKeyseq / UnknownFunction. Key-script macros are recorded as mirrored-with-loss; their translation is unchanged (K3 owns the disposition change). NIU_BINDKEYS is retained and layered as the user source. K2 — listing / reminders / topic: - niu help keys topic from a niu-side topic table; the topic name is a single constant referenced by the reminder templates, the niu --help topics section and the niu help verb (verbatim- consistency pinned). The engine's HELP_TOPICS_TABLE and GNU help bytes are untouched. - Actionable startup reminders replace the old warn pass: which bind, why (by reason class), the exact session fix and persistent fix, and the topic pointer. Dedup key is (keyseq, reason, target); the reminded set persists in ~/.niubash/state.toml (runtime state, never config.toml). Structural classes stay silent per #612 except in the one-line summary count and the listings. - doctor gains the standing key-binding face: effective count by snapshot plus the dropped table with one-line fixes, read from the persisted snapshot (doctor never sources rc files). Behavior discipline (DESIGN Appendix A): besides the two ruled changes (build order; dropped records transient -> persistent), unconfigured-user key behavior is byte-identical — pinned by a snapshot-equivalence test comparing the layered build against the pre-registry build order on all three keymaps. Refs #630 Refs #631
- keymap_registry::is_response_sequence: merge the two CSI introducer branches (clippy::if_same_then_else). - Factor the provenance-stack type into keymap_registry:: KeymapStacks and use it in entries_from_stacks and LayeredKeymap::finish (clippy::type_complexity x2).
The engine translates a macro's \C- escapes to raw control characters before the host sees the text, so the notation-only shape test missed exactly the macros it exists to record (found by a PTY smoke: fzf's Alt-C shape landed unrecorded while its literal insert showed control bytes). Raw control characters other than tab/newline are key actions, never text — the shape test now accepts both representations.
…t applied' The reminder headline now matches the record's semantics: a key-script macro IS applied today (its text inserts literally); claiming 'not applied' in the headline while the why-line says the opposite would train users to distrust both.
Workspace-scope fmt gate (CI) caught the one hunk the earlier per-file pass predated.
|
Gate evidence (head CI — green-equivalent, name-verified. Run 40623323668, job build-and-test (122602274472): fmt ✓, clippy (niubash-runtime, -D warnings) ✓, build ✓, Local — failure-set identity. Pristine 9ba7f01 clone: 598 passed / 21 failed. This branch: 612 passed / 21 failed, failure names identical to the pristine set (diff empty); +14 = the new tests. Bin-package extra failures (issue153 root-slash ×2, epochrealtime timing ×1) reproduce identically on the pristine tree — pre-existing environmental, untouched by this diff. End-to-end smoke (PTY, temp HOME). An rc with the fzf/zoxide bind shapes produced: the one-line summary (3 not applied), the per-item actionable block for the unknown function, the 'mirrored with loss' block for the key-script macro, a persisted Full account: |
K1+K2 of the keymap remap layer, per
~/workspace/keymap-remap/DESIGN.md§5/§6/§8 and the 2026-10-28 rulings on #630 (comment-6458611569) / #631 (comment-6458611972).K1 registry spine — new
keymap_registrymodule; the editor build now produces one effective-table snapshot (per-slot winning source + shadowed layer) by observing the existingadd_*passes layer by layer in the order defaults < host baseline < bundle < script < user. Build-order fix: NIU_BINDKEYS user bindings now apply after the engine pass (previously a startup script silently overrode the user — ruled a defect). Dropped records are persistent + queryable, refined by shape: ChainedSequence / ModeToggleFunction / ScriptMacro / ResponseSequence / UnparseableKeyseq / UnknownFunction. Key-script macros are recorded as mirrored-with-loss; translation unchanged until K3.K2 faces —
niu help keystopic (niu-side topic table; topic name is a single constant shared by reminder text,niu --helptopics section, and theniu helpverb — verbatim-consistency pinned; engine HELP_TOPICS_TABLE and GNU help bytes untouched). §8 actionable reminders replace the old warn pass (which + why + session fix + persistent fix + topic pointer; dedup (keyseq, reason, target) persisted in~/.niubash/state.toml, not config.toml; structural classes silent per #612 except the summary count and listings). Doctor gains the standing key-binding face from the persisted snapshot.Behavior discipline (DESIGN Appendix A): besides the two ruled changes (build order; dropped transient → persistent), unconfigured-user behavior is byte-identical — snapshot-equivalence pin compares the layered build against the pre-registry order on all three keymaps.
Gates pending: local runtime lib failure-set equality vs this tree's pristine baseline; CI green-equivalent adjudication vs master's own run. Do not merge — main session merges.
Refs #630
Refs #631