feat(tui): expose api.keymap to TUI plugins for OpenCode compatibility - #2064
Open
YOMXXX wants to merge 2 commits into
Open
feat(tui): expose api.keymap to TUI plugins for OpenCode compatibility#2064YOMXXX wants to merge 2 commits into
YOMXXX wants to merge 2 commits into
Conversation
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
Fixes #2001. TUI plugins written against the upstream OpenCode plugin API (
api.keymap.registerLayer({ commands, bindings })) failed to initialize on MiMoCode because@mimo-ai/plugin's TUI API was missing thekeymapmodule — the error killed the whole TUI plugin (sidebar slots included).Design: reimplement a narrow, type-compatible subset of
api.keymapin the fork (no@opentui/keymapdependency — it targets opentui 0.2.x, incompatible with the fork's 0.1.x). It bridges to the existing command dialog + keybind system.packages/plugin/src/tui.ts: keymap types (TuiKeymap,Binding,Layer,Command,CommandContext,RunCommandResult, …) +TuiPluginApi.keymap.packages/opencode/src/cli/cmd/tui/plugin/keymap.ts(new):createPluginKeymap—registerLayer(bridges commands into the command palette, keybind via existing dialog loop; function-valuedbinding.cmdhandled as hidden keybind options),dispatchCommand/runCommand(threadpayload/event,command.palette.showspecial case,enabledgate),getCommands/getCommandEntries/getCommandBindings,setData/getData(surfaced inCommandContext.data),on/interceptno-ops, key helpers.useCommandDialog.find(name), wiring inapi.tsx/runtime.ts/app.tsx.api.command(legacy) keeps working.Test Plan
createPluginKeymaptest (8 cases): registerLayer bridging, dispatch, palette.show, not-found, data round-trip + ctx.data, enabled gate, payload/event, function binding.bun typecheckclean (bothpackages/opencodeandpackages/plugin); existing plugin/TUI suites 423 pass no regression.Known gaps (documented in code)
Sequence keys (
"g c"), layer target/priority/targetMode semantics, reactiveenabled/suggested(snapshot-evaluated),api.lifecycle.onDisposeno-op,api.modeabsent. These are the documented subset boundaries — the acceptance path (real plugin initializes + commands appear in palette +run(ctx)valid) holds.