use keymap state for layer visibility (#26246)

This commit is contained in:
Sebastian
2026-05-19 17:07:26 +02:00
committed by GitHub
parent 18b9cec50d
commit 8dd6448c90
17 changed files with 418 additions and 222 deletions
@@ -219,6 +219,14 @@ export function createTuiApi(input: Input): TuiPluginApi {
},
},
keymap: input.keymap,
mode: {
current() {
return Keymap.getOpencodeModeStack(input.keymap).current()
},
push(mode) {
return Keymap.getOpencodeModeStack(input.keymap).push(mode)
},
},
route: {
register(list) {
return routeRegister(input.routes, list, input.bump)
@@ -192,6 +192,17 @@ function createScopedAttention(
}
}
function createScopedMode(mode: TuiPluginApi["mode"], scope: PluginScope): TuiPluginApi["mode"] {
return {
current() {
return mode.current()
},
push(value) {
return scope.track(mode.push(value))
},
}
}
type CleanupResult = { type: "ok" } | { type: "error"; error: unknown } | { type: "timeout" }
function runCleanup(fn: () => unknown, ms: number): Promise<CleanupResult> {
@@ -616,6 +627,7 @@ function pluginApi(runtime: RuntimeState, plugin: PluginEntry, scope: PluginScop
command: createCommandShim(keymap, api.ui.dialog, api.tuiConfig.keybinds),
keys: api.keys,
keymap,
mode: createScopedMode(api.mode, scope),
route,
ui: api.ui,
tuiConfig: api.tuiConfig,