Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

fix(eve): fix TUI setup sequencing (#31)

Ruiea35d0e17390
diff --git a/.changeset/model-flow-exit-to-prompt.md b/.changeset/model-flow-exit-to-prompt.md
new file mode 100644
index 000000000..4c48075fb
--- /dev/null
+++ b/.changeset/model-flow-exit-to-prompt.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+Changing a model or configuring its provider in `/model` now returns to the prompt and prints the result there. Cancelling or choosing an external provider still returns to the menu.
diff --git a/.changeset/tui-setup-attention-order.md b/.changeset/tui-setup-attention-order.md
new file mode 100644
index 000000000..f334e9b69
--- /dev/null
+++ b/.changeset/tui-setup-attention-order.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+The dev TUI now shows `/vc` or `/login` before `/model` when Vercel authentication is blocking model setup.
diff --git a/packages/eve/src/cli/dev/tui/runner.ts b/packages/eve/src/cli/dev/tui/runner.ts
index 92740cfce..7e67a8f3a 100644
--- a/packages/eve/src/cli/dev/tui/runner.ts
+++ b/packages/eve/src/cli/dev/tui/runner.ts
@@ -51,6 +51,7 @@ import {
detectSetupIssues,
formatSetupIssuesLine,
LOGIN_SETUP_ISSUE,
+ orderedSetupIssues,
type BootDetection,
type BootDetectionContext,
type SetupIssue,
@@ -911,7 +912,7 @@ export class EveTUIRunner {
/** Repaints the attention line from the cached detection + auth issues, or clears it. */
#paintSetupAttention(): void {
- const issues = [...this.#bootIssues, ...(this.#authIssue ? [this.#authIssue] : [])];
+ const issues = orderedSetupIssues(this.#bootIssues, this.#authIssue);
if (issues.length > 0) {
this.#renderer.renderSetupWarning?.(formatSetupIssuesLine(issues));
} else {
diff --git a/packages/eve/src/cli/dev/tui/setup-issues.test.ts b/packages/eve/src/cli/dev/tui/setup-issues.test.ts
index 9f8957620..b572f7fbc 100644
--- a/packages/eve/src/cli/dev/tui/setup-issues.test.ts
+++ b/packages/eve/src/cli/dev/tui/setup-issues.test.ts
@@ -6,6 +6,7 @@ import {
detectSetupIssues,
formatSetupIssuesLine,
LOGIN_SETUP_ISSUE,
+ orderedSetupIssues,
type BootDetectionContext,
} from "./setup-issues.js";
@@ -107,3 +108,22 @@ describe("formatSetupIssuesLine", () => {
);
});
});
+
+describe("orderedSetupIssues", () => {
+ it("puts the auth prerequisite before the boot detections", () => {
+ const modelIssue = { label: "model provider not linked", command: "/model" };
+ expect(orderedSetupIssues([modelIssue], CLI_MISSING_SETUP_ISSUE)).toEqual([
+ CLI_MISSING_SETUP_ISSUE,
+ modelIssue,
+ ]);
+ expect(orderedSetupIssues([modelIssue], LOGIN_SETUP_ISSUE)).toEqual([
+ LOGIN_SETUP_ISSUE,
+ modelIssue,
+ ]);
+ });
+
+ it("returns the boot issues unchanged when no auth prerequisite is unmet", () => {
+ const boot = [{ label: "AI Gateway credentials missing", command: "/model" }];
+ expect(orderedSetupIssues(boot, undefined)).toEqual(boot);
+ });
+});
diff --git a/packages/eve/src/cli/dev/tui/setup-issues.ts b/packages/eve/src/cli/dev/tui/setup-issues.ts
index 933048726..a92607e04 100644
--- a/packages/eve/src/cli/dev/tui/setup-issues.ts
+++ b/packages/eve/src/cli/dev/tui/setup-issues.ts
@@ -104,6 +104,14 @@ export async function detectSetupIssues(
return results.flat();
}
+/** Places the auth issue before boot-time setup issues. */
+export function orderedSetupIssues(
+ bootIssues: readonly SetupIssue[],
+ authIssue: SetupIssue | undefined,
+): SetupIssue[] {
+ return authIssue === undefined ? [...bootIssues] : [authIssue, ...bootIssues];
+}
+
/**
* The attention line's body, mirroring Claude Code's
* `1 setup issue: MCP · /doctor` shape; the renderer prefixes the warning
diff --git a/packages/eve/src/setup/flows/model.test.ts b/packages/eve/src/setup/flows/model.test.ts
index 98ab8950f..89d6b9e9a 100644
--- a/packages/eve/src/setup/flows/model.test.ts
+++ b/packages/eve/src/setup/flows/model.test.ts
@@ -255,9 +255,9 @@ describe("runModelFlow", () => {
});
});
- it("applies the pick, then repaints with the new hint and a success notice", async () => {
+ it("applies the model and returns to the prompt", async () => {
const { prompter, menuPaints, selectMessages } = scriptedPrompter({
- menu: ["model", "esc"],
+ menu: ["model"],
picker: ["openai/gpt-5.5"],
});
const deps = flowDeps();
@@ -267,45 +267,15 @@ describe("runModelFlow", () => {
modelMessage: `Model changed to ${pc.bold("openai/gpt-5.5")}. Live on your next prompt.`,
});
- expect(selectMessages).toEqual([
- MODEL_MENU_MESSAGE,
- "Which model should your agent use?",
- MODEL_MENU_MESSAGE,
- ]);
+ expect(selectMessages).toEqual([MODEL_MENU_MESSAGE, "Which model should your agent use?"]);
+ expect(menuPaints).toHaveLength(1);
expect(deps.applyModel).toHaveBeenCalledWith({ appRoot: APP_ROOT, slug: "openai/gpt-5.5" });
- // The applied slug is authoritative for the hint — no compiled-state
- // re-read (which would race the HMR recompile).
expect(deps.readCurrentModel).toHaveBeenCalledTimes(1);
- expect(menuPaints[1]?.options[0]).toEqual({
- value: "model",
- label: "Change model",
- hint: "openai/gpt-5.5",
- });
- expect(menuPaints[1]?.notices).toEqual([
- { tone: "success", text: "Model changed to openai/gpt-5.5" },
- ]);
- });
-
- it("keeps only the latest model-change notice", async () => {
- const { prompter, menuPaints } = scriptedPrompter({
- menu: ["model", "model", "esc"],
- picker: ["openai/gpt-5.5", "anthropic/claude-sonnet-4.6"],
- });
- const deps = flowDeps();
-
- await expect(runModelFlow({ appRoot: APP_ROOT, prompter, deps })).resolves.toEqual({
- kind: "done",
- modelMessage: `Model changed to ${pc.bold("anthropic/claude-sonnet-4.6")}. Live on your next prompt.`,
- });
-
- expect(menuPaints[2]?.notices).toEqual([
- { tone: "success", text: "Model changed to anthropic/claude-sonnet-4.6" },
- ]);
});
- it("paints a warning notice for a rejected slug and keeps the old hint", async () => {
+ it("returns a rejection without repainting the menu", async () => {
const { prompter, menuPaints } = scriptedPrompter({
- menu: ["model", "esc"],
+ menu: ["model"],
picker: ["openai/gpt-5.5"],
});
const deps = flowDeps({
@@ -319,12 +289,11 @@ describe("runModelFlow", () => {
modelMessage: "Couldn't confirm the id.",
});
- expect(menuPaints[1]?.options[0]?.hint).toBe("anthropic/claude-sonnet-4.6");
- expect(menuPaints[1]?.notices).toEqual([{ tone: "warning", text: "Couldn't confirm the id." }]);
+ expect(menuPaints).toHaveLength(1);
});
- it("runs the provider sub-flow, re-detects the status, and posts its notice", async () => {
- const { prompter, menuPaints } = scriptedPrompter({ menu: ["provider", "esc"] });
+ it("returns to the prompt after provider setup", async () => {
+ const { prompter, menuPaints } = scriptedPrompter({ menu: ["provider"] });
const detectProviderStatus = vi
.fn<ModelFlowDeps["detectProviderStatus"]>()
.mockResolvedValueOnce({ kind: "unset" })
@@ -344,12 +313,7 @@ describe("runModelFlow", () => {
expect(runVercelFlow).toHaveBeenCalledWith(expect.objectContaining({ appRoot: APP_ROOT }));
expect(detectProviderStatus).toHaveBeenCalledTimes(2);
- expect(menuPaints[1]?.options[1]).toEqual({
- value: "provider",
- label: "Change provider",
- hint: `AI Gateway (Linked to ${pc.bold("my-agent")})`,
- });
- expect(menuPaints[1]?.notices).toEqual([{ tone: "success", text: "Connected to AI Gateway" }]);
+ expect(menuPaints).toHaveLength(1);
});
it("treats the external-provider branch as informational — no notice, no outcome", async () => {
@@ -414,31 +378,6 @@ describe("runModelFlow", () => {
expect(menuPaints[0]?.initialValue).toBe("model");
});
- it("lands on Done after a model change", async () => {
- const { prompter, menuPaints } = scriptedPrompter({
- menu: ["model", "esc"],
- picker: ["openai/gpt-5.5"],
- });
-
- await runModelFlow({ appRoot: APP_ROOT, prompter, deps: flowDeps() });
-
- expect(menuPaints[0]?.initialValue).toBe("provider");
- expect(menuPaints[1]?.initialValue).toBe("done");
- });
-
- it("lands on Done after a completed provider sub-flow", async () => {
- const { prompter, menuPaints } = scriptedPrompter({ menu: ["provider", "esc"] });
- const deps = flowDeps({
- runVercelFlow: vi.fn(
- async () => ({ kind: "done", credential: "AI_GATEWAY_API_KEY" }) as const,
- ),
- });
-
- await runModelFlow({ appRoot: APP_ROOT, prompter, deps });
-
- expect(menuPaints[1]?.initialValue).toBe("done");
- });
-
it("lands on Done after the external-provider branch", async () => {
const { prompter, menuPaints } = scriptedPrompter({ menu: ["provider", "esc"] });
const deps = flowDeps({
diff --git a/packages/eve/src/setup/flows/model.ts b/packages/eve/src/setup/flows/model.ts
index 1d36456e2..ebac52fb4 100644
--- a/packages/eve/src/setup/flows/model.ts
+++ b/packages/eve/src/setup/flows/model.ts
@@ -179,26 +179,6 @@ function modelMenuRows(
return [modelRow, providerRow, { value: "done", label: "Done" }];
}
-/** The menu's per-action outcome notices; each lap keeps only the latest. */
-function applyModelNotice(outcome: ApplyModelOutcome): SelectNotice {
- switch (outcome.kind) {
- case "changed":
- return { tone: "success", text: `Model changed to ${outcome.to}` };
- case "unchanged":
- return { tone: "info", text: `Model is already ${outcome.model}` };
- case "rejected":
- return { tone: "warning", text: outcome.message };
- }
-}
-
-function providerNotice(provider: ModelProviderStatus): SelectNotice {
- // Short on purpose: the menu's provider row already names the project and
- // team, and the full status hint overflows the panel width.
- return provider.kind === "unset"
- ? { tone: "warning", text: "Provider updated — no gateway credential detected yet." }
- : { tone: "success", text: "Connected to AI Gateway" };
-}
-
/**
* Reads the provider status the menu shows. Detection order matters: a linked
* project subsumes any pulled credential (the link is what the user manages),
@@ -240,10 +220,8 @@ export async function detectModelProviderStatus(
* choice into `agent.ts` (activation is the dev server's HMR watcher).
* The provider row runs {@link runVercelFlow} — the provider gate (AI
* Gateway or your own), then link-or-paste-a-key.
- * Each sub-flow lands back on the repainted menu; Done or Esc leaves. A
- * cancelled sub-flow also returns to the menu. Esc after something completed
- * reports it exactly like the channels flow (the effects already happened);
- * only an empty exit folds to cancelled.
+ * Completed model and provider changes return to the prompt with their result.
+ * Cancelled flows and external-provider instructions return to the menu.
*/
export async function runModelFlow(input: {
appRoot: string;
@@ -281,10 +259,6 @@ export async function runModelFlow(input: {
let lastApply: ApplyModelOutcome | undefined;
let providerOutcome: ModelProviderOutcome | undefined;
- // One notice per action kind, each overwritten by its latest outcome — two
- // model changes in a row leave a single "Model changed to …" line.
- let modelNotice: SelectNotice | undefined;
- let provNotice: SelectNotice | undefined;
// Explains, once, why every row is inert for an external-provider model.
const externalNotice: SelectNotice | undefined =
routing?.kind === "external"
@@ -294,11 +268,7 @@ export async function runModelFlow(input: {
}
: undefined;
- // The menu opens on the most useful selectable row: an unconfigured provider
- // (the agent can't run without it) leads on the first lap; otherwise the model
- // row when it can be edited, else the provider row, else Done. Completing a
- // sub-flow lands the cursor on Done; a cancelled sub-flow leaves it where it
- // came from.
+ // Start at the first useful row. Cancellation keeps the current row.
let nextSelection: ModelMenuRow =
provider.kind === "unset" && routing?.kind !== "external"
? "provider"
@@ -316,7 +286,7 @@ export async function runModelFlow(input: {
options: modelMenuRows(current, provider, routing, editable),
hintLayout: "stacked",
initialValue: nextSelection,
- notices: [externalNotice, modelNotice, provNotice].filter((notice) => notice !== undefined),
+ notices: externalNotice === undefined ? [] : [externalNotice],
});
} catch (error) {
if (!(error instanceof WizardCancelledError)) throw error;
@@ -333,21 +303,14 @@ export async function runModelFlow(input: {
signal,
deps: deps.selectModel,
});
- if (slug !== undefined) {
- signal?.throwIfAborted();
- lastApply = await deps.applyModel({ appRoot, slug });
- signal?.throwIfAborted();
- // The notice distinguishes success from a rejected slug; the menu
- // hint alone would show an unchanged model with no explanation.
- modelNotice = applyModelNotice(lastApply);
- // The applied slug is authoritative for the hint — the compiled
- // state the read reports lags behind the HMR recompile.
- if (lastApply.kind === "changed") current = lastApply.to;
- nextSelection = "done";
- } else {
+ if (slug === undefined) {
nextSelection = "model";
+ continue;
}
- continue;
+ signal?.throwIfAborted();
+ lastApply = await deps.applyModel({ appRoot, slug });
+ signal?.throwIfAborted();
+ break;
}
const result = await deps.runVercelFlow({ appRoot, prompter, signal });
@@ -358,9 +321,7 @@ export async function runModelFlow(input: {
nextSelection = "provider";
continue;
}
- // The external-provider branch only showed instructions (any gateway link
- // is untouched), so it earns no outcome, notice, or status re-read — but
- // the user did make a provider choice, so the menu lands on Done.
+ // External-provider setup only shows instructions, so keep the menu open.
if ("outcome" in result) {
nextSelection = "done";
continue;
@@ -371,8 +332,7 @@ export async function runModelFlow(input: {
signal?.throwIfAborted();
providerOutcome = { status: provider };
if (result.credential !== undefined) providerOutcome.credential = result.credential;
- provNotice = providerNotice(provider);
- nextSelection = "done";
+ break;
}
if (lastApply === undefined && providerOutcome === undefined) {