Skip to content

fix(settings): spell every key like config.yml and check conflicts on all of them - #645

Merged
LargeModGames merged 1 commit into
LargeModGames:mainfrom
kapok-4o:fix/settings-key-names
Sep 28, 2026
Merged

LargeModGames merged 1 commit into
LargeModGames:mainfrom
kapok-4o:fix/settings-key-names

Conversation

@kapok-4o

@kapok-4o kapok-4o commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #596.

  • The handler's complete key_to_config_string moves to src/core/user_config.rs as pub fn key_to_config_string(key: &Key) -> String, next to parse_key_public. It keeps its exhaustive match (no _ arm).
  • handle_key_edit imports it, and load_settings_for_category uses it for every keys.* row. The local key_to_string is gone. settings_schema.rs gets it through the existing crate::core::user_config import in core/app/mod.rs, with no new use line.
  • Space now reads [space], matching config.yml.
  • I left the save_config closure and plugin_key_string alone (optional in the issue).

Most of the settings_schema.rs diff is rustfmt re-wrapping the 36 rows after the rename.

Tests: keybinding_rows_spell_keys_the_way_config_yml_does and every_key_row_parses_back_as_a_key in settings_schema.rs, config_string_round_trips_through_parse_key in user_config.rs, and capturing_a_key_already_bound_elsewhere_is_refused_after_a_reload in tui/handlers/settings.rs (walks Enter/F5 on Help, applies, reloads, then Enter/F5 on Search; no app.<field> = writes).

Testing

  • cargo fmt --all -- --check: clean
  • cargo clippy --no-default-features --features telemetry,tui -- -D warnings: clean
  • cargo clippy --no-default-features --features telemetry -- -D warnings (headless leg): clean
  • cargo test --no-default-features --features telemetry,tui: 1313 passed, 0 failed
  • The four new tests pass under the settings and round_trips_through_parse_key filters.
  • With the old key_to_string (ending in _ => "unknown") shadowed back into load_settings_for_category, the two settings_schema tests and the conflict test fail.

Additional notes

This is one of five small PRs I opened together (for #606, #598, #597, #596 and #601). Each changelog entry sits at a different spot in [Unreleased], and I test-merged all five in three orders without conflicts; together they pass the slim checks (1327 tests).

Written with AI coding assistants: Codex drafted fixes for these issues, and Claude Code rebuilt each one on current main against the issue text and re-tested it.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Settings now display keybindings using the same names as config.yml, including function keys, Home, End, Tab, Insert, and Space.
    • Assigning a key already bound to another action is refused, and the existing binding is preserved.

… all of them

load_settings_for_category had its own key_to_string with no arm for
Space, Tab, Home, End, Ins or F0-F12, so those rows showed [unknown]
or [ ], and the conflict check, which parses the row text back, skipped
them and let two actions share an F-key. Move the handler's complete
key_to_config_string to core::user_config and use it for the Settings
rows and for key capture. It lives in core so the headless build keeps
compiling.

Fixes LargeModGames#596

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: LargeModGames/spotatui/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: a8f218a7-f557-4c4b-8a11-0f686340a3a2

📥 Commits

Reviewing files that changed from the base of the PR and between ea356a0 and 592b72b.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • src/core/app/mod.rs
  • src/core/app/settings_schema.rs
  • src/core/user_config.rs
  • src/tui/handlers/settings.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

Keybinding rows in Settings now use config-style key names through a shared formatter. Tests cover key serialization, displayed values, and refusal of a duplicate key assignment after settings reload.

Changes

Keybinding settings

Layer / File(s) Summary
Shared key serialization
src/core/user_config.rs
Adds key_to_config_string for key variants and tests that representative serialized values parse back to the original keys.
Settings keybinding display
src/core/app/mod.rs, src/core/app/settings_schema.rs
Settings keybinding rows use the shared formatter. Tests check config-style names for F5, Home, and Space, and verify that each key row contains a parseable value.
Key-edit conflict handling
src/tui/handlers/settings.rs, CHANGELOG.md
Key-edit handling imports the shared formatter. A test checks that assigning F5 to Search is refused after F5 is assigned to Help and settings are reloaded. The changelog describes the key display and duplicate-assignment behavior.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 592b7

The supplied evidence identifies no remaining issue that would prevent merging the keybinding display and conflict-handling changes.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 592b7

Settings now displays keybindings using configuration-compatible names. Duplicate-key and reserved-key checks still run before an edit is accepted. No new external access or privilege path was identified, though configuration write recovery was not fully established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The assessed change is confined to locally loaded keybinding rows and their representation; the changed formatter takes a typed key and contains no external call or privileged sink.

Trust Boundaries and Controls

  • observed — The key-capture path retains reserved-key rejection and duplicate detection before accepting a new binding; the changed formatter supplies the resulting spelling rather than deciding whether a key is permitted.

Resilience and Maintainability Implications

  • observed — A failed settings save can leave live configuration changed without advancing the saved snapshot. This pre-existing recovery limitation was not worsened by the assessed formatter change; interruption atomicity was not established.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title uses the allowed conventional-commit prefix fix(settings):, clearly describes the key-formatting and conflict-check changes, and uses an imperative subject.
Linked Issues check ✅ Passed PR #645 satisfies the coding requirements in #596. key_to_config_string now lives in src/core/user_config.rs and uses an exhaustive Key match. Settings rows and key capture use the shared format…
Out of Scope Changes check ✅ Passed The changed files support #596 directly. They move the shared formatter to core, update Settings row and key capture behavior, add focused automated tests, and document the fix. No unrelated change is…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
✨ Simplify code
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.84211% with 20 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/core/user_config.rs 66.6% 18 Missing ⚠️
src/core/app/settings_schema.rs 98.7% 1 Missing ⚠️
src/tui/handlers/settings.rs 95.0% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@LargeModGames
LargeModGames merged commit 089d06d into LargeModGames:main Sep 28, 2026
31 checks passed
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.

Settings shows F-keys and Home/End as [unknown] and misses conflicts

2 participants