From b25e0a63db5798de6b4584de18e07fba496b5852 Mon Sep 17 00:00:00 2001 From: Adeel Ahmad Date: Sat, 10 Oct 2026 22:47:59 +0000 Subject: [PATCH] feat(ui): new pipelines and routines are named for you and Enter creates them; Enter in a note's title goes to its first line Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_018XZkebEbpvyi9y3qmDVD8V --- ci/clicks/baseline.json | 96 +++++++++---------- ci/clicks/journeys.mjs | 15 +-- ci/clicks/meter.mjs | 12 ++- .../components/notes/note-page.tsx | 11 +++ .../components/pipelines/pipeline-editor.tsx | 16 +++- 5 files changed, 85 insertions(+), 65 deletions(-) diff --git a/ci/clicks/baseline.json b/ci/clicks/baseline.json index 91ce82c98..6c6f55be4 100644 --- a/ci/clicks/baseline.json +++ b/ci/clicks/baseline.json @@ -1,5 +1,5 @@ { - "surveyed": "2026-10-10T22:25:49.567Z", + "surveyed": "2026-10-10T22:47:49.235Z", "commit": "", "viewport": "1400x900", "journeys": [ @@ -45,7 +45,7 @@ } ], "id": "install", - "ms": 2081, + "ms": 2000, "ok": true }, { @@ -82,7 +82,7 @@ } ], "id": "first-admin", - "ms": 475, + "ms": 423, "ok": true }, { @@ -127,7 +127,7 @@ } ], "id": "setup-wizard", - "ms": 659, + "ms": 572, "ok": true }, { @@ -156,7 +156,7 @@ } ], "id": "first-question", - "ms": 2225, + "ms": 2207, "ok": true }, { @@ -201,7 +201,7 @@ } ], "id": "import-paste", - "ms": 4139, + "ms": 4107, "ok": true }, { @@ -230,7 +230,7 @@ } ], "id": "library-open", - "ms": 2621, + "ms": 2525, "ok": true }, { @@ -267,7 +267,7 @@ } ], "id": "search-word", - "ms": 3173, + "ms": 3176, "ok": true }, { @@ -304,7 +304,7 @@ } ], "id": "jump-to", - "ms": 2385, + "ms": 2251, "ok": true }, { @@ -341,15 +341,15 @@ } ], "id": "chat-ask", - "ms": 3552, + "ms": 3390, "ok": true }, { "module": "Notes", "feature": "Write a note", "note": "", - "clicks": 3, - "keys": 35, + "clicks": 2, + "keys": 36, "prompts": 0, "steps": [ { @@ -376,17 +376,25 @@ "keys": 8, "prompts": 0 }, + { + "page": "/notes/:id", + "kind": "key", + "what": "Enter to go to the first line", + "clicks": 0, + "keys": 1, + "prompts": 0 + }, { "page": "/notes/:id", "kind": "type", "what": "first line", - "clicks": 1, + "clicks": 0, "keys": 27, "prompts": 0 } ], "id": "note-create", - "ms": 3366, + "ms": 3254, "ok": true }, { @@ -431,15 +439,15 @@ } ], "id": "topic-add", - "ms": 3487, + "ms": 3368, "ok": true }, { "module": "Pipelines", "feature": "Make a pipeline from the standard steps", "note": "", - "clicks": 3, - "keys": 14, + "clicks": 2, + "keys": 1, "prompts": 0, "steps": [ { @@ -460,31 +468,23 @@ }, { "page": "/pipelines/new", - "kind": "type", - "what": "name", + "kind": "key", + "what": "Enter to create", "clicks": 0, - "keys": 14, - "prompts": 0 - }, - { - "page": "/pipelines/new", - "kind": "click", - "what": "Create pipeline", - "clicks": 1, - "keys": 0, + "keys": 1, "prompts": 0 } ], "id": "pipeline-create", - "ms": 2694, + "ms": 2548, "ok": true }, { "module": "Routines", "feature": "Make a nightly routine (sync sources, the default action)", "note": "", - "clicks": 3, - "keys": 12, + "clicks": 2, + "keys": 1, "prompts": 0, "steps": [ { @@ -505,23 +505,15 @@ }, { "page": "/routines/new", - "kind": "type", - "what": "name", + "kind": "key", + "what": "Enter to create", "clicks": 0, - "keys": 12, - "prompts": 0 - }, - { - "page": "/routines/new", - "kind": "click", - "what": "Create routine", - "clicks": 1, - "keys": 0, + "keys": 1, "prompts": 0 } ], "id": "routine-create", - "ms": 2647, + "ms": 3298, "ok": true }, { @@ -558,7 +550,7 @@ } ], "id": "extension-add", - "ms": 2554, + "ms": 2533, "ok": true }, { @@ -595,7 +587,7 @@ } ], "id": "sensor-webhook", - "ms": 2684, + "ms": 2822, "ok": true }, { @@ -640,7 +632,7 @@ } ], "id": "settings-change", - "ms": 3491, + "ms": 3430, "ok": true }, { @@ -701,7 +693,7 @@ } ], "id": "person-add", - "ms": 3863, + "ms": 3059, "ok": true }, { @@ -746,7 +738,7 @@ } ], "id": "api-token", - "ms": 3140, + "ms": 3137, "ok": true }, { @@ -775,7 +767,7 @@ } ], "id": "namespace-switch", - "ms": 2280, + "ms": 2256, "ok": true } ], @@ -892,7 +884,7 @@ "page": "/routines/history", "label": "Routines › History", "reach": 2, - "controls": 3 + "controls": 6 }, { "page": "/extensions", @@ -1048,7 +1040,7 @@ "page": "/settings/telemetry", "label": "Settings › Telemetry", "reach": 2, - "controls": 12 + "controls": 13 }, { "page": "/settings/fedora", @@ -1126,7 +1118,7 @@ "page": "/admin/health", "label": "Admin › System health", "reach": 2, - "controls": 10 + "controls": 11 } ] } diff --git a/ci/clicks/journeys.mjs b/ci/clicks/journeys.mjs index 2f8a4e414..25045c193 100644 --- a/ci/clicks/journeys.mjs +++ b/ci/clicks/journeys.mjs @@ -190,8 +190,9 @@ export const JOURNEYS = [ await page.waitForURL(/\/notes\/\d+/); const title = page.getByRole("textbox", { name: "Title" }); await meter.replace(title, "Pi setup", "title"); - const body = page.locator("main affine-page-root [contenteditable=true]").first(); - const editor = (await body.count()) ? body : page.locator("main .inline-editor").last(); + const editor = page.locator("main affine-page-root .inline-editor").first(); + await editor.waitFor(); // the page has loaded its editor + await meter.press("Enter", "Enter to go to the first line"); await meter.type(editor, "Use cloud models on the Pi.", "first line"); await page.getByText("Saved").first().waitFor(); }, @@ -217,8 +218,9 @@ export const JOURNEYS = [ async run({ page, meter }) { await meter.click(nav(page, "Pipelines"), "Pipelines"); await meter.click(page.getByRole("main").getByRole("link", { name: "New pipeline" }), "New pipeline"); - await meter.type(page.getByRole("textbox", { name: "Pipeline name" }), "Quick pipeline", "name"); - await meter.click(page.getByRole("button", { name: "Create pipeline" }), "Create pipeline"); + await page.getByRole("textbox", { name: "Pipeline name" }).waitFor(); // named for you + await page.waitForFunction(() => document.activeElement?.tagName === "INPUT"); + await meter.press("Enter", "Enter to create"); await page.waitForURL(/\/pipelines\/\d+/); }, }, @@ -230,8 +232,9 @@ export const JOURNEYS = [ async run({ page, meter }) { await meter.click(nav(page, "Routines"), "Routines"); await meter.click(page.getByRole("main").getByRole("link", { name: "New routine" }), "New routine"); - await meter.type(page.getByRole("textbox", { name: "Name" }), "Nightly sync", "name"); - await meter.click(page.getByRole("button", { name: "Create routine" }), "Create routine"); + await page.getByRole("textbox", { name: "Name" }).waitFor(); // named for you + await page.waitForFunction(() => document.activeElement?.tagName === "INPUT"); + await meter.press("Enter", "Enter to create"); await page.waitForURL(/\/routines\/\d+/); }, }, diff --git a/ci/clicks/meter.mjs b/ci/clicks/meter.mjs index 98bc121df..c65ea409e 100644 --- a/ci/clicks/meter.mjs +++ b/ci/clicks/meter.mjs @@ -19,6 +19,14 @@ export function pageKey(url) { return (port ? `${port}:` : "") + (path || "/"); } +/** Typing goes into `el` without a click: it has the focus, or (rich text) the caret is in it. */ +function hasFocus(el) { + const active = document.activeElement; + if (el === active || el.contains(active)) return true; + const caret = getSelection()?.anchorNode; + return Boolean(el.isContentEditable && active?.contains(el) && caret && el.contains(caret)); +} + export class Meter { constructor(page) { this.page = page; @@ -80,7 +88,7 @@ export class Meter { /** Types `text` into a field, adding the click that focuses it when it isn't focused already. */ async type(locator, text, what) { await locator.waitFor(); - const focused = await locator.evaluate((el) => el === document.activeElement || el.contains(document.activeElement)); + const focused = await locator.evaluate(hasFocus); this.record("type", what, focused ? 0 : 1, text.length); if (!focused) await locator.click(); await locator.pressSequentially(text); @@ -89,7 +97,7 @@ export class Meter { /** Pastes `text` into a field: the focusing click when needed, and the paste shortcut. */ async paste(locator, text, what) { await locator.waitFor(); - const focused = await locator.evaluate((el) => el === document.activeElement || el.contains(document.activeElement)); + const focused = await locator.evaluate(hasFocus); this.record("paste", what, focused ? 0 : 1, 1); await locator.fill(text); } diff --git a/nextjs-frontend/components/notes/note-page.tsx b/nextjs-frontend/components/notes/note-page.tsx index 26e127b59..534270af0 100644 --- a/nextjs-frontend/components/notes/note-page.tsx +++ b/nextjs-frontend/components/notes/note-page.tsx @@ -290,6 +290,17 @@ export function NotePage({ id, about }: { id?: number; about?: string }) { setTitle(e.target.value); change({ title: e.target.value }); }} + onKeyDown={(e) => { + // Enter goes on to the page's first line, as in a document + if (e.key !== "Enter" || e.nativeEvent.isComposing) return; + // (the page root is what takes the focus; the caret goes in its first paragraph, not the hidden title line) + const root = document.querySelector(".lens-block-editor affine-page-root"); + const line = root?.querySelector(".inline-editor"); + if (!root || !line) return; + e.preventDefault(); + root.focus(); + window.getSelection()?.collapse(line, 0); + }} placeholder="Untitled" className="w-full bg-transparent text-[30px] font-bold leading-tight tracking-[-.015em] text-fg outline-none placeholder:text-fg-muted" /> diff --git a/nextjs-frontend/components/pipelines/pipeline-editor.tsx b/nextjs-frontend/components/pipelines/pipeline-editor.tsx index bbf9823b4..52f54ea94 100644 --- a/nextjs-frontend/components/pipelines/pipeline-editor.tsx +++ b/nextjs-frontend/components/pipelines/pipeline-editor.tsx @@ -218,6 +218,9 @@ export function PipelineEditor({ id }: { id?: number }) { const base: Pipeline | undefined = q.data; const [steps, setSteps] = useState([]); const [name, setName] = useState(""); + // A new pipeline is named for you unless you type one, so Enter creates it straight away + const suggested = `Pipeline ${(catalog.data?.pipelines.length ?? 0) + 1}`; + const named = name.trim() || suggested; const [description, setDescription] = useState(""); const [notes, setNotes] = useState(""); const [sel, setSel] = useState(0); @@ -268,7 +271,7 @@ export function PipelineEditor({ id }: { id?: number }) { Pipelines.createPipeline({ client, body: { - name: name.trim(), + name: named, description: description.trim() || null, steps: body, }, @@ -291,7 +294,7 @@ export function PipelineEditor({ id }: { id?: number }) { void qc.invalidateQueries({ queryKey: ["pipeline", r.id] }); setNotes(""); if (creating) { - toast({ tone: "green", title: "Pipeline created", body: name }); + toast({ tone: "green", title: "Pipeline created", body: named }); router.push(`/pipelines/${r.id}`); return; } @@ -407,9 +410,12 @@ export function PipelineEditor({ id }: { id?: number }) { {creating ? ( setName(e.target.value)} + onKeyDown={(e) => { + if (e.key === "Enter" && !publishReason && !save.isPending) save.mutate(true); + }} className="h-9 w-[280px] text-[16px] font-bold" autoFocus /> @@ -499,8 +505,8 @@ export function PipelineEditor({ id }: { id?: number }) {