feat: add ask notifications

This commit is contained in:
Erik Kotsiuba
2026-05-06 12:44:37 +02:00
parent 8c02565a5f
commit 43cee4c0f0
15 changed files with 480 additions and 79 deletions
+20
View File
@@ -2,6 +2,10 @@ import type { ExtensionContext } from "@mariozechner/pi-coding-agent";
import { Editor, type EditorTheme } from "@mariozechner/pi-tui";
import type { AskConfig } from "../config/schema.ts";
import { getAskConfigStore } from "../config/store.ts";
import {
createQuestionWaitingNotification,
notifyQuestionWaiting,
} from "../notifications.ts";
import { createInitialState } from "../state/create.ts";
import {
getEditorDraft,
@@ -134,6 +138,9 @@ function createAskFlowController(
controller.editor.onSubmit = (value) => submitEditor(controller, value);
syncSelection(controller);
notifyCurrentQuestion(controller).catch(() => {
// Notification failures are best-effort and must not affect the ask flow.
});
return {
render: (width: number) => renderController(controller, width),
@@ -457,6 +464,19 @@ function refresh(controller: AskFlowController) {
controller.tui.requestRender();
}
async function notifyCurrentQuestion(
controller: AskFlowController
): Promise<void> {
const question = getCurrentQuestion(controller.state);
if (!question) {
return;
}
await notifyQuestionWaiting(
controller.config,
createQuestionWaitingNotification(question)
);
}
function maybeFinish(controller: AskFlowController) {
if (controller.state.completed) {
controller.done(toAskResult(controller.state));