Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(workflows): align local step controls and timing disclosure (#7648)

Louis Beaumontd3bebe820b28
diff --git a/apps/screenpipe-app-tauri/components/workflows/cloud-workflows.test.tsx b/apps/screenpipe-app-tauri/components/workflows/cloud-workflows.test.tsx
index 3e7653be0..302dbd334 100644
--- a/apps/screenpipe-app-tauri/components/workflows/cloud-workflows.test.tsx
+++ b/apps/screenpipe-app-tauri/components/workflows/cloud-workflows.test.tsx
@@ -174,7 +174,8 @@ it("uses the document layout with visible steps and no editing capabilities", as
expect(document.querySelector('[contenteditable="true"]')).toBeNull();
expect(within(document).queryByRole('button', { name: /Add step|Move step|Undo last edit/ })).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: 'Expand all' })).not.toBeInTheDocument();
- fireEvent.click(within(document).getByRole('button', { name: 'Workflow timing' }));
- expect(screen.getByRole('tooltip')).toHaveTextContent('Time not measured yet');
+ expect(within(document).queryByRole('button', { name: 'Workflow timing' })).not.toBeInTheDocument();
+ expect(within(step).queryByRole('button', { name: 'Timing for step 1' })).not.toBeInTheDocument();
+ expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
expect(service.stopLocal).not.toHaveBeenCalled();
});
diff --git a/apps/screenpipe-app-tauri/components/workflows/workflow-timing.test.tsx b/apps/screenpipe-app-tauri/components/workflows/workflow-timing.test.tsx
index 0064a0795..68eb300f6 100644
--- a/apps/screenpipe-app-tauri/components/workflows/workflow-timing.test.tsx
+++ b/apps/screenpipe-app-tauri/components/workflows/workflow-timing.test.tsx
@@ -30,6 +30,19 @@ describe("workflow elapsed timing", () => {
expect(screen.getByRole("tooltip")).toHaveTextContent("30m median duration");
expect(screen.getByRole("tooltip")).not.toHaveTextContent("on average");
});
+ it("omits empty timing in documents and shows the duration when evidence exists", () => {
+ const view = render(<TimingDisclosure value={null} label="Timing" hideWhenUnknown showDuration />);
+ expect(screen.queryByRole("button", { name: "Timing" })).not.toBeInTheDocument();
+ view.rerender(<TimingDisclosure value={workflow.timing} label="Timing" hideWhenUnknown showDuration />);
+ const trigger = screen.getByRole("button", { name: "Timing" });
+ expect(trigger).toHaveTextContent("24m");
+ fireEvent.click(trigger);
+ expect(screen.getByRole("tooltip")).toHaveTextContent("3 observed runs");
+ fireEvent.keyDown(trigger, { key: "Escape" });
+ expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
+ view.rerender(<TimingDisclosure value={null} label="Timing" hideWhenUnknown showDuration measured={{ minutes: 30, samples: 1 }} />);
+ expect(screen.queryByRole("button", { name: "Timing" })).not.toBeInTheDocument();
+ });
it("filters by average time, without classifying unknowns as short runs", () => {
const unknown = { ...workflow, timing: null, durationSource: "unknown" as const };
expect(filterWorkflows([workflow, unknown], { ...defaultWorkflowFilters, duration: "medium" })).toEqual([workflow]);
@@ -38,17 +51,15 @@ describe("workflow elapsed timing", () => {
it("keeps step timing tied to its source on reorder and hides stale timing while editing", async () => {
sessionStorage.clear();
render(<WorkflowEditor workflow={workflow} save={() => new Promise(() => {})} />);
- fireEvent.keyDown(screen.getByRole("button", { name: "Move step 1" }), { key: "ArrowDown", altKey: true });
+ fireEvent.keyDown(screen.getByRole("button", { name: "Step 1 actions" }), { key: "ArrowDown", altKey: true });
const moved = screen.getByRole("button", { name: "Timing for step 2" });
fireEvent.mouseEnter(moved);
expect(screen.getByRole("tooltip")).toHaveTextContent("5m on average");
fireEvent.mouseLeave(moved);
fireEvent.change(screen.getByRole("textbox", { name: "Step 2 title" }), { target: { value: "Different scope" } });
- fireEvent.mouseEnter(moved);
- expect(screen.getByRole("tooltip")).toHaveTextContent("Time not measured yet");
- fireEvent.mouseLeave(moved);
- fireEvent.mouseEnter(screen.getByRole("button", { name: "Workflow timing" }));
- expect(screen.getByRole("tooltip")).toHaveTextContent("Time not measured yet");
+ expect(screen.queryByRole("button", { name: "Timing for step 2" })).not.toBeInTheDocument();
+ expect(screen.queryByRole("button", { name: "Workflow timing" })).not.toBeInTheDocument();
+ expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
});
it("shows average, single and unknown cards without the removed evidence diagnostics", async () => {
window.history.replaceState(null, "", "/home?mode=workflows");
@@ -89,8 +100,7 @@ describe("workflow elapsed timing", () => {
expect(screen.getByRole("tooltip")).toHaveTextContent("5m on average");
expect(screen.getByRole("tooltip")).toHaveTextContent("2 observed runs · 4m to 6m");
fireEvent.mouseLeave(step);
- fireEvent.focus(screen.getByRole("button", { name: "Timing for step 2" }));
- expect(screen.getByRole("tooltip")).toHaveTextContent("Time not measured yet");
+ expect(screen.queryByRole("button", { name: "Timing for step 2" })).not.toBeInTheDocument();
// Removing diagnostic chrome must not discard the persisted run boundaries.
expect(workflowTiming(workflow.timing)).toMatchObject({ averageMinutes: 24, sampleCount: 3 });
});
diff --git a/apps/screenpipe-workflows-web/scripts/check-workflow-timing-browser.cjs b/apps/screenpipe-workflows-web/scripts/check-workflow-timing-browser.cjs
index 42c04cc1b..382e6a719 100644
--- a/apps/screenpipe-workflows-web/scripts/check-workflow-timing-browser.cjs
+++ b/apps/screenpipe-workflows-web/scripts/check-workflow-timing-browser.cjs
@@ -17,6 +17,7 @@ fs.mkdirSync(output, { recursive: true });
let page;
try {
page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
+ page.setDefaultTimeout(15000);
const errors = [];
page.on('pageerror', error => errors.push(error.message));
const base = process.env.WORKFLOW_TIMING_PREVIEW_URL || 'http://127.0.0.1:1420/home?mode=workflows';
@@ -42,25 +43,26 @@ fs.mkdirSync(output, { recursive: true });
const titleInput = page.getByRole('textbox', { name: 'Workflow title', exact: true });
await titleInput.waitFor();
const global = page.getByRole('button', { name: 'Workflow timing', exact: true });
+ await titleInput.hover();
await global.hover();
await page.getByRole('tooltip').getByText(`${average} on average`, { exact: true }).waitFor();
await page.screenshot({ path: path.join(output, 'workflow-hover.png') });
await titleInput.hover();
const first = page.getByRole('button', { name: 'Timing for step 1', exact: true });
+ await page.getByRole("textbox", { name: "Step 1 title", exact: true }).hover();
await first.hover();
await page.getByRole('tooltip').getByText(stepTime, { exact: true }).waitFor();
await page.screenshot({ path: path.join(output, 'step-hover.png') });
await first.focus();
await page.keyboard.press('Escape');
assert.equal(await page.getByRole('tooltip').count(), 0);
- const unknown = page.getByRole('button', { name: 'Timing for step 2', exact: true });
- await unknown.click();
- await page.getByRole('tooltip').getByText('Time not measured yet', { exact: true }).waitFor();
+ assert.equal(await page.getByRole('button', { name: 'Timing for step 2', exact: true }).count(), 0);
await titleInput.click();
assert.equal(await page.getByRole('tooltip').count(), 0);
// Keyboard reorder must keep the sampled timing with the step's source.
- await page.getByRole('button', { name: 'Move step 1', exact: true }).focus();
+ await page.getByRole('button', { name: 'Step 1 actions', exact: true }).focus();
await page.keyboard.press('Alt+ArrowDown');
+ await page.getByRole('textbox', { name: 'Step 2 title', exact: true }).hover();
await page.getByRole('button', { name: 'Timing for step 2', exact: true }).hover();
await page.getByRole('tooltip').getByText(stepTime, { exact: true }).waitFor();
// Wait for the real fixture adapter's autosave, then reload and reopen.
@@ -72,9 +74,11 @@ fs.mkdirSync(output, { recursive: true });
const reopenedCard = page.getByRole('heading', { name: title, exact: true }).locator('..');
await reopenedCard.getByRole('button', { name: 'Open map' }).click();
await page.getByRole('textbox', { name: 'Workflow title', exact: true }).waitFor();
+ await page.getByRole('textbox', { name: 'Step 2 title', exact: true }).hover();
await page.getByRole('button', { name: 'Timing for step 2', exact: true }).hover();
await page.getByRole('tooltip').getByText(stepTime, { exact: true }).waitFor();
await page.setViewportSize({ width: 700, height: 900 });
+ await page.getByRole('textbox', { name: 'Step 2 title', exact: true }).hover();
const clock = page.getByRole('button', { name: 'Timing for step 2', exact: true });
await clock.click();
const bounds = await page.getByRole('tooltip').boundingBox();
diff --git a/apps/screenpipe-workflows-web/scripts/eval-step-controls.cjs b/apps/screenpipe-workflows-web/scripts/eval-step-controls.cjs
new file mode 100644
index 000000000..49e467cb8
--- /dev/null
+++ b/apps/screenpipe-workflows-web/scripts/eval-step-controls.cjs
@@ -0,0 +1,147 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+const { chromium } = require("playwright");
+const assert = require("node:assert/strict");
+const fs = require("node:fs");
+const path = require("node:path");
+const url = process.env.WORKFLOWS_PREVIEW_URL || "http://127.0.0.1:1431/preview";
+const out = process.env.WORKFLOW_EDITOR_ARTIFACTS || path.join(require("node:os").tmpdir(), "workflow-step-controls");
+fs.mkdirSync(out, { recursive: true });
+(async () => {
+ const browser = await chromium.launch({ headless: true, channel: "chrome" });
+ try {
+ const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
+ page.setDefaultTimeout(15000);
+ const errors = [];
+ page.on("pageerror", e => errors.push(e.message));
+ const field = name => page.getByRole("textbox", { name, exact: true });
+ const button = name => page.getByRole("button", { name, exact: true });
+ const snap = name => page.screenshot({ path: path.join(out, `${name}.png`), animations: "disabled" });
+ const saved = () => page.getByRole("status", { name: "Save status" }).filter({ hasText: /^Saved$/ }).waitFor();
+ const stored = () => page.evaluate(() => JSON.parse(localStorage.getItem("screenpipe:fictional-workflow-editor-preview"))?.analysis.workflows.find(w => w.id === "Research synthesis"));
+ await page.goto(url, { timeout: 120000 });
+ await button("Open map").first().click();
+ await field("Workflow title").waitFor();
+ const handle = button("Step 1 actions");
+ await page.mouse.move(0, 0);
+ await page.waitForTimeout(200);
+ assert.equal(await handle.evaluate(e => getComputedStyle(e).opacity), "0");
+ assert.equal(await handle.evaluate(e => getComputedStyle(e).pointerEvents), "none");
+ await snap("after-idle");
+ const titleBounds = await field("Step 1 title").boundingBox();
+ await field("Step 1 title").hover();
+ await page.waitForTimeout(200);
+ assert.equal(await handle.evaluate(e => getComputedStyle(e).opacity), "1");
+ assert.equal(await button("Step 2 actions").evaluate(e => getComputedStyle(e).opacity), "0");
+ await snap("after-hover");
+ await handle.hover();
+ await snap("after-handle-hover");
+ await handle.click();
+ await page.getByRole("dialog", { name: "Actions for step 1" }).waitFor();
+ assert.deepEqual(await field("Step 1 title").boundingBox(), titleBounds);
+ await snap("after");
+ await button("Move step 1 down").focus();
+ await page.keyboard.press("Tab");
+ await snap("after-keyboard");
+ await page.keyboard.press("Escape");
+ assert(await handle.evaluate(e => e === document.activeElement));
+ assert.equal(await page.getByRole("dialog", { name: "Actions for step 1" }).count(), 0);
+ await snap("after-handle-focus");
+ await handle.click();
+ await field("Workflow title").click();
+ assert.equal(await page.getByRole("dialog", { name: "Actions for step 1" }).count(), 0);
+ await page.mouse.move(0, 0);
+ await page.waitForTimeout(200);
+ assert.equal(await handle.evaluate(e => getComputedStyle(e).opacity), "0");
+ await snap("after-mouse-leave");
+ console.log("PASS idle, hover, neighboring controls, focus, Escape, outside click, and stable layout");
+ const timing = button("Timing for step 1");
+ assert.equal(await timing.locator("..").evaluate(e => getComputedStyle(e).opacity), "0");
+ assert.equal(await button("Timing for step 2").count(), 0);
+ await field("Step 1 title").hover();
+ assert.equal(await timing.innerText(), "5m");
+ await timing.click();
+ await page.getByRole("tooltip").getByText("5m on average", { exact: true }).waitFor();
+ await snap("after-timing");
+ await page.keyboard.press("Escape");
+ assert.equal(await page.getByRole("tooltip").count(), 0);
+ await field("Workflow title").focus();
+ await timing.focus();
+ assert.equal(await timing.locator("..").evaluate(e => getComputedStyle(e).opacity), "1");
+ await page.keyboard.press("Escape");
+ console.log("PASS empty timing omitted; measured timing reveals on hover and keyboard focus");
+
+
+ await field("Workflow title").fill("Research brief");
+ await saved();
+ const before = await stored();
+ await field("Step 1 title").hover();
+ const insert = button("Add step after 1");
+ await insert.locator("..").hover();
+ await snap("after-insert");
+ await insert.click();
+ await page.waitForFunction(() => document.activeElement?.getAttribute("aria-label") === "Step 2 title");
+ await field("Step 2 title").fill("Review the sources");
+ await saved();
+ const inserted = await stored();
+ assert.equal(inserted.stages[1].name, "Review the sources");
+ assert.deepEqual(inserted.stages[0].evidence, before.stages[0].evidence);
+ assert.deepEqual(inserted.stages[2].evidence, before.stages[1].evidence);
+ await button("Step 2 actions").click();
+ await button("Delete step 2").click();
+ await saved();
+ assert.equal((await stored()).stages.length, before.stages.length);
+ console.log("PASS insert below, focused title, autosave, delete, and preserved sources");
+
+ await field("Step 1 title").hover();
+ await button("Add detail to step 1").click();
+ await page.waitForFunction(() => document.activeElement?.getAttribute("aria-label") === "Block 4 in step 1");
+ await field("Block 4 in step 1").fill("Check each source date.");
+ await saved();
+ assert.equal((await stored()).stages[0].procedure[3].text, "Check each source date.");
+ await handle.focus();
+ await page.keyboard.press("Alt+ArrowDown");
+ await saved();
+ assert.equal((await stored()).stages[1].name, "Collect sources");
+ await button("Step 2 actions").focus();
+ await page.keyboard.press("Alt+ArrowUp");
+ await saved();
+ await field("Step 1 title").hover();
+ // Keep both complete steps on screen for a real pointer drag.
+ await page.setViewportSize({ width: 1440, height: 1900 });
+ await handle.dragTo(field("Step 2 title"));
+ await saved();
+ assert.equal((await stored()).stages[1].name, "Collect sources");
+ assert.equal(await page.getByRole("dialog", { name: /^Actions for step/ }).count(), 0);
+ await button("Undo last edit").click();
+ await saved();
+ await page.reload();
+ await button("Open map").first().click();
+ assert.equal(await field("Step 1 title").inputValue(), "Collect sources");
+ assert.equal(await field("Workflow title").inputValue(), "Research brief");
+ console.log("PASS add block, keyboard and drag reorder, undo, reload persistence");
+
+ const context = await browser.newContext({ viewport: { width: 390, height: 900 }, isMobile: true, hasTouch: true, reducedMotion: "reduce" });
+ const touch = await context.newPage();
+ await touch.goto(url);
+ await touch.getByRole("button", { name: "Open map", exact: true }).first().tap();
+ const touchHandle = touch.getByRole("button", { name: "Step 1 actions", exact: true });
+ assert.equal(await touchHandle.evaluate(e => getComputedStyle(e).opacity), "1");
+ assert.equal(await touch.getByRole("button", { name: "Timing for step 2", exact: true }).count(), 0);
+ const touchTiming = touch.getByRole("button", { name: "Timing for step 1", exact: true });
+ await touchTiming.tap();
+ await touch.getByRole("tooltip").getByText("5m on average", { exact: true }).waitFor();
+ await touch.getByRole("textbox", { name: "Workflow title", exact: true }).tap();
+ await touchHandle.tap();
+ const menu = touch.getByRole("dialog", { name: "Actions for step 1" });
+ const bounds = await menu.boundingBox();
+ assert(bounds.x >= 0 && bounds.x + bounds.width <= 390);
+ await touch.screenshot({ path: path.join(out, "after-touch.png"), animations: "disabled" });
+ await touch.getByRole("button", { name: "Add step below", exact: true }).tap();
+ await touch.getByRole("textbox", { name: "Step 2 title", exact: true }).waitFor();
+ console.log("PASS narrow touch controls, menu bounds, insertion, reduced motion");
+ await context.close();
+ assert.deepEqual(errors, []);
+ console.log("PASS no browser exceptions");
+ } finally { await browser.close(); }
+})().catch(error => { console.error(error); process.exitCode = 1; });
diff --git a/apps/screenpipe-workflows-web/scripts/eval-workflow-editor.cjs b/apps/screenpipe-workflows-web/scripts/eval-workflow-editor.cjs
index 4dae8bc84..a918a9a4b 100644
--- a/apps/screenpipe-workflows-web/scripts/eval-workflow-editor.cjs
+++ b/apps/screenpipe-workflows-web/scripts/eval-workflow-editor.cjs
@@ -24,7 +24,7 @@ require("node:fs").mkdirSync(out, { recursive: true });
assert.equal(await button("Edit workflow").count(), 0);
assert.equal(await button("Edit steps").count(), 0);
assert.equal(await button("Save").count(), 0);
- assert.equal(await button("Move step 1").getAttribute("draggable"), "true");
+ assert.equal(await button("Step 1 actions").getAttribute("draggable"), "true");
});
await check("open questions launch focused feedback and preserve unanswered questions", async () => {
const question = "Who reviews the synthesis before it is shared?";
@@ -63,16 +63,16 @@ require("node:fs").mkdirSync(out, { recursive: true });
assert.equal(await page.getByText("Drag handles to reorder", { exact: false }).count(), 0);
await page.mouse.move(0, 0);
await page.waitForTimeout(150);
- assert.equal(await button("Move step 1").evaluate(e => getComputedStyle(e).opacity), "0");
+ assert.equal(await button("Step 1 actions").evaluate(e => getComputedStyle(e).opacity), "0");
assert.equal(await button("Move block 1 in step 1").evaluate(e => getComputedStyle(e).opacity), "0");
await field("Step 1 title").hover();
await page.waitForTimeout(150);
- assert.equal(await button("Move step 1").evaluate(e => getComputedStyle(e).opacity), "1");
- assert.equal(await button("Move step 2").evaluate(e => getComputedStyle(e).opacity), "0");
+ assert.equal(await button("Step 1 actions").evaluate(e => getComputedStyle(e).opacity), "1");
+ assert.equal(await button("Step 2 actions").evaluate(e => getComputedStyle(e).opacity), "0");
await page.mouse.move(0, 0);
- await button("Move step 2").focus();
+ await button("Step 2 actions").focus();
await page.waitForTimeout(150);
- assert.equal(await button("Move step 2").evaluate(e => getComputedStyle(e).opacity), "1");
+ assert.equal(await button("Step 2 actions").evaluate(e => getComputedStyle(e).opacity), "1");
await field("Workflow title").focus();
const references = page.getByRole("region", { name: "References for Collect sources", exact: true });
await references.getByText("1 source", { exact: true }).click();
@@ -115,7 +115,7 @@ require("node:fs").mkdirSync(out, { recursive: true });
});
await check("step controls stay reachable and dismiss with Escape or an outside click", async () => {
await field("Step 1 title").hover();
- const grip = button("Move step 1");
+ const grip = button("Step 1 actions");
const bounds = await grip.boundingBox();
await page.mouse.move(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, { steps: 12 });
assert.equal(await grip.evaluate(e => getComputedStyle(e).opacity), "1");
@@ -160,7 +160,7 @@ require("node:fs").mkdirSync(out, { recursive: true });
});
await check("drag step, auto-save and retain its screenshot", async () => {
await page.getByRole("article", { name: "Step 1", exact: true }).hover();
- await button("Move step 1").dragTo(field("Step 2 title"));
+ await button("Step 1 actions").dragTo(field("Step 2 title"));
assert.equal(await field("Step 2 title").inputValue(), "Collect sources");
await saved();
const workflow = await stored();
@@ -175,19 +175,19 @@ require("node:fs").mkdirSync(out, { recursive: true });
});
await check("successive saved reorders preserve source identity", async () => {
const before = await stored();
- await button("Move step 1").focus();
+ await button("Step 1 actions").focus();
await page.keyboard.press("Alt+ArrowDown");
await saved();
- await button("Move step 2").focus();
+ await button("Step 2 actions").focus();
await page.keyboard.press("Alt+ArrowDown");
await saved();
const after = await stored();
assert.equal(after.stages[2].name, "Collect sources");
assert.deepEqual(after.stages[2].screenshot, before.stages[0].screenshot);
- await button("Move step 3").focus();
+ await button("Step 3 actions").focus();
await page.keyboard.press("Alt+ArrowUp");
await saved();
- await button("Move step 2").focus();
+ await button("Step 2 actions").focus();
await page.keyboard.press("Alt+ArrowUp");
await saved();
assert.equal((await stored()).stages[0].name, "Collect sources");
@@ -201,14 +201,16 @@ require("node:fs").mkdirSync(out, { recursive: true });
await check("empty blocks remain drafts until filled", async () => {
const before = await stored();
await field("Step 1 title").hover();
- await button("Add block").first().click();
+ await button("Step 1 actions").click();
+ await button("Add block").click();
await page.getByText("Finish the empty block to save", { exact: true }).waitFor();
await page.waitForTimeout(850);
assert.equal((await stored()).revision, before.revision);
await field("Block 4 in step 1").fill("Gather the dated source links.");
await saved();
await field("Step 1 title").hover();
- await button("Add block").first().click();
+ await button("Step 1 actions").click();
+ await button("Add block").click();
await field("Block 5 in step 1").fill("Check the source author.");
await saved();
});
@@ -319,14 +321,16 @@ require("node:fs").mkdirSync(out, { recursive: true });
assert(await sources.evaluate(e => e.getBoundingClientRect().right <= innerWidth));
await context.close();
});
- await check("touch layout keeps controls hidden until a step is focused", async () => {
+ await check("touch layout exposes step actions without entering text", async () => {
const context = await browser.newContext({ viewport: { width: 390, height: 900 }, isMobile: true, hasTouch: true });
context.setDefaultTimeout(10000);
const touch = await context.newPage();
await touch.goto(process.env.WORKFLOWS_PREVIEW_URL || "http://127.0.0.1:1431/preview");
await touch.getByRole("button", { name: "Open map", exact: true }).first().tap();
- const grip = touch.getByRole("button", { name: "Move step 1", exact: true });
- assert.equal(await grip.evaluate(e => getComputedStyle(e).opacity), "0");
+ const grip = touch.getByRole("button", { name: "Step 1 actions", exact: true });
+ assert.equal(await grip.evaluate(e => getComputedStyle(e).opacity), "1");
+ await grip.tap();
+ await touch.getByRole("button", { name: "Add step below", exact: true }).waitFor();
await touch.getByRole("textbox", { name: "Step 1 title", exact: true }).tap();
await touch.waitForFunction(el => getComputedStyle(el).opacity === "1", await grip.elementHandle());
assert.equal(await grip.evaluate(e => getComputedStyle(e).opacity), "1");
diff --git a/docs/pr-assets/local-editor-parity/after-handle-focus.png b/docs/pr-assets/local-editor-parity/after-handle-focus.png
new file mode 100644
index 000000000..5675a5b01
Binary files /dev/null and b/docs/pr-assets/local-editor-parity/after-handle-focus.png differ
diff --git a/docs/pr-assets/local-editor-parity/after-handle-hover.png b/docs/pr-assets/local-editor-parity/after-handle-hover.png
new file mode 100644
index 000000000..fb5bce5dd
Binary files /dev/null and b/docs/pr-assets/local-editor-parity/after-handle-hover.png differ
diff --git a/docs/pr-assets/local-editor-parity/after-hover.png b/docs/pr-assets/local-editor-parity/after-hover.png
new file mode 100644
index 000000000..9aae6af9a
Binary files /dev/null and b/docs/pr-assets/local-editor-parity/after-hover.png differ
diff --git a/docs/pr-assets/local-editor-parity/after-idle.png b/docs/pr-assets/local-editor-parity/after-idle.png
new file mode 100644
index 000000000..3292a27c2
Binary files /dev/null and b/docs/pr-assets/local-editor-parity/after-idle.png differ
diff --git a/docs/pr-assets/local-editor-parity/after-insert.png b/docs/pr-assets/local-editor-parity/after-insert.png
new file mode 100644
index 000000000..9ae6a8a74
Binary files /dev/null and b/docs/pr-assets/local-editor-parity/after-insert.png differ
diff --git a/docs/pr-assets/local-editor-parity/after-keyboard.png b/docs/pr-assets/local-editor-parity/after-keyboard.png
new file mode 100644
index 000000000..a7eb158f3
Binary files /dev/null and b/docs/pr-assets/local-editor-parity/after-keyboard.png differ
diff --git a/docs/pr-assets/local-editor-parity/after-mouse-leave.png b/docs/pr-assets/local-editor-parity/after-mouse-leave.png
new file mode 100644
index 000000000..dbc9d65cc
Binary files /dev/null and b/docs/pr-assets/local-editor-parity/after-mouse-leave.png differ
diff --git a/docs/pr-assets/local-editor-parity/after-timing.png b/docs/pr-assets/local-editor-parity/after-timing.png
new file mode 100644
index 000000000..eefa17c1b
Binary files /dev/null and b/docs/pr-assets/local-editor-parity/after-timing.png differ
diff --git a/docs/pr-assets/local-editor-parity/after-touch.png b/docs/pr-assets/local-editor-parity/after-touch.png
new file mode 100644
index 000000000..37da916cb
Binary files /dev/null and b/docs/pr-assets/local-editor-parity/after-touch.png differ
diff --git a/docs/pr-assets/local-editor-parity/after.png b/docs/pr-assets/local-editor-parity/after.png
new file mode 100644
index 000000000..84ce2c0e0
Binary files /dev/null and b/docs/pr-assets/local-editor-parity/after.png differ
diff --git a/docs/pr-assets/local-editor-parity/before.png b/docs/pr-assets/local-editor-parity/before.png
new file mode 100644
index 000000000..21cd67d8d
Binary files /dev/null and b/docs/pr-assets/local-editor-parity/before.png differ
diff --git a/docs/pr-assets/local-editor-parity/capture.json b/docs/pr-assets/local-editor-parity/capture.json
new file mode 100644
index 000000000..2cd378886
--- /dev/null
+++ b/docs/pr-assets/local-editor-parity/capture.json
@@ -0,0 +1,30 @@
+{
+ "surface": "Maintained Workflows browser preview, real shared WorkflowEditor with fictional fixture data",
+ "route": "/preview -> Research synthesis",
+ "before_commit": "022d99748",
+ "after_source": "Source files in this PR",
+ "viewport": {
+ "width": 1440,
+ "height": 1000
+ },
+ "touch_viewport": {
+ "width": 390,
+ "height": 900
+ },
+ "theme": "Existing light Workflows palette",
+ "states": [
+ "before menu",
+ "after idle",
+ "after step hover",
+ "after handle hover",
+ "after menu",
+ "after keyboard menu focus",
+ "after handle focus",
+ "after mouse leave",
+ "after touch menu",
+ "after measured timing disclosure",
+ "after plus insertion"
+ ],
+ "installed_app_verified": false,
+ "revision": 2
+}
diff --git a/packages/workflows-ui/src/timing-disclosure.module.css b/packages/workflows-ui/src/timing-disclosure.module.css
index 03f9f974a..489b13a88 100644
--- a/packages/workflows-ui/src/timing-disclosure.module.css
+++ b/packages/workflows-ui/src/timing-disclosure.module.css
@@ -10,3 +10,5 @@
.content small { color: var(--muted); font-size: 11px; }
.anchor[data-above] { top: auto; bottom: 100%; padding-top: 0; padding-bottom: 4px; }
+
+.root .trigger.withDuration { width: auto; gap: 4px; white-space: nowrap; font: inherit; }
diff --git a/packages/workflows-ui/src/timing-disclosure.tsx b/packages/workflows-ui/src/timing-disclosure.tsx
index a4676b7cd..1127bf889 100644
--- a/packages/workflows-ui/src/timing-disclosure.tsx
+++ b/packages/workflows-ui/src/timing-disclosure.tsx
@@ -7,13 +7,16 @@ import { workflowTiming, formatTimingMinutes } from "./timing";
import styles from "./timing-disclosure.module.css";
/** Lightweight, local disclosure: no requests, timers or per-row document listeners. */
-export function TimingDisclosure({ value, label, measured }: {
+export function TimingDisclosure({ value, label, measured, hideWhenUnknown = false, showDuration = false }: {
value: unknown;
+ hideWhenUnknown?: boolean;
+ showDuration?: boolean;
label: string;
measured?: { minutes: number; samples: number };
}) {
const timing = workflowTiming(value);
const recording = !timing && measured && Number.isFinite(measured.minutes) && measured.minutes > 0 && measured.samples >= 2 ? measured : null;
+ const hasTiming = Boolean(timing || recording);
const [open, setOpen] = useState(false);
const [above, setAbove] = useState(false);
const [pinned, setPinned] = useState(false);
@@ -25,6 +28,7 @@ export function TimingDisclosure({ value, label, measured }: {
setOpen(true);
};
const close = () => { setOpen(false); setPinned(false); };
+ useEffect(() => { if (hideWhenUnknown && !hasTiming) close(); }, [hideWhenUnknown, hasTiming]);
useEffect(() => {
if (!pinned) return;
const dismiss = (event: PointerEvent) => {
@@ -33,14 +37,16 @@ export function TimingDisclosure({ value, label, measured }: {
document.addEventListener("pointerdown", dismiss);
return () => document.removeEventListener("pointerdown", dismiss);
}, [pinned]);
+ if (hideWhenUnknown && !timing && !recording) return null;
return <span ref={root} className={styles.root}
onMouseEnter={show} onMouseLeave={() => { if (!pinned && !root.current?.contains(document.activeElement)) setOpen(false); }}
onBlur={event => { if (!event.currentTarget.contains(event.relatedTarget as Node)) close(); }}
onKeyDown={event => { if (event.key === "Escape") { event.stopPropagation(); close(); } }}>
- <button type="button" className={styles.trigger} aria-label={label}
+ <button type="button" className={`${styles.trigger} ${showDuration ? styles.withDuration : ""}`} aria-label={label}
aria-expanded={open} aria-controls={open ? id : undefined} aria-describedby={open ? id : undefined}
onFocus={show} onClick={() => { if (pinned) close(); else { show(); setPinned(true); } }}>
<Clock3 size={15} aria-hidden="true" />
+ {showDuration && (timing || recording) && <span aria-hidden="true">{formatTimingMinutes(timing ? timing.averageMinutes : recording!.minutes)}</span>}
</button>
{open && <span className={styles.anchor} data-above={above || undefined}><span id={id} role="tooltip" className={styles.content}>
{timing ? <>
diff --git a/packages/workflows-ui/src/workflow-editor.module.css b/packages/workflows-ui/src/workflow-editor.module.css
index 0e9bd31c2..93219a3a6 100644
--- a/packages/workflows-ui/src/workflow-editor.module.css
+++ b/packages/workflows-ui/src/workflow-editor.module.css
@@ -43,25 +43,20 @@
.step { position: relative; padding: 4px 0; margin: 0 0 24px; border: 0; background: transparent; }
.step::before { content: ""; position: absolute; left: -30px; top: 0; bottom: 0; width: 30px; }
.step.drop { box-shadow: 0 -2px 0 var(--ink); }
-.stepTop { padding-right: 30px; position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: start; }
+.stepTop { position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: start; }
.number { padding-top: 7px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.step .title { font-family: var(--heading-font); min-width: 0; font-size: 17px; font-weight: 550; line-height: 1.4; }
.step > textarea, .step > div[data-testid="procedure-markdown"] { width: calc(100% - 24px); margin-left: 24px; }
.editor .grip {
-webkit-user-drag: element; cursor: grab; color: var(--muted); }
.editor .grip:active { cursor: grabbing; }
-.stepTop > .grip { position: absolute; left: -30px; top: 0; }
-.controls { position: relative; }
-.controls > summary { display: flex; align-items: center; justify-content: center; min-width: 28px; min-height: 28px; border-radius: 4px; color: var(--muted); list-style: none; cursor: pointer; }
-.controls > summary::-webkit-details-marker { display: none; }
-.controls > summary:hover { background: var(--soft); }
-.controls > summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
-.stepMenu { display: flex; position: absolute; top: 30px; right: 0; z-index: 3; padding: 4px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); box-shadow: 0 4px 12px #0000000d; }
-.controls[open] { opacity: 1; pointer-events: auto; z-index: 6; }
-.stepTop > .grip, .controls, .step > .add, .blockControls > .grip { opacity: 0; pointer-events: none; transition: opacity .12s ease; }
-.step:hover > .stepTop > .grip, .step:focus-within > .stepTop > .grip,
-.step:hover > .stepTop > .controls, .step:focus-within > .stepTop > .controls,
-.step:hover > .add, .step:focus-within > .add,
+.stepControls { position: absolute; left: -30px; top: 0; }
+.stepControls[data-open] { z-index: 6; }
+.stepMenu { display: flex; flex-direction: column; position: absolute; top: 32px; left: 0; z-index: 3; width: 200px; padding: 4px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); box-shadow: 0 4px 12px #0000000d; }
+.stepMenu > button { justify-content: flex-start; width: 100%; padding: 7px 6px; gap: 8px; }
+.stepControls > .grip, .blockControls > .grip { opacity: 0; pointer-events: none; transition: opacity .12s ease; }
+.step:hover > .stepTop > .stepControls > .grip, .step:focus-within > .stepTop > .stepControls > .grip,
+.stepControls[data-open] > .grip,
.block:hover > .blockControls > .grip, .block:focus-within > .blockControls > .grip,
.blockControls[data-open] > .grip { opacity: 1; pointer-events: auto; }
.blocks { margin-left: 24px; }
@@ -87,18 +82,18 @@
.source > details > summary svg { width: 12px; height: 12px; }
.source p, .source blockquote { font-size: 12px; line-height: 1.5; }
.source small { display: block; color: var(--muted); }
-.editor .add { position: absolute; top: 4px; right: 0; font-size: 0; gap: 0; }
.editor .addStep { margin: 0 0 12px 49px; padding: 4px 6px; color: var(--muted); }
.note { font-size: 11px; color: var(--muted); line-height: 1.5; padding: 0 5px; }
.error { padding: 12px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; line-height: 1.6; }
.srOnly { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
@media (hover: none) {
+ .stepControls > .grip, .blockControls > .grip { opacity: 1; pointer-events: auto; }
.kindLabel[data-kind="action"], .kindLabel svg { opacity: 1; }
.kindLabel select { min-height: 32px; }
.editor button { min-width: 32px; min-height: 32px; }
}
@media (prefers-reduced-motion: reduce) {
- .stepTop > .grip, .controls, .step > .add, .blockControls > .grip { transition: none; }
+ .stepControls > .grip, .blockControls > .grip { transition: none; }
}
@container workflow-editor (max-width: 560px) {
.intro .title { font-family: var(--heading-font); font-size: 25px; }
@@ -121,7 +116,6 @@
.titleRow > textarea { flex: 1; min-width: 0; }
.titleRow > span { margin-top: 6px; }
.stepActions { display: flex; align-items: flex-start; }
-.step:hover > .stepTop .controls, .step:focus-within > .stepTop .controls { opacity: 1; pointer-events: auto; }
.readOnlyText { display: block; padding: 3px 5px; color: var(--ink); font-size: 14px; line-height: 1.6; }
.titleRow > h1 { flex: 1; min-width: 0; padding: 3px 5px; }
@@ -140,3 +134,22 @@
.readOnlyKind { grid-column: 1; grid-row: 2; }
.stepApps { margin-left: 25px; }
}
+
+/* Plus insertion follows the web document: reveal in the gap between steps. */
+.insertion + .step { margin-bottom: 4px; }
+.insertion { position: relative; display: flex; align-items: center; height: 24px; margin-left: -30px; padding-left: 30px; }
+.insertion > button { position: absolute; left: 0; opacity: 0; pointer-events: none; }
+.insertion > span { width: 100%; border-top: 1px solid transparent; }
+.insertion:hover > button, .insertion:focus-within > button { opacity: 1; pointer-events: auto; }
+.insertion:hover > span, .insertion:focus-within > span { border-color: var(--line); }
+.editor .addDetail { margin: 4px 0 4px 25px; font-size: 12px; gap: 5px; }
+/* Keep measured timing available without a permanent clock on every row. */
+.stepActions > span, .titleRow > span { opacity: 0; pointer-events: none; }
+.step:hover > .stepTop > .stepActions > span, .step:focus-within > .stepTop > .stepActions > span,
+.titleRow:hover > span, .titleRow:focus-within > span { opacity: 1; pointer-events: auto; }
+@media (hover: none) {
+ .insertion > button, .stepActions > span, .titleRow > span { opacity: 1; pointer-events: auto; }
+}
+@container workflow-editor (max-width: 560px) {
+ .editor .addDetail { margin-left: 21px; }
+}
diff --git a/packages/workflows-ui/src/workflow-editor.tsx b/packages/workflows-ui/src/workflow-editor.tsx
index 1cc905bb7..dc6fff0fd 100644
--- a/packages/workflows-ui/src/workflow-editor.tsx
+++ b/packages/workflows-ui/src/workflow-editor.tsx
@@ -1,13 +1,12 @@
// screenpipe — AI that knows everything you've seen, said, or heard
// https://screenpipe.com
"use client";
-import { useEffect, useRef, useState, type ReactNode } from "react";
+import { Fragment, useEffect, useRef, useState, type ReactNode } from "react";
import {
ArrowDown,
ArrowUp,
GripVertical,
ChevronDown,
- MoreHorizontal,
Plus,
Trash2,
Undo2,
@@ -82,6 +81,9 @@ export function WorkflowEditor({ workflow, save, actions, renderSource, stepsOnl
const [announcement, setAnnouncement] = useState("");
const [dragOver, setDragOver] = useState<number | null>(null);
const [blockDragOver, setBlockDragOver] = useState<string | null>(null);
+ const [stepMenu, setStepMenu] = useState<string | null>(null);
+ const stepMenuTrigger = useRef<HTMLButtonElement | null>(null);
+ const draggedStep = useRef(false);
const [blockMenu, setBlockMenu] = useState<string | null>(null);
const blockMenuTrigger = useRef<HTMLButtonElement | null>(null);
useEffect(() => {
@@ -100,14 +102,17 @@ export function WorkflowEditor({ workflow, save, actions, renderSource, stepsOnl
}, [blockMenu]);
const editorRoot = useRef<HTMLElement | null>(null);
useEffect(() => {
+ if (!stepMenu) return;
const dismiss = (event: PointerEvent) => {
- editorRoot.current?.querySelectorAll<HTMLDetailsElement>("details[data-step-actions][open]").forEach(menu => {
- if (!(event.target instanceof Node) || !menu.contains(event.target)) menu.open = false;
- });
+ if (!(event.target instanceof Element) || !event.target.closest("[data-step-actions]")) setStepMenu(null);
};
document.addEventListener("pointerdown", dismiss);
return () => document.removeEventListener("pointerdown", dismiss);
- }, []);
+ }, [stepMenu]);
+ function closeStepMenu(restoreFocus = true) {
+ setStepMenu(null);
+ if (restoreFocus) stepMenuTrigger.current?.focus();
+ }
const dragging = useRef<{ stage: number; detail?: number } | null>(null);
const busy = useRef(false);
const mounted = useRef(true);
@@ -165,6 +170,32 @@ export function WorkflowEditor({ workflow, save, actions, renderSource, stepsOnl
setAnnouncement(`Block moved to position ${to + 1}`);
}
}
+ function addStage(index: number) {
+ if (draft.stages.length >= 100) return;
+ const stages = [...draft.stages];
+ stages.splice(index, 0, { key: crypto.randomUUID(), sourceIndex: null, name: "", description: "", procedure: [] });
+ change({ ...draft, stages });
+ closeStepMenu(false);
+ focusField(`Step ${index + 1} title`);
+ }
+ function addDetail(index: number) {
+ const stage = draft.stages[index];
+ if (stage.procedure.length >= 100 || (singleCheck && stage.procedure.length)) return;
+ stageChange(index, { ...stage, procedure: [...stage.procedure,
+ { key: crypto.randomUUID(), sourceIndex: null, kind: singleCheck ? "check" : "action", text: "" }],
+ });
+ closeStepMenu(false);
+ focusField(`Block ${stage.procedure.length + 1} in step ${index + 1}`);
+ }
+ function insertion(index: number) {
+ return <div className={styles.insertion}>
+ <button type="button" aria-label={index === 0 ? "Add step at start" : `Add step after ${index}`}
+ title="Add step" disabled={draft.stages.length >= 100} onClick={() => addStage(index)}>
+ <Plus size={16} aria-hidden="true" />
+ </button>
+ <span />
+ </div>;
+ }
function focusField(label: string) {
requestAnimationFrame(() =>
document
@@ -274,7 +305,7 @@ export function WorkflowEditor({ workflow, save, actions, renderSource, stepsOnl
<div className={styles.intro}>
<div className={styles.titleRow}>
{stepsOnly ? <h1 className={styles.title}>{workflow.title}</h1> : <Text title label="Workflow title" value={draft.title} onChange={title => change({ ...draft, title })} />}
- <TimingDisclosure label="Workflow timing" value={unchangedStages ? workflow.timing : null}
+ <TimingDisclosure hideWhenUnknown showDuration label="Workflow timing" value={unchangedStages ? workflow.timing : null}
measured={unchangedStages && workflow.durationSource === "measured-meeting" ? { minutes: workflow.totalMinutes, samples: workflow.durationSampleCount ?? 0 } : undefined} />
</div>
{stepsOnly ? <p className={styles.readOnlyText}>{workflow.description}</p> : <Text label="Workflow description" value={draft.description} onChange={description => change({ ...draft, description })} />}
@@ -286,9 +317,10 @@ export function WorkflowEditor({ workflow, save, actions, renderSource, stepsOnl
<div className={styles.stepsHeading}><strong>Steps</strong></div>
<div className={styles.steps}>
{draft.stages.map((stage, index) => (
+ <Fragment key={stage.key}>
+ {insertion(index)}
<article
className={`${styles.step} ${dragOver === index ? styles.drop : ""}`}
- key={stage.key}
aria-label={`Step ${index + 1}`}
onDragOver={(e) => {
if (
@@ -312,19 +344,38 @@ export function WorkflowEditor({ workflow, save, actions, renderSource, stepsOnl
}}
>
<div className={styles.stepTop}>
+ <div data-step-actions data-open={stepMenu === stage.key || undefined} className={styles.stepControls}
+ onBlur={event => { if (!event.currentTarget.contains(event.relatedTarget as Node)) setStepMenu(null); }}
+ onKeyDown={event => {
+ if (event.key === "Escape") {
+ event.preventDefault(); event.stopPropagation(); closeStepMenu();
+ }
+ }}>
<button
type="button"
className={styles.grip}
draggable
- title="Drag step. Alt + Up/Down to reorder."
- aria-label={`Move step ${index + 1}`}
+ title="Click for step actions. Drag or Alt + Up/Down to reorder."
+ aria-label={`Step ${index + 1} actions`}
+ aria-expanded={stepMenu === stage.key}
+ aria-haspopup="dialog"
+ onPointerDown={() => { draggedStep.current = false; }}
+ onClick={event => {
+ if (draggedStep.current) return;
+ stepMenuTrigger.current = event.currentTarget;
+ setStepMenu(stepMenu === stage.key ? null : stage.key);
+ setBlockMenu(null);
+ }}
onKeyDown={(e) => {
+ if (e.key === "Enter" || e.key === " ") draggedStep.current = false;
if (e.altKey && ["ArrowUp", "ArrowDown"].includes(e.key)) {
e.preventDefault();
moveStage(index, index + (e.key === "ArrowUp" ? -1 : 1));
}
}}
onDragStart={(e) => {
+ draggedStep.current = true;
+ setStepMenu(null);
dragging.current = { stage: index };
e.dataTransfer.effectAllowed = "move";
e.dataTransfer.setData("text/plain", "workflow-step");
@@ -337,6 +388,18 @@ export function WorkflowEditor({ workflow, save, actions, renderSource, stepsOnl
>
<GripVertical size={18} />
</button>
+ {stepMenu === stage.key && <div className={styles.stepMenu} role="dialog" aria-label={`Actions for step ${index + 1}`}>
+ <button type="button" disabled={draft.stages.length >= 100} onClick={() => addStage(index + 1)}><Plus size={15} />Add step below</button>
+ {(!singleCheck || !stage.procedure.length) && <button type="button" disabled={stage.procedure.length >= 100} onClick={() => addDetail(index)}><Plus size={15} />{singleCheck ? "Add expected result" : "Add block"}</button>}
+ <button type="button" aria-label={`Move step ${index + 1} up`} disabled={index === 0} onClick={() => { closeStepMenu(); moveStage(index, index - 1); }}><ArrowUp size={15} />Move up</button>
+ <button type="button" aria-label={`Move step ${index + 1} down`} disabled={index === draft.stages.length - 1} onClick={() => { closeStepMenu(); moveStage(index, index + 1); }}><ArrowDown size={15} />Move down</button>
+ <button type="button" aria-label={`Delete step ${index + 1}`} disabled={draft.stages.length === 1} onClick={() => {
+ closeStepMenu(false);
+ change({ ...draft, stages: draft.stages.filter((_, i) => i !== index) });
+ focusField(`Step ${Math.min(index + 1, draft.stages.length - 1)} title`);
+ }}><Trash2 size={15} />Delete step</button>
+ </div>}
+ </div>
<span className={styles.number}>
{String(index + 1).padStart(2, "0")}
</span>
@@ -347,49 +410,9 @@ export function WorkflowEditor({ workflow, save, actions, renderSource, stepsOnl
onChange={(name) => stageChange(index, { ...stage, name })}
/>
<div className={styles.stepActions}>
- <TimingDisclosure label={`Timing for step ${index + 1}`} value={stage.sourceIndex !== null &&
+ <TimingDisclosure hideWhenUnknown showDuration label={`Timing for step ${index + 1}`} value={stage.sourceIndex !== null &&
isUnchangedStage(stage, workflow.stages[stage.sourceIndex])
? workflow.stages[stage.sourceIndex]?.timing : null} />
- <details data-step-actions className={styles.controls} onKeyDown={event => {
- if (event.key === "Escape") {
- event.preventDefault(); event.stopPropagation();
- event.currentTarget.open = false;
- event.currentTarget.querySelector<HTMLElement>("summary")?.focus();
- }
- }}><summary aria-label={`Step ${index + 1} actions`} title="Step actions"><MoreHorizontal size={16} /></summary><div className={styles.stepMenu}>
- <button
- type="button"
- aria-label={`Move step ${index + 1} up`}
- title="Move up"
- disabled={index === 0}
- onClick={() => moveStage(index, index - 1)}
- >
- <ArrowUp size={15} />
- </button>
- <button
- type="button"
- aria-label={`Move step ${index + 1} down`}
- title="Move down"
- disabled={index === draft.stages.length - 1}
- onClick={() => moveStage(index, index + 1)}
- >
- <ArrowDown size={15} />
- </button>
- <button
- type="button"
- aria-label={`Delete step ${index + 1}`}
- title="Delete step"
- disabled={draft.stages.length === 1}
- onClick={() =>
- change({
- ...draft,
- stages: draft.stages.filter((_, i) => i !== index),
- })
- }
- >
- <Trash2 size={15} />
- </button>
- </div></details>
</div>
</div>
<Text
@@ -526,45 +549,21 @@ export function WorkflowEditor({ workflow, save, actions, renderSource, stepsOnl
</div>
))}
</div>
- {stage.sourceIndex !== null && workflow.stages[stage.sourceIndex] && <div className={styles.source}>{renderSource?.(workflow.stages[stage.sourceIndex])}</div>}
- {(!singleCheck || !stage.procedure.length) && <button
- type="button"
- className={styles.add}
- title="Add block"
- disabled={stage.procedure.length >= 100}
- onClick={() => {
- stageChange(index, {
- ...stage,
- procedure: [
- ...stage.procedure,
- { key: crypto.randomUUID(), sourceIndex: null, kind: singleCheck ? "check" : "action", text: "" },
- ],
- });
- focusField(
- `Block ${stage.procedure.length + 1} in step ${index + 1}`,
- );
- }}
- >
- <Plus size={14} />
- Add block
+ {(!singleCheck || !stage.procedure.length) && <button type="button" className={styles.addDetail}
+ aria-label={singleCheck ? `Add expected result to step ${index + 1}` : `Add detail to step ${index + 1}`}
+ disabled={stage.procedure.length >= 100} onClick={() => addDetail(index)}>
+ <Plus size={14} aria-hidden="true" />{singleCheck ? "Add expected result" : "Add detail"}
</button>}
+ {stage.sourceIndex !== null && workflow.stages[stage.sourceIndex] && <div className={styles.source}>{renderSource?.(workflow.stages[stage.sourceIndex])}</div>}
</article>
+ </Fragment>
))}
</div>
<button
type="button"
className={styles.addStep}
disabled={draft.stages.length >= 100}
- onClick={() => {
- change({
- ...draft,
- stages: [
- ...draft.stages,
- { key: crypto.randomUUID(), sourceIndex: null, name: "", description: "", procedure: [] },
- ],
- });
- focusField(`Step ${draft.stages.length + 1} title`);
- }}
+ onClick={() => addStage(draft.stages.length)}
>
<Plus size={16} />
Add step
@@ -602,7 +601,7 @@ export function WorkflowDocument({ workflow, actions, sourceLabel, renderSource
<div className={styles.intro}>
<div className={styles.titleRow}>
<h1 className={styles.title}>{workflow.title}</h1>
- <TimingDisclosure label="Workflow timing" value={workflow.timing}
+ <TimingDisclosure hideWhenUnknown showDuration label="Workflow timing" value={workflow.timing}
measured={workflow.durationSource === "measured-meeting" ? { minutes: workflow.totalMinutes, samples: workflow.durationSampleCount ?? 0 } : undefined} />
</div>
<p className={styles.readOnlyText}>{workflow.description}</p>
@@ -614,7 +613,7 @@ export function WorkflowDocument({ workflow, actions, sourceLabel, renderSource
<div className={styles.stepTop}>
<span className={styles.number}>{String(index + 1).padStart(2, "0")}</span>
<h2 className={`${styles.title} ${styles.readOnlyText}`}>{stage.name}</h2>
- <div className={styles.stepActions}><TimingDisclosure label={`Timing for step ${index + 1}`} value={stage.timing} /></div>
+ <div className={styles.stepActions}><TimingDisclosure hideWhenUnknown showDuration label={`Timing for step ${index + 1}`} value={stage.timing} /></div>
</div>
{stage.description && <WorkflowRichText label={`Step ${index + 1} description`} value={stage.description} />}
<div className={styles.blocks}>