stabilize command palette selection

This commit is contained in:
Shantur Rathore
2025-11-14 11:29:02 +00:00
parent 6918232913
commit 1b8c186edd
3 changed files with 178 additions and 102 deletions

View File

@@ -351,11 +351,18 @@ const App: Component = () => {
const { isDark } = useTheme()
const commandRegistry = createCommandRegistry()
const [escapeInDebounce, setEscapeInDebounce] = createSignal(false)
const [paletteCommands, setPaletteCommands] = createSignal<Command[]>([])
const refreshCommandPalette = () => {
setPaletteCommands(commandRegistry.getAll())
}
createEffect(() => {
void initMarkdown(isDark()).catch(console.error)
})
const activeInstance = createMemo(() => getActiveInstance())
const activeSessions = createMemo(() => {
@@ -882,12 +889,16 @@ const App: Component = () => {
console.log("Show help modal (not implemented)")
},
})
refreshCommandPalette()
}
function handleExecuteCommand(commandId: string) {
commandRegistry.execute(commandId)
}
onMount(() => {
setEscapeStateChangeHandler(setEscapeInDebounce)
@@ -1166,7 +1177,7 @@ const App: Component = () => {
<CommandPalette
open={isCommandPaletteOpen()}
onClose={hideCommandPalette}
commands={commandRegistry.getAll()}
commands={paletteCommands()}
onExecute={handleExecuteCommand}
/>