From dd90b462f52f40643e0dcab7c3b4d59a30a4c642 Mon Sep 17 00:00:00 2001 From: David Ibia Date: Sat, 17 Oct 2026 16:28:20 +0100 Subject: [PATCH] feat(omo): quit with :q, :q!, :qa or :wq A small extension catches Enter while the editor holds :q, :q!, :qa or :wq and shuts omo down, after the running turn if there is one. It reads the key through onTerminalInput rather than the input event, so typing :q never fires UserPromptSubmit hooks, which used to leave the blue working marker behind. setup-mac.sh links it into ~/.omo/agent/extensions. --- .config/omo/extensions/vim-quit.ts | 27 +++++++++++++++++++++++++++ setup-mac.sh | 1 + 2 files changed, 28 insertions(+) create mode 100644 .config/omo/extensions/vim-quit.ts diff --git a/.config/omo/extensions/vim-quit.ts b/.config/omo/extensions/vim-quit.ts new file mode 100644 index 0000000..39cdf0f --- /dev/null +++ b/.config/omo/extensions/vim-quit.ts @@ -0,0 +1,27 @@ +// Enter is caught before the editor submits, where omo handles /quit, so :q never fires prompt hooks +// such as UserPromptSubmit. ctx.shutdown() waits for the agent to go idle, so :q mid-turn quits after it. +import type { ExtensionAPI } from "@code-yeongyu/senpi"; +import { Key, matchesKey } from "@earendil-works/pi-tui"; + +const QUIT_COMMANDS = new Set([":q", ":q!", ":qa", ":wq"]); + +export default function (pi: ExtensionAPI) { + let unsubscribe: (() => void) | undefined; + + pi.on("session_start", (_event, ctx) => { + unsubscribe?.(); + unsubscribe = ctx.ui.onTerminalInput((data) => { + if (!matchesKey(data, Key.enter) || !QUIT_COMMANDS.has(ctx.ui.getEditorText().trim())) { + return undefined; + } + ctx.ui.setEditorText(""); + ctx.shutdown(); + return { consume: true }; + }); + }); + + pi.on("session_shutdown", () => { + unsubscribe?.(); + unsubscribe = undefined; + }); +} diff --git a/setup-mac.sh b/setup-mac.sh index 71b3111..e234844 100755 --- a/setup-mac.sh +++ b/setup-mac.sh @@ -48,6 +48,7 @@ local_servers .config/zed/settings.json .config/omo/hooks.json:.omo/agent/hooks.json .config/omo/keybindings.json:.omo/agent/keybindings.json +.config/omo/extensions/vim-quit.ts:.omo/agent/extensions/vim-quit.ts .config/omo/prompts:.omo/agent/prompts "