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): stabilize block controls with click-open actions

louis89b32c32e8e4
diff --git a/apps/screenpipe-workflows-web/scripts/eval-workflow-editor.cjs b/apps/screenpipe-workflows-web/scripts/eval-workflow-editor.cjs
index b60c1cb80..eac3d89ec 100644
--- a/apps/screenpipe-workflows-web/scripts/eval-workflow-editor.cjs
+++ b/apps/screenpipe-workflows-web/scripts/eval-workflow-editor.cjs
@@ -62,6 +62,39 @@ require("node:fs").mkdirSync(out, { recursive: true });
await references.getByRole("img", { name: "Captured moment for Collect sources", exact: true }).waitFor();
await references.getByRole("button", { name: "Close recording for Collect sources" }).click();
});
+ await check("block handle reveals stable click-open actions without hover layout shifts", async () => {
+ const text = field("Block 1 in step 1");
+ const grip = button("Move block 1 in step 1");
+ const before = await text.boundingBox();
+ assert.equal(await page.getByRole("combobox", { name: "Block 1 type in step 1" }).count(), 0);
+ assert.equal(await button("Delete block 1 in step 1").count(), 0);
+ await text.hover();
+ const handle = await grip.boundingBox();
+ await page.mouse.move(handle.x + handle.width / 2, handle.y + handle.height / 2, { steps: 12 });
+ assert.equal(await grip.evaluate(e => getComputedStyle(e).opacity), "1");
+ assert.deepEqual(await text.boundingBox(), before);
+ await grip.click();
+ const menu = page.getByRole("dialog", { name: "Actions for block 1 in step 1" });
+ await menu.waitFor();
+ await page.mouse.move(0, 0);
+ assert.equal(await menu.isVisible(), true);
+ await page.getByRole("combobox", { name: "Block 1 type in step 1" }).selectOption("decision");
+ await saved();
+ assert.equal((await stored()).stages[0].procedure[0].kind, "decision");
+ await page.screenshot({ path: out + "/block-actions.png" });
+ await page.keyboard.press("Escape");
+ assert.equal(await menu.count(), 0);
+ assert(await grip.evaluate(e => document.activeElement === e));
+ await grip.click();
+ await field("Workflow title").click();
+ assert.equal(await menu.count(), 0);
+ await button("Undo last edit").click(); await saved();
+ await grip.focus(); await page.keyboard.press("Enter");
+ await button("Delete block 1 in step 1").click(); await saved();
+ assert.equal((await stored()).stages[0].procedure.length, initialBlocks.length - 1);
+ await button("Undo last edit").click(); await saved();
+ assert.deepEqual((await stored()).stages[0].procedure.map(p => p.text), initialBlocks);
+ });
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"));
@@ -189,6 +222,11 @@ require("node:fs").mkdirSync(out, { recursive: true });
const bad = await page.locator("main textarea, main button").evaluateAll(es => es.filter(e => e.getBoundingClientRect().width && (e.getBoundingClientRect().right > innerWidth + 1 || (e.tagName === "TEXTAREA" && e.scrollHeight > e.clientHeight + 3))).map(e => e.getAttribute("aria-label") || e.textContent));
assert.deepEqual(bad, []);
});
+ await button("Move block 1 in step 1").focus();
+ await page.keyboard.press("Enter");
+ const menu = page.getByRole("dialog", { name: "Actions for block 1 in step 1" });
+ assert(await menu.evaluate(e => { const r = e.getBoundingClientRect(); return r.left >= 0 && r.right <= innerWidth; }));
+ await page.keyboard.press("Escape");
await page.screenshot({ path: `${out}/inline-${width}.png` });
}
await check("legacy evidence is retained without procedure blocks or screenshots", async () => {
diff --git a/packages/workflows-ui/src/workflow-editor.module.css b/packages/workflows-ui/src/workflow-editor.module.css
index 454f13d0e..c66154a66 100644
--- a/packages/workflows-ui/src/workflow-editor.module.css
+++ b/packages/workflows-ui/src/workflow-editor.module.css
@@ -55,21 +55,24 @@
.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; }
-.stepTop > .grip, .controls, .step > .add, .block > button, .block .actionKind { opacity: 0; pointer-events: none; transition: opacity .12s ease; }
+.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,
-.block:hover > button, .block:focus-within > button,
-.block:hover .actionKind, .block:focus-within .actionKind { opacity: 1; pointer-events: auto; }
+.block:hover > .blockControls > .grip, .block:focus-within > .blockControls > .grip,
+.blockControls[data-open] > .grip { opacity: 1; pointer-events: auto; }
.blocks { margin-left: 24px; }
-.block { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 65px 28px; align-items: start; gap: 4px; margin: 2px 0; }
+.block { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 76px; align-items: start; gap: 4px; margin: 2px 0; }
.blockDrop { box-shadow: 0 -2px 0 var(--ink); }
-.block > .grip { position: absolute; left: -30px; top: 1px; }
+.block::before { content: ""; position: absolute; left: -30px; top: 0; bottom: 0; width: 30px; }
+.blockControls { position: absolute; left: -30px; top: 1px; }
+.blockControls[data-open] { z-index: 5; }
.block textarea { min-width: 0; grid-column: 1; grid-row: 1; }
-.block select { grid-column: 2; grid-row: 1; }
-.block > button:last-child { grid-column: 3; grid-row: 1; }
-.block select { width: 100%; appearance: none; font: inherit; font-size: 11px; color: var(--muted); border: 0; border-radius: 4px; padding: 7px 4px; background: transparent; cursor: pointer; }
-.block select:hover, .block select:focus { appearance: auto; background: var(--soft); }
+.kindLabel { grid-column: 2; grid-row: 1; padding: 8px 4px; font-size: 11px; line-height: 1.4; color: var(--muted); pointer-events: none; }
+.blockMenu { position: absolute; left: 0; top: 29px; box-sizing: border-box; width: 200px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); box-shadow: 0 4px 12px #00000012; }
+.blockMenu label { display: block; padding: 4px; font-size: 11px; color: var(--muted); }
+.blockMenu select { display: block; box-sizing: border-box; width: 100%; margin-top: 6px; border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; font: inherit; font-size: 13px; color: var(--ink); background: var(--panel); }
+.blockMenu > button { justify-content: flex-start; width: 100%; padding: 7px 4px; }
.source { margin: 2px 0 0 29px; }
.source > details { margin: 0; border: 0; border-radius: 0; background: transparent; }
.source > details > summary { min-height: 26px; width: fit-content; padding: 2px 0; gap: 6px; color: var(--muted); }
@@ -86,7 +89,7 @@
.editor button { min-width: 32px; min-height: 32px; }
}
@media (prefers-reduced-motion: reduce) {
- .stepTop > .grip, .controls, .step > .add, .block > button, .block .actionKind { transition: none; }
+ .stepTop > .grip, .controls, .step > .add, .blockControls > .grip { transition: none; }
}
@container workflow-editor (max-width: 560px) {
.intro .title { font-size: 25px; }
@@ -95,8 +98,7 @@
.step > textarea { width: calc(100% - 20px); margin-left: 20px; }
.blocks { margin-left: 20px; }
.source { margin-left: 25px; }
- .block { grid-template-columns: minmax(0, 1fr) 28px; }
+ .block { grid-template-columns: minmax(0, 1fr); }
.block textarea { grid-column: 1; grid-row: 1; }
- .block select { grid-column: 1; grid-row: 2; width: 85px; padding-top: 2px; padding-bottom: 2px; }
- .block > button:last-child { grid-column: 2; grid-row: 1; }
+ .kindLabel { grid-column: 1; grid-row: 2; padding: 0 5px 3px; }
}
diff --git a/packages/workflows-ui/src/workflow-editor.tsx b/packages/workflows-ui/src/workflow-editor.tsx
index 4d3909a39..fbe9640b0 100644
--- a/packages/workflows-ui/src/workflow-editor.tsx
+++ b/packages/workflows-ui/src/workflow-editor.tsx
@@ -10,7 +10,6 @@ import {
Plus,
Trash2,
Undo2,
- X,
} from "lucide-react";
import type { WorkflowMap, WorkflowStage } from "./model";
import {
@@ -109,6 +108,22 @@ export function WorkflowEditor({ workflow, save, actions, renderSource }: {
const [announcement, setAnnouncement] = useState("");
const [dragOver, setDragOver] = useState<number | null>(null);
const [blockDragOver, setBlockDragOver] = useState<string | null>(null);
+ const [blockMenu, setBlockMenu] = useState<string | null>(null);
+ const blockMenuTrigger = useRef<HTMLButtonElement | null>(null);
+ useEffect(() => {
+ if (!blockMenu) return;
+ const dismiss = (event: PointerEvent) => {
+ if (!(event.target instanceof Element) || !event.target.closest("[data-block-actions]")) setBlockMenu(null);
+ };
+ const escape = (event: KeyboardEvent) => {
+ if (event.key === "Escape") {
+ event.preventDefault(); setBlockMenu(null); blockMenuTrigger.current?.focus();
+ }
+ };
+ document.addEventListener("pointerdown", dismiss);
+ document.addEventListener("keydown", escape);
+ return () => { document.removeEventListener("pointerdown", dismiss); document.removeEventListener("keydown", escape); };
+ }, [blockMenu]);
const dragging = useRef<{ stage: number; detail?: number } | null>(null);
const busy = useRef(false);
const mounted = useRef(true);
@@ -412,11 +427,15 @@ export function WorkflowEditor({ workflow, save, actions, renderSource }: {
}
}}
>
+ <div className={styles.blockControls} data-block-actions data-open={blockMenu === detail.key || undefined}>
<button
className={styles.grip}
type="button"
draggable
- title="Drag block. Alt + Up/Down to reorder."
+ title="Drag to move. Click for block actions."
+ aria-expanded={blockMenu === detail.key}
+ aria-haspopup="dialog"
+ onClick={(event) => { blockMenuTrigger.current = event.currentTarget; setBlockMenu(blockMenu === detail.key ? null : detail.key); }}
aria-label={`Move block ${detailIndex + 1} in step ${index + 1}`}
onKeyDown={(e) => {
if (
@@ -433,6 +452,7 @@ export function WorkflowEditor({ workflow, save, actions, renderSource }: {
}}
onDragStart={(e) => {
e.stopPropagation();
+ setBlockMenu(null);
dragging.current = {
stage: index,
detail: detailIndex,
@@ -447,8 +467,10 @@ export function WorkflowEditor({ workflow, save, actions, renderSource }: {
>
<GripVertical size={15} />
</button>
+ {blockMenu === detail.key && <div role="dialog" aria-label={`Actions for block ${detailIndex + 1} in step ${index + 1}`} className={styles.blockMenu}>
+ <label>Block type
<select
- className={detail.kind === "action" ? styles.actionKind : undefined}
+ autoFocus
aria-label={`Block ${detailIndex + 1} type in step ${index + 1}`}
value={detail.kind}
onChange={(e) =>
@@ -468,6 +490,26 @@ export function WorkflowEditor({ workflow, save, actions, renderSource }: {
),
)}
</select>
+ </label>
+ <button
+ type="button"
+ title="Delete block"
+ aria-label={`Delete block ${detailIndex + 1} in step ${index + 1}`}
+ onClick={() => {
+ setBlockMenu(null);
+ stageChange(index, {
+ ...stage,
+ procedure: stage.procedure.filter(
+ (_, i) => i !== detailIndex,
+ ),
+ });
+ }}
+ >
+ <Trash2 size={14} />Delete block
+ </button>
+ </div>}
+ </div>
+ {detail.kind !== "action" && <span className={styles.kindLabel}>{detail.kind}</span>}
<Text
label={`Block ${detailIndex + 1} in step ${index + 1}`}
placeholder="Write a step detail…"
@@ -481,21 +523,7 @@ export function WorkflowEditor({ workflow, save, actions, renderSource }: {
})
}
/>
- <button
- type="button"
- title="Delete block"
- aria-label={`Delete block ${detailIndex + 1} in step ${index + 1}`}
- onClick={() =>
- stageChange(index, {
- ...stage,
- procedure: stage.procedure.filter(
- (_, i) => i !== detailIndex,
- ),
- })
- }
- >
- <X size={15} />
- </button>
+
</div>
))}
</div>