mirror of
https://github.com/boxpositron/absolute-dotfiles.git
synced 2026-10-24 08:23:19 +00:00
dd90b462f5
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.
28 lines
885 B
TypeScript
28 lines
885 B
TypeScript
// 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;
|
|
});
|
|
}
|