Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

[TUI] improve project name placeholder editing (#241)

Timo Linsf618bef2fec9
diff --git a/.changeset/calm-project-placeholder.md b/.changeset/calm-project-placeholder.md
new file mode 100644
index 000000000..c04480aa8
--- /dev/null
+++ b/.changeset/calm-project-placeholder.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+New Vercel project names now show the suggested name as a placeholder, so typing replaces it instead of editing a prefilled value.
diff --git a/packages/eve/src/cli/dev/tui/setup-panel.test.ts b/packages/eve/src/cli/dev/tui/setup-panel.test.ts
index 671c4ccf2..db39d6289 100644
--- a/packages/eve/src/cli/dev/tui/setup-panel.test.ts
+++ b/packages/eve/src/cli/dev/tui/setup-panel.test.ts
@@ -410,9 +410,9 @@ describe("renderSelectQuestion", () => {
expect(continuation).toBeDefined();
});
- it("renders the hovered editable row as a live field with the caret after the name", () => {
+ it("renders the hovered editable row with the default as a placeholder", () => {
const options = [
- { value: "new", label: "Create a new project", hint: "Named 'weather-agent'" },
+ { value: "new", label: "Create a new project", hint: "Name: weather-agent" },
{ value: "link", label: "Link an existing project" },
];
const renameEditor = (editor: ReturnType<typeof lineOf>) =>
@@ -420,12 +420,12 @@ describe("renderSelectQuestion", () => {
kind: "rename",
editor,
defaultValue: "weather-agent",
- formatHint: (value: string) => `Named '${value}'`,
+ formatHint: (value: string) => `Name: ${value}`,
}) as const;
const baseEdit = { optionValue: "new", caretVisible: true };
- // Hovering the editable row: the seeded default reads back with the caret
- // parked after it, never wedged before the name, and the footer says so.
+ // Hovering the editable row leaves the real buffer empty and parks the
+ // caret before the suggested name, so typing replaces the placeholder.
const hover = renderSelectQuestion(
{
kind: "inline-edit",
@@ -433,16 +433,17 @@ describe("renderSelectQuestion", () => {
message: "Vercel project",
options,
select: initialSelectState({ options }),
- edit: { ...baseEdit, editor: renameEditor(lineOf("weather-agent")) },
+ edit: { ...baseEdit, editor: renameEditor(lineOf("")) },
},
- theme,
+ colorTheme,
80,
);
- expect(hover.join("\n")).toContain("Named 'weather-agent▏'");
- expect(hover.join("\n")).not.toContain("'▏weather-agent'");
+ expect(stripAnsi(hover.join("\n"))).toContain("Name: weather-agent");
+ expect(hover.join("\n")).toContain(colorTheme.colors.inverse("w"));
+ expect(hover.join("\n")).not.toContain("Name: \x1b[22mweather-agent");
expect(hover.at(-1)).toContain("type to rename");
- // Caret off (blink) collapses to nothing — no stray space before the quote.
+ // Caret off (blink) collapses to nothing — no stray space before the placeholder.
const hoverOff = renderSelectQuestion(
{
kind: "inline-edit",
@@ -450,15 +451,16 @@ describe("renderSelectQuestion", () => {
message: "Vercel project",
options,
select: initialSelectState({ options }),
- edit: { ...baseEdit, caretVisible: false, editor: renameEditor(lineOf("weather-agent")) },
+ edit: { ...baseEdit, caretVisible: false, editor: renameEditor(lineOf("")) },
},
- theme,
+ colorTheme,
80,
);
- expect(hoverOff.join("\n")).toContain("Named 'weather-agent'");
- expect(hoverOff.join("\n")).not.toContain("Named 'weather-agent '");
+ expect(stripAnsi(hoverOff.join("\n"))).toContain("Name: weather-agent");
+ expect(stripAnsi(hover.join("\n"))).toBe(stripAnsi(hoverOff.join("\n")));
- // A backspaced field renders the shortened name with the caret at its end.
+ // Entered text keeps a trailing cursor cell, so the cursor follows rather
+ // than covers the final character and blinking does not shift the text.
const edited = renderSelectQuestion(
{
kind: "inline-edit",
@@ -468,10 +470,30 @@ describe("renderSelectQuestion", () => {
select: initialSelectState({ options }),
edit: { ...baseEdit, editor: renameEditor(lineOf("weather-fixtur")) },
},
- theme,
+ colorTheme,
+ 80,
+ );
+ expect(stripAnsi(edited.join("\n"))).toContain("Name: weather-fixtur");
+ expect(edited.join("\n")).toContain("Name: \x1b[22mweather-fixtu");
+ expect(edited.join("\n")).toContain(colorTheme.colors.inverse(" "));
+
+ const editedOff = renderSelectQuestion(
+ {
+ kind: "inline-edit",
+ layout: "task-list",
+ message: "Vercel project",
+ options,
+ select: initialSelectState({ options }),
+ edit: {
+ ...baseEdit,
+ caretVisible: false,
+ editor: renameEditor(lineOf("weather-fixtur")),
+ },
+ },
+ colorTheme,
80,
);
- expect(edited.join("\n")).toContain("Named 'weather-fixtur▏'");
+ expect(stripAnsi(edited.join("\n"))).toBe(stripAnsi(editedOff.join("\n")));
});
it("keeps a long masked key's inline failure visible within a narrow panel", () => {
@@ -519,7 +541,7 @@ describe("renderSelectQuestion", () => {
it("hides the rename cursor and hint when the cursor is off the editable row", () => {
const options = [
- { value: "new", label: "Create a new project", hint: "Named 'weather-agent'" },
+ { value: "new", label: "Create a new project", hint: "Name: weather-agent" },
{ value: "link", label: "Link an existing project" },
];
const rows = renderSelectQuestion(
@@ -537,7 +559,7 @@ describe("renderSelectQuestion", () => {
kind: "rename",
editor: lineOf(""),
defaultValue: "weather-agent",
- formatHint: (value: string) => `Named '${value}'`,
+ formatHint: (value: string) => `Name: ${value}`,
},
},
},
@@ -545,7 +567,7 @@ describe("renderSelectQuestion", () => {
80,
);
// The editable row shows its plain static hint — no caret injected.
- expect(rows.join("\n")).toContain("Named 'weather-agent'");
+ expect(rows.join("\n")).toContain("Name: weather-agent");
expect(rows.join("\n")).not.toContain("weather-agent▏");
expect(rows.at(-1)).not.toContain("type to rename");
});
diff --git a/packages/eve/src/cli/dev/tui/setup-panel.ts b/packages/eve/src/cli/dev/tui/setup-panel.ts
index d5fdd65bd..34ea52661 100644
--- a/packages/eve/src/cli/dev/tui/setup-panel.ts
+++ b/packages/eve/src/cli/dev/tui/setup-panel.ts
@@ -66,10 +66,9 @@ interface SetupSelectPanelBase extends SetupQuestionPanelBase {
* A menu row that turns into an inline editor while the cursor rests on it.
* `optionValue` names the row; the `editor` discriminant chooses the widget —
* an in-place rename field, or a masked provider-key field with its own
- * validation phases. Hovering the row makes it editable directly (typing and
- * backspace edit in place), so the editor's text and a blinking caret render
- * only on that row. Layout and inline editing are orthogonal, so the editor
- * travels as a payload rather than as its own panel `kind`.
+ * validation phases. Rename defaults stay placeholders until typing begins;
+ * provider keys edit in place. Layout and inline editing are orthogonal, so
+ * the editor travels as a payload rather than as its own panel `kind`.
*/
interface SetupInlineEditRow {
optionValue: string;
@@ -198,6 +197,12 @@ function dimWithEmphasis(text: string, theme: Theme): string {
return theme.colors.dim(text.replaceAll(BOLD_OR_DIM_CLOSE, `${BOLD_OR_DIM_CLOSE}${DIM_OPEN}`));
}
+/** Restores normal intensity for a span nested inside an otherwise dim hint. */
+function solidWithinDim(text: string, theme: Theme): string {
+ if (!theme.color) return text;
+ return `${BOLD_OR_DIM_CLOSE}${text}${DIM_OPEN}`;
+}
+
/** A selected row must not inherit an authored hint color. */
function foregroundWithEmphasis(text: string): string {
return text.replaceAll(DIM_OPEN, "").replace(ANSI_FOREGROUND_COLOR, "");
@@ -407,9 +412,17 @@ function renameHint(
theme: Theme,
): SetupPanelOption {
const value = rename.editor.text || rename.defaultValue;
- const caretAt = rename.editor.text.length === 0 ? value.length : rename.editor.cursor;
- const caret = caretVisible ? theme.colors.cyan(theme.glyph.caret) : "";
- const editableValue = `${value.slice(0, caretAt)}${caret}${value.slice(caretAt)}`;
+ const caretLine = { text: value, cursor: rename.editor.cursor };
+ // The placeholder caret overlays its first character. Entered text uses the
+ // editor's real cursor position, including the stable trailing cell at EOF.
+ let editableValue = renderInputWithBlockCursor({
+ ...visibleLine(caretLine, Number.POSITIVE_INFINITY),
+ visible: caretVisible,
+ inverse: theme.colors.inverse,
+ });
+ if (rename.editor.text.length > 0) {
+ editableValue = solidWithinDim(editableValue, theme);
+ }
return { ...option, hint: rename.formatHint(editableValue) };
}
diff --git a/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts b/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts
index a51fdd4fb..b9dcae635 100644
--- a/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts
+++ b/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts
@@ -1812,34 +1812,33 @@ describe("TerminalRenderer setup panel", () => {
renderer.shutdown();
});
- it("renames the hovered editable row directly via typing and backspace", async () => {
+ it("uses the default name as a placeholder when renaming the hovered row", async () => {
const { screen, input, renderer } = makeRenderer();
const answer = renderer.setupFlow.readEditableSelect?.({
message: "Vercel project",
options: [
- { value: "new", label: "Create a new project", hint: "Named 'weather-agent'" },
+ { value: "new", label: "Create a new project", hint: "Name: weather-agent" },
{ value: "link", label: "Link an existing project" },
],
initialValue: "new",
editable: {
value: "new",
defaultValue: "weather-agent",
- formatHint: (value) => `Named '${value}'`,
+ formatHint: (value) => `Name: ${value}`,
},
});
expect(answer).toBeDefined();
// Hovering the editable row is already a live field — no → to enter.
expect(screen.snapshot()).toContain("type to rename");
- expect(screen.snapshot()).toContain("Named 'weather-agent");
- // Backspace edits the seeded default in place, exactly like typing.
+ expect(screen.snapshot()).toContain("Name: weather-agent");
+ // The default is not real editor text, so backspace cannot partially erase
+ // it. Typing replaces the placeholder with the new name.
input.backspace();
- input.backspace();
- // "nt" trimmed off the end of the seeded default.
- expect(screen.snapshot()).not.toContain("weather-agent");
- input.type("!");
- expect(screen.snapshot()).toContain("Named 'weather-age!");
+ expect(screen.snapshot()).toContain("Name: weather-agent");
+ input.type("weather-age!");
+ expect(screen.snapshot()).toContain("Name: weather-age!");
input.enter();
await expect(answer).resolves.toEqual({
kind: "edited",
@@ -1849,6 +1848,29 @@ describe("TerminalRenderer setup panel", () => {
renderer.shutdown();
});
+ it("returns an untouched editable row as a plain selection", async () => {
+ const { input, renderer } = makeRenderer();
+
+ const answer = renderer.setupFlow.readEditableSelect?.({
+ message: "Vercel project",
+ options: [
+ { value: "new", label: "Create a new project", hint: "Name: weather-agent" },
+ { value: "link", label: "Link an existing project" },
+ ],
+ initialValue: "new",
+ editable: {
+ value: "new",
+ defaultValue: "weather-agent",
+ formatHint: (value) => `Name: ${value}`,
+ },
+ });
+ expect(answer).toBeDefined();
+
+ input.enter();
+ await expect(answer).resolves.toEqual({ kind: "selected", value: "new" });
+ renderer.shutdown();
+ });
+
it("validates a masked key without replacing the provider frame", async () => {
const { screen, input, renderer } = makeRenderer();
let resolveValidation:
diff --git a/packages/eve/src/cli/dev/tui/terminal-renderer.ts b/packages/eve/src/cli/dev/tui/terminal-renderer.ts
index b045f3900..4b8edc955 100644
--- a/packages/eve/src/cli/dev/tui/terminal-renderer.ts
+++ b/packages/eve/src/cli/dev/tui/terminal-renderer.ts
@@ -1467,11 +1467,13 @@ export class TerminalRenderer implements AgentTUIRenderer {
if (error !== undefined) state.error = error;
return renderSelectQuestion(state, this.#theme, width);
};
+ // Hovering the editable row makes it a live field. The editor stays empty
+ // until typing starts, leaving the default as a placeholder with the caret
+ // at its start. Moving off the row clears the field and stops the blink.
const onEditableRow = () =>
selectValueAtCursor([...opts.options], select.cursor) === opts.editable.value;
const syncEditableRow = () => {
if (onEditableRow()) {
- if (editor.text.length === 0) editor = lineOf(opts.editable.defaultValue);
this.#startCaretBlink();
} else {
editor = lineOf("");
diff --git a/packages/eve/src/cli/dev/tui/tui-prompter.test.ts b/packages/eve/src/cli/dev/tui/tui-prompter.test.ts
index 7887fb634..38c92de00 100644
--- a/packages/eve/src/cli/dev/tui/tui-prompter.test.ts
+++ b/packages/eve/src/cli/dev/tui/tui-prompter.test.ts
@@ -135,7 +135,7 @@ describe("createTuiPrompter", () => {
editable: {
value: "new",
defaultValue: "weather-agent",
- formatHint: (value) => `Named '${value}'`,
+ formatHint: (value) => `Name: ${value}`,
},
}),
).resolves.toEqual({ kind: "edited", value: "new", text: "custom-name" });
diff --git a/packages/eve/src/setup/boxes/resolve-provisioning.ts b/packages/eve/src/setup/boxes/resolve-provisioning.ts
index 9abdda65d..eb60300a0 100644
--- a/packages/eve/src/setup/boxes/resolve-provisioning.ts
+++ b/packages/eve/src/setup/boxes/resolve-provisioning.ts
@@ -297,7 +297,7 @@ export function resolveProvisioning(
{
value: "new" as const,
label: "Create a new project",
- hint: `Named ${agentName}`,
+ hint: `Name: ${agentName}`,
},
{ value: "link" as const, label: "Link an existing project" },
];
@@ -310,7 +310,7 @@ export function resolveProvisioning(
editable: {
value: "new",
defaultValue: agentName,
- formatHint: (value) => `Named ${value}`,
+ formatHint: (value) => `Name: ${value}`,
validate: (value) =>
value.trim().length === 0 ? "Project name cannot be empty." : undefined,
},
@@ -329,7 +329,7 @@ export function resolveProvisioning(
id: "new",
value: "new",
label: "Create a new project",
- hint: `Named ${agentName}`,
+ hint: `Name: ${agentName}`,
},
{ id: "link", value: "link", label: "Link an existing project" },
],