fix(ui): restore the digit shortcut for the settings view - #182
Merged
Merged
Conversation
The sidebar advertises a digit key on every nav item, but the keydown guard hard-coded the range `1`-`7`. `NAV_ORDER` has 8 items (`ops` was inserted before `settings`), so `settings` renders the badge "8" and its tooltip tells the user to press it -- while pressing 8 is silently ignored. The doc in `ui/README.md` documented `1-7` correctly: it was a faithful description of a buggy guard. The guard no longer writes a bound at all: the badge is `NAV_ORDER` index + 1 and the handler now resolves the item from the same array, so an out-of-range digit is a no-op and the two can never diverge again (bumping "7" to "8" would only re-arm the same bug at the next view insert). Also refresh five stale current-state claims in `ui/README.md` that the same sweep found, each against an arbiter that is itself asserted: language-pack key count 733 -> 785 (`src/i18n_pack.rs` constants), the referenced-key union 496 -> 680 (T() literals 430 + data-i18n 305), toast() call sites 39 -> 75, view count 7 -> 8 (`VIEW_TITLE`), and the help row `1-7` -> `1-8`. Tests: cargo test 165 passed; fmt and clippy -D warnings clean; node --check clean; A/B probe over the real sources flips FAIL(exit 1) -> OK(exit 0), with controls showing a hard-coded "8" still breaks once a 9th view is added.
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.
Summary
The sidebar advertises a digit shortcut on every nav item, but the global keydown guard hard-coded the range
1-7.NAV_ORDERnow has 8 items (opswas inserted beforesettings), sosettingsrenders the badge "8" and its tooltip says to press it — while pressing8is silently ignored. The view was unreachable by digit key while advertising that it was reachable.ui/README.mddocumented1-7correctly: it was a faithful description of a buggy guard, not a doc drift. Provenance:ad631ae(#44) wrote the range whenNAVhad exactly 7 items;85982e8(#80) insertedopsbeforesettingsand the range was never widened.Related Issue
Changes
ui/js/app.js: the digit guard no longer writes a bound at all — the badge isNAV_ORDERindex + 1 and the handler resolves the item from the same array, so an out-of-range digit is a no-op and badge/key range can never diverge again. (Simply bumping"7"→"8"would re-arm the identical bug at the next view insertion; the controls below demonstrate exactly that.)ui/js/app.js: help-panel key row1–7→1–8; the two comments that asserted1-7now state the count-independent rule (1..N,N = NAV_ORDER.length).ui/css/style.css: comment数字 1-7 切换视图→数字键切换视图.ui/README.md:1-7→1-8(view list corrected to all 8 inNAV_ORDERorder); help row1–7→1–8; kbd-guard line de-numbered. Plus 4 more stale current-state counts from the same sweep, each against an arbiter that is itself asserted:733→ 785 (src/i18n_pack.rsZH_KEY_COUNT/EN_KEY_COUNT, enforced bycargo test)496→ 680 (T()literals 430 +data-i18n*305, deduplicated)toast()call sites39→ 75document.titlecoverage7 个视图→ 8 (VIEW_TITLEhas 8 keys)ui/index.html: cache-bust20260912-3→20260912-4(5 refs).No i18n key change:
help.k2's value is range-free in both packs (切换侧边栏视图/Switch sidebar view), so no pack edit and no gate-constant change was needed.Tests
cargo test全部通过 — 165 passed / 0 failedcargo fmt --check通过cargo clippy --all-targets -- -D warnings通过node --check ui/js/app.js通过ui/JS, which has no test harness in this repo; the i18n/key gates (src/i18n_pack.rs) still pass unchanged. Verification was done with an A/B probe over the real sources instead:7/8, so it stays valid after the guard is rewritten)HEAD):RESULT: FAIL (1 advertised shortcut(s) do nothing), exit 1 → after:RESULT: OK (every advertised shortcut works), exit 0"7"on the fixed tree reproduces the failure; hard-coding"8"also fails once a 9th view is added, while the derived guard passes in the same 9-view tree — i.e. the fix removes the class, not the instanceChecklist
fix/)fix(ui): …)