Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

fix(eve): keep addressed add confirmations responsive (#2861)

prha68d44b5e79cb
diff --git a/.changeset/brave-panthers-rest.md b/.changeset/brave-panthers-rest.md
new file mode 100644
index 000000000..73d2988d3
--- /dev/null
+++ b/.changeset/brave-panthers-rest.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+Addressed `/add <item>` confirmations now remain responsive in the dev TUI.
diff --git a/packages/eve/src/cli/dev/tui/setup-commands.test.ts b/packages/eve/src/cli/dev/tui/setup-commands.test.ts
index 8a0c355fa..ac06434f4 100644
--- a/packages/eve/src/cli/dev/tui/setup-commands.test.ts
+++ b/packages/eve/src/cli/dev/tui/setup-commands.test.ts
@@ -106,6 +106,32 @@ function run(input: {
}
describe("runTuiSetupCommand", () => {
+ it("arms the interrupt trap before an addressed add opens its confirmation", async () => {
+ const calls: string[] = [];
+ const renderer = fakePanelRenderer();
+ renderer.waitForInterrupt = vi.fn(() => {
+ calls.push("interrupt");
+ return { promise: new Promise<"escape" | "ctrl-c">(() => {}), dispose: vi.fn() };
+ });
+ renderer.readSelect = vi.fn(async () => {
+ calls.push("select");
+ return ["install"];
+ });
+ const flows = fakeFlows({
+ runRegistryFlow: vi.fn<TuiSetupFlows["runRegistryFlow"]>(async ({ prompter }) => {
+ await prompter.select({
+ message: "Add experimental/self-modification?",
+ options: [{ value: "install", label: "Install and set up" }],
+ });
+ return registryResult();
+ }),
+ });
+
+ await run({ command: "add", flows, renderer, useDefaultPrompter: true });
+
+ expect(calls).toEqual(["interrupt", "select"]);
+ });
+
it("suspends the runtime during registry installation", async () => {
const calls: string[] = [];
const runRegistryFlow = vi.fn<TuiSetupFlows["runRegistryFlow"]>(async (input) => {
diff --git a/packages/eve/src/cli/dev/tui/setup-commands.ts b/packages/eve/src/cli/dev/tui/setup-commands.ts
index cbef7e50a..f680e9983 100644
--- a/packages/eve/src/cli/dev/tui/setup-commands.ts
+++ b/packages/eve/src/cli/dev/tui/setup-commands.ts
@@ -173,6 +173,10 @@ export async function runTuiSetupCommand(
cancelActiveRegistryItem = undefined;
}
};
+ // Arm the idle trap before a flow can synchronously open its first question.
+ // Otherwise it replaces the question's key consumer, leaving addressed `/add`
+ // confirmations visible but unresponsive.
+ let interrupt = input.renderer.waitForInterrupt();
const execution = executeSetupCommand(
input,
prompter,
@@ -183,7 +187,7 @@ export async function runTuiSetupCommand(
const outcomePromise = execution.then((value) => ({ kind: "outcome" as const, value }));
try {
while (true) {
- const interrupt = input.renderer.waitForInterrupt();
+ let rearm = false;
try {
const settled = await Promise.race([
outcomePromise,
@@ -196,22 +200,24 @@ export async function runTuiSetupCommand(
cancelActiveRegistryItem !== undefined
) {
cancelActiveRegistryItem();
- continue;
+ rearm = true;
+ } else {
+ interrupted = true;
+ controller.abort(new WizardCancelledError());
+ const outcome = await execution;
+ return outcome.partial === true
+ ? outcome
+ : {
+ ...outcome,
+ message: `/${command} interrupted.`,
+ tone: "error",
+ preserveFlowDiagnostics: true,
+ };
}
- interrupted = true;
- controller.abort(new WizardCancelledError());
- const outcome = await execution;
- return outcome.partial === true
- ? outcome
- : {
- ...outcome,
- message: `/${command} interrupted.`,
- tone: "error",
- preserveFlowDiagnostics: true,
- };
} finally {
interrupt.dispose();
}
+ if (rearm) interrupt = input.renderer.waitForInterrupt();
}
} finally {
// A flow that threw or was abandoned mid-wait must not leave the footer spinning.