The Open Framework for Building Agents
fix(eve): wrap long setup questions in TUI (#3518)
prha06e17ae15fa7
diff --git a/.changeset/wrapped-setup-questions.md b/.changeset/wrapped-setup-questions.mdnew file mode 100644index 000000000..82f4e6e4a--- /dev/null+++ b/.changeset/wrapped-setup-questions.md@@ -0,0 +1,5 @@+---+"eve": patch+---++Wrap long setup questions in the `eve dev` terminal UI instead of clipping them at the terminal edge.diff --git a/packages/eve/src/cli/dev/tui/setup-panel.test.ts b/packages/eve/src/cli/dev/tui/setup-panel.test.tsindex 2cf20c764..cb43b873b 100644--- a/packages/eve/src/cli/dev/tui/setup-panel.test.ts+++ b/packages/eve/src/cli/dev/tui/setup-panel.test.ts@@ -67,7 +67,7 @@ describe("renderFlowPanel", () => {expect(text).toContain(" › Create a new project");});- it("renders multiline titles as separate terminal rows", () => {+ it("wraps long titles and renders multiline titles as separate terminal rows", () => {const title ="You need to link to a project to use linear through Vercel Connect.\n\nSelect your team";const rows = renderFlowPanel(@@ -81,11 +81,12 @@ describe("renderFlowPanel", () => {},},theme,- 80,+ 48,);- expect(rows.slice(0, 5)).toEqual([- " You need to link to a project to use linear through Vercel Connect.",+ expect(rows.slice(0, 7)).toEqual([+ " You need to link to a project to use linear",+ " through Vercel Connect.",""," Select your team","",@@ -288,6 +289,32 @@ describe("renderSelectQuestion", () => {expect(text).toContain("esc to cancel");});+ it("wraps a long question instead of clipping it", () => {+ const options = [+ { value: "yes", label: "Yes" },+ { value: "no", label: "No" },+ ];+ const rows = renderSelectQuestion(+ {+ kind: "single",+ message:+ "A legacy self-modification scaffold was found at agent/subagents/self-modification. This scaffold format is no longer supported. Do you want to remove it?",+ options,+ select: initialSelectState({ options }),+ },+ theme,+ 48,+ );++ expect(rows.slice(0, 5)).toEqual([+ " A legacy self-modification scaffold was",+ " found at agent/subagents/self-modification.",+ " This scaffold format is no longer supported.",+ " Do you want to remove it?",+ "",+ ]);+ });+it("drops the numbers for a lone option", () => {const lone = [{ value: "relink", label: "Link to another project" }];const text = renderSelectQuestion(diff --git a/packages/eve/src/cli/dev/tui/setup-panel.ts b/packages/eve/src/cli/dev/tui/setup-panel.tsindex e3b6b8d9e..ad3d52a38 100644--- a/packages/eve/src/cli/dev/tui/setup-panel.ts+++ b/packages/eve/src/cli/dev/tui/setup-panel.ts@@ -283,7 +283,13 @@ export function renderFlowPanel(state: FlowPanelState, theme: Theme, width: numbstate.content.kind === "question" ? (state.content.title ?? state.title) : state.title;if (title.length > 0) {for (const line of title.split("\n")) {- rows.push(line.length === 0 ? "" : ` ${c.bold(line)}`);+ if (line.length === 0) {+ rows.push("");+ continue;+ }+ for (const wrapped of wrapVisibleLine(line, Math.max(1, width - 3))) {+ rows.push(` ${c.bold(wrapped)}`);+ }}rows.push("");}@@ -438,12 +444,19 @@ function plannerStepRows(return [` ${progress.join("")}`, ""];}-function selectMessageRows(message: string, layout: SelectLayout, theme: Theme): string[] {+function selectMessageRows(+ message: string,+ layout: SelectLayout,+ theme: Theme,+ width: number,+): string[] {if (message === "") return [];- const rows = message.split("\n").map((line, index) => {+ const rows = message.split("\n").flatMap((line, index) => {const emphasized = layout === "stacked" || index > 0;- return ` ${emphasized ? theme.colors.bold(line) : line}`;+ return wrapVisibleLine(line, Math.max(1, width - 4)).map(+ (wrapped) => ` ${emphasized ? theme.colors.bold(wrapped) : wrapped}`,+ );});rows.push("");return rows;@@ -814,7 +827,7 @@ export function renderSelectQuestion(theme,): []),- ...selectMessageRows(state.message, presentation.layout, theme),+ ...selectMessageRows(state.message, presentation.layout, theme, width),];if (state.description !== undefined || state.metadata !== undefined) {if (rows.at(-1) === "") rows.pop();