-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Fix: nonfatal missing key commands (resolves #6397) #6398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Fix: nonfatal missing key commands (resolves #6397) #6398
Conversation
|
this shouldn't be enforced on the tui side, I would expect the tui to always be fed a valid config, and maybe u can introduce a config event for warnings that you emit that the tui could display |
|
@rekram1-node Alright, I'll look into how that could work and see what I can come up with. |
a17f3a8 to
69ab87a
Compare
- Change Keybinds schema from .strict() to .passthrough() to allow unknown keys - Add ValidKeybindNames set for validating keybind names - Add Config.Warning schema and Config.warnings() function - Add GET /config/warnings endpoint to fetch warnings - Add warning toast display in TUI when sync completes - Add tests for warning generation with unknown keybind names Fixes anomalyco#6397
When user presses a key that matches a keybind configured for an unknown command name, show a warning toast with the command name.
- Fetch unknown keybinds from /config/warnings endpoint instead of iterating all keybinds in config - Add keybinds array field to Warning schema to provide list of unknown keybind names - Fix TypeScript error from passthrough schema by casting value - Regenerate SDK with ConfigWarning.keybinds field
69ab87a to
18b74aa
Compare
…approach - Pre-process unknown keybinds before Zod validation (keep .strict() schema) - Store unknown keybinds with name+binding in warnings - Update TUI to parse and match unknown keybinds directly - Remove unused BusEvent for warnings - Update tests to verify new warning structure - Regenerate TypeScript SDK (KeybindsConfig without index signature) Resolves anomalyco#6397
The null check was added during earlier iterations when .passthrough() was used in the keybind schema. With the current pre-processing approach that strips unknown keybinds and maintains .strict(), all keybind values have defaults applied and will never be undefined, making this check unnecessary.
- Add Config.Event.Warning BusEvent definition - Server sends warning events to clients on SSE connect - TUI subscribes to config.warning events instead of polling API - Remove /config/warnings API endpoint (no longer needed) - Regenerate SDK This fulfills the maintainer's request to use event-based communication for config warnings rather than TUI-side enforcement.
|
@rekram1-node Well.... it turned out to be a lot trickier to do than I thought it would, but after a few rerolls this does seem to be doing it in the way that you'd requested?
Whaddya think? If there are further refinements you'd like. don't hesitate to ask! |
This PR changes the behaviour so that binding missing key commands in a user's config is not a fatal error that prevents the startup of opencode entirely.
With this PR, keybindings for non-existent keywords, when struck will instead display a toast saying "No command 'the_fake_command_name'".
Resolves #6397.