Skip to content

Conversation

@ariane-emory
Copy link
Contributor

@ariane-emory ariane-emory commented Dec 29, 2025

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.

@ariane-emory ariane-emory marked this pull request as ready for review December 29, 2025 21:41
@ariane-emory ariane-emory changed the title Fix: nonfatal missing key commands Fix: nonfatal missing key commands (resolves #6397) Dec 29, 2025
@ariane-emory ariane-emory marked this pull request as draft December 29, 2025 23:17
@ariane-emory ariane-emory marked this pull request as ready for review December 29, 2025 23:20
@ariane-emory ariane-emory marked this pull request as draft December 29, 2025 23:37
@ariane-emory ariane-emory marked this pull request as ready for review December 29, 2025 23:43
@rekram1-node
Copy link
Collaborator

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

@ariane-emory
Copy link
Contributor Author

@rekram1-node Alright, I'll look into how that could work and see what I can come up with.

@ariane-emory ariane-emory marked this pull request as draft December 31, 2025 02:46
@ariane-emory ariane-emory force-pushed the fix/nonfatal-missing-key-commands branch 2 times, most recently from a17f3a8 to 69ab87a Compare December 31, 2025 04:42
- 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
@ariane-emory ariane-emory force-pushed the fix/nonfatal-missing-key-commands branch from 69ab87a to 18b74aa Compare December 31, 2025 07:43
…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.
@ariane-emory ariane-emory marked this pull request as ready for review January 1, 2026 00:54
@ariane-emory
Copy link
Contributor Author

@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?

  • strips the 'unknown' key commands out prior to validation, so the config always receives a valid config.
  • -emits a config.warning BusEvent that TUI then consumes and reacts to by displaying a warning like Unknown key commands: foo, bar.
  • retains the Unknown key command: foo toast upon striking one of these keys.

Whaddya think? If there are further refinements you'd like. don't hesitate to ask!

@ariane-emory ariane-emory marked this pull request as draft January 1, 2026 23:35
@ariane-emory ariane-emory marked this pull request as ready for review January 3, 2026 00:47
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.

[FEATURE]: Missing key commands ought not be fatal errors.

2 participants