fix(tui): show slash commands in autocomplete regardless of enabled state#26606
fix(tui): show slash commands in autocomplete regardless of enabled state#26606kagura-agent wants to merge 1 commit into
Conversation
|
Thanks for tracking this down. I think using Before #26053, A narrower alternative would be:
That restores The main concern with Happy to defer to the maintainers if showing all registered slash commands is the desired behavior. |
|
Good point — using Your narrower approach makes more sense:
This restores Happy to rework the PR with this approach if maintainers agree it's the right direction — or defer to whoever wants to pick it up. |
|
Sounds good. I’ll leave PR ownership with you. For reference, the minimal patch shape I tried locally is:
Roughly: import { reactiveMatcherFromSignal } from "./keymap"
const appExitBindingCommands = ["app.exit"] as const
const appExitBindingEnabled = reactiveMatcherFromSignal(() => {
const current = promptRef.current
return command.matcher.get() && (!current?.focused || current.current.input === "")
})
useBindings(() => ({
enabled: command.matcher,
bindings: tuiConfig.keybinds.gather("app", appBindingCommands),
}))
useBindings(() => ({
enabled: appExitBindingEnabled,
bindings: tuiConfig.keybinds.gather("app", appExitBindingCommands),
}))Then remove That should preserve the old behavior: explicit |
65a3783 to
960b89e
Compare
Split app.exit out of the general app binding group and remove the enabled guard from the command itself. The prompt-empty guard is now applied only to the app.exit keybinding layer, so /exit, /quit, and /q remain reachable as explicit slash commands while accidental-exit protection for keybindings (ctrl+c/ctrl+d) is preserved. Fixes anomalyco#26549
960b89e to
4d892ca
Compare
|
Updated the PR with the narrower approach @CasualDeveloper suggested:
This restores Tests pass locally. |
|
Closing — upstream already implemented the same approach (separating app.exit into its own keybind group with the prompt guard). Thanks @CasualDeveloper for the design guidance! |
Issue for this PR
Closes #26549
Type of change
What does this PR do?
/exit,/quit, and/qare missing from the slash autocomplete dropdown when typing/in the prompt.Root cause: The
app.exitcommand has anenabledfunction that returnsfalsewhen the prompt input is non-empty (to prevent accidental exit via Ctrl+C when text is present). The slash command autocomplete list derives fromentries()which queries the keymap withvisibility: "reachable"— this excludes commands whoseenabledreturns false. Since typing/means the input is no longer empty,app.exitbecomes unreachable and is excluded from the dropdown.This is a regression from #26053 (opentui keymap refactor), which changed command filtering to use keymap visibility levels.
Fix: Added a separate keymap query with
visibility: "registered"specifically for slash commands, so they always appear in the autocomplete dropdown regardless of their keybinding-level enabled state. The command palette (Ctrl+P) and keyboard shortcuts continue to usevisibility: "reachable".How did you verify your code works?
Traced the data flow from keymap → command-palette entries → slashes → autocomplete. Confirmed
app.exithasenabled: () => current.input === ""which returns false when/is typed. Verifiedvisibility: "registered"includes all commands regardless of enabled state per the@opentui/keymaptype definitions.Checklist