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
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(workflows): preserve question discussions and polish editor controls
louisea6798b0b98a
diff --git a/apps/screenpipe-app-tauri/components/workflows/workflow-feedback.test.tsx b/apps/screenpipe-app-tauri/components/workflows/workflow-feedback.test.tsxindex 4a299805a..91c67dc5d 100644--- a/apps/screenpipe-app-tauri/components/workflows/workflow-feedback.test.tsx+++ b/apps/screenpipe-app-tauri/components/workflows/workflow-feedback.test.tsx@@ -1,7 +1,7 @@// screenpipe — AI that knows everything you've seen, said, or heard// https://screenpipe.comimport React from "react";-import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";+import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react";import { describe, expect, it, vi } from "vitest";import { WorkflowAssistant, emptyAssistantState, type WorkflowsAssistantPlatform } from "@screenpipe/workflows-ui";import { fixtureWorkflowAnalysis } from "@screenpipe/workflows-ui/fixture";@@ -24,12 +24,29 @@ function submit() {}describe("workflow feedback conversation", () => {+ it.each(["floating", "sidebar"] as const)("reopens a saved question and its draft in %s mode", async mode => {+ const saved = emptyAssistantState(); saved.mode = mode;+ const question = "Who reviews the synthesis?";+ saved.conversations.push({ id: "clarification", title: question, draft: "My unfinished answer", clarificationQuestion: question,+ feedbackContext: feedback, messages: [{ id: "q", role: "assistant", text: question, at: new Date().toISOString() }] });+ const { platform } = setup({ load: vi.fn().mockResolvedValue(saved) });+ const open = () => act(() => { window.dispatchEvent(new CustomEvent("workflows:feedback", { detail: { ...feedback, question } })); });+ open();+ await waitFor(() => expect(screen.getByRole("textbox", { name: "Ask Screenpipe" })).toHaveValue("My unfinished answer"));+ expect(screen.getByRole("region", { name: "Screenpipe assistant" })).toHaveAttribute("data-mode", mode);+ open();+ await waitFor(() => expect(vi.mocked(platform.save).mock.calls.at(-1)![0].activeId).toBe("clarification"));+ expect(vi.mocked(platform.save).mock.calls.at(-1)![0].conversations).toHaveLength(2);+ expect(platform.ask).not.toHaveBeenCalled();+ expect(platform.saveFeedback).not.toHaveBeenCalled();+ });+it("opens a selected question without an AI call and keeps its answer scoped after navigation", async () => {const saved = emptyAssistantState(); saved.conversations[0].draft = "Keep my draft";const { platform, props, rerender } = setup({ load: vi.fn().mockResolvedValue(saved) });const question = "Who reviews the synthesis before it is shared?";act(() => { window.dispatchEvent(new CustomEvent("workflows:feedback", { detail: { ...feedback, question } })); });- await screen.findByText(question);+ await within(screen.getByRole("log")).findByText(question);expect(platform.ask).not.toHaveBeenCalled();expect(platform.saveFeedback).not.toHaveBeenCalled();expect(screen.queryByRole("button", { name: "Save feedback" })).not.toBeInTheDocument();diff --git a/apps/screenpipe-workflows-web/scripts/eval-workflow-editor.cjs b/apps/screenpipe-workflows-web/scripts/eval-workflow-editor.cjsindex 289290dd5..dab948c44 100644--- a/apps/screenpipe-workflows-web/scripts/eval-workflow-editor.cjs+++ b/apps/screenpipe-workflows-web/scripts/eval-workflow-editor.cjs@@ -32,9 +32,14 @@ require("node:fs").mkdirSync(out, { recursive: true });await questions.getByRole("button", { name: question, exact: true }).focus();await page.keyboard.press("Enter");const chat = page.getByRole("region", { name: "Screenpipe assistant", exact: true });- await chat.getByText(question, { exact: true }).waitFor();+ await chat.getByRole("log").getByText(question, { exact: true }).waitFor();assert.equal(await chat.getByRole("button", { name: "Stop answer" }).count(), 0);assert.equal(await chat.getByRole("button", { name: "Save feedback" }).count(), 0);+ await chat.getByRole("textbox", { name: "Ask Screenpipe", exact: true }).fill("Keep this unfinished answer");+ await chat.getByRole("button", { name: "Minimize chat", exact: true }).click();+ await questions.getByRole("button", { name: question, exact: true }).click();+ assert.equal(await chat.getByRole("textbox", { name: "Ask Screenpipe", exact: true }).inputValue(), "Keep this unfinished answer");+ assert.equal(await chat.getByRole("log").getByText(question, { exact: true }).count(), 1);await page.screenshot({ path: out + "/question-chat.png" });await chat.getByRole("textbox", { name: "Ask Screenpipe", exact: true }).fill("The research lead reviews it before sharing.");await chat.getByRole("button", { name: "Send feedback", exact: true }).click();@@ -45,7 +50,7 @@ require("node:fs").mkdirSync(out, { recursive: true });const references = page.getByRole("region", { name: "References for Collect sources", exact: true });await references.getByText("Unresolved details", { exact: true }).click();await references.getByRole("button", { name: "Where should the source list be saved?", exact: true }).click();- await chat.getByText("Where should the source list be saved?", { exact: true }).waitFor();+ await chat.getByRole("log").getByText("Where should the source list be saved?", { exact: true }).waitFor();await chat.getByText("Collect sources", { exact: true }).waitFor();await chat.getByRole("button", { name: "Minimize chat", exact: true }).click();await references.getByText("Unresolved details", { exact: true }).click();@@ -87,6 +92,22 @@ 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("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 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");+ const actions = page.getByLabel("Step 1 actions", { exact: true });+ await actions.click();+ await button("Move step 1 down").focus();+ await page.keyboard.press("Escape");+ assert.equal(await button("Move step 1 down").isVisible(), false);+ assert.equal(await actions.evaluate(e => e === document.activeElement), true);+ await actions.click();+ await field("Workflow title").click();+ assert.equal(await button("Move step 1 down").isVisible(), false);+ });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");diff --git a/packages/workflows-ui/src/assistant.ts b/packages/workflows-ui/src/assistant.tsindex 64cbe4e36..3ae74ce67 100644--- a/packages/workflows-ui/src/assistant.ts+++ b/packages/workflows-ui/src/assistant.ts@@ -20,7 +20,7 @@ export type AssistantMessage = {status?: "stopped" | "error";feedbackSaved?: boolean;};-export type AssistantConversation = { id: string; title: string; messages: AssistantMessage[]; draft: string; pageKey?: string; feedbackContext?: AssistantContext };+export type AssistantConversation = { id: string; title: string; messages: AssistantMessage[]; draft: string; pageKey?: string; clarificationQuestion?: string; feedbackContext?: AssistantContext };export type AssistantState = {version: 1;mode: "floating" | "sidebar";diff --git a/packages/workflows-ui/src/workflow-assistant.tsx b/packages/workflows-ui/src/workflow-assistant.tsxindex a6ba1d210..6edd0bb18 100644--- a/packages/workflows-ui/src/workflow-assistant.tsx+++ b/packages/workflows-ui/src/workflow-assistant.tsx@@ -184,12 +184,14 @@ export function WorkflowAssistant({ platform, context, onDockChange, onWidthChanuseEffect(() => {if (!pendingFeedback || !loaded || busy || controller.current || consumedFeedback.current === pendingFeedback) return;consumedFeedback.current = pendingFeedback;- const fresh = { ...newAssistantConversation(), feedbackContext: pendingFeedback.context };- if (pendingFeedback.question) {+ const existing = pendingFeedback.question ? [...stateRef.current.conversations].reverse().find(c =>+ c.clarificationQuestion === pendingFeedback.question && c.feedbackContext?.key === pendingFeedback.context.key) : undefined;+ const fresh = existing ?? { ...newAssistantConversation(), feedbackContext: pendingFeedback.context, clarificationQuestion: pendingFeedback.question };+ if (pendingFeedback.question && !existing) {fresh.title = pendingFeedback.question.slice(0, 64);fresh.messages = [{ id: crypto.randomUUID(), role: "assistant", text: pendingFeedback.question, at: new Date().toISOString() }];}- update(current => ({ ...current, activeId: fresh.id, conversations: [...current.conversations, fresh] }));+ update(current => ({ ...current, activeId: fresh.id, conversations: existing ? current.conversations : [...current.conversations, fresh] }));setPendingFeedback(null);setIncludeContext(true);setError("");@@ -216,7 +218,7 @@ export function WorkflowAssistant({ platform, context, onDockChange, onWidthChansetBusy(true); setError(""); setHistoryOpen(false); setActivity("Starting…");follow.current = true; setAtBottom(true);const snapshot = update((s) => ({ ...s, conversations: s.conversations.map((c) => c.id !== current.id ? c : {- ...c, draft: retry ? c.draft : "", title: c.feedbackContext ? `Feedback: ${c.feedbackContext.title}` : history.length ? c.title : question.trim().slice(0, 64),+ ...c, draft: retry ? c.draft : "", title: c.clarificationQuestion ? c.title : c.feedbackContext ? `Feedback: ${c.feedbackContext.title}` : history.length ? c.title : question.trim().slice(0, 64),messages: [...history,{ id: userId, role: "user", feedbackSaved: alreadySavedFeedback || undefined, text: question.trim(), at: new Date().toISOString(), ...(turnContext ? { context: turnContext } : {}) },{ id: answerId, role: "assistant", text: "", at: new Date().toISOString() }],@@ -315,7 +317,7 @@ export function WorkflowAssistant({ platform, context, onDockChange, onWidthChan<header className={styles.header}><button className={styles.title} aria-label="Conversation history" aria-expanded={historyOpen} disabled={!loaded}title={conversation.messages.length ? conversation.title : "New chat"} onClick={() => { setHistoryOpen(!historyOpen); setDisplayOpen(false); }}>- <span>{feedbackContext ? "Feedback" : conversation.messages.length ? conversation.title : "New chat"}</span><ChevronDown size={13} />+ <span>{conversation.clarificationQuestion ? conversation.title : feedbackContext ? "Feedback" : conversation.messages.length ? conversation.title : "New chat"}</span><ChevronDown size={13} /></button><div className={styles.headerActions}><button aria-label="New conversation" title="New chat" disabled={busy || !loaded} onClick={newConversation}><SquarePen size={16} /></button>diff --git a/packages/workflows-ui/src/workflow-editor.module.css b/packages/workflows-ui/src/workflow-editor.module.cssindex c66154a66..68bc9541e 100644--- a/packages/workflows-ui/src/workflow-editor.module.css+++ b/packages/workflows-ui/src/workflow-editor.module.css@@ -40,6 +40,7 @@.stepsHeading strong { color: var(--muted); font-size: 11px; font-weight: 500; }.steps { margin: 0 0 4px; padding-left: 26px; }.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; }.number { padding-top: 7px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }@@ -54,7 +55,7 @@.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; }+.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,diff --git a/packages/workflows-ui/src/workflow-editor.tsx b/packages/workflows-ui/src/workflow-editor.tsxindex fbe9640b0..a394bd37b 100644--- a/packages/workflows-ui/src/workflow-editor.tsx+++ b/packages/workflows-ui/src/workflow-editor.tsx@@ -124,6 +124,16 @@ export function WorkflowEditor({ workflow, save, actions, renderSource }: {document.addEventListener("keydown", escape);return () => { document.removeEventListener("pointerdown", dismiss); document.removeEventListener("keydown", escape); };}, [blockMenu]);+ const editorRoot = useRef<HTMLElement | null>(null);+ useEffect(() => {+ 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;+ });+ };+ document.addEventListener("pointerdown", dismiss);+ return () => document.removeEventListener("pointerdown", dismiss);+ }, []);const dragging = useRef<{ stage: number; detail?: number } | null>(null);const busy = useRef(false);const mounted = useRef(true);@@ -234,6 +244,7 @@ export function WorkflowEditor({ workflow, save, actions, renderSource }: {}, [draft, dirty, valid, saving, error, workflow.revision]);return (<section+ ref={editorRoot}className={styles.editor}aria-label="Workflow document"onKeyDown={(e) => {@@ -357,7 +368,13 @@ export function WorkflowEditor({ workflow, save, actions, renderSource }: {value={stage.name}onChange={(name) => stageChange(index, { ...stage, name })}/>- <details className={styles.controls}><summary aria-label={`Step ${index + 1} actions`} title="Step actions"><MoreHorizontal size={16} /></summary><div className={styles.stepMenu}>+ <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}><buttontype="button"aria-label={`Move step ${index + 1} up`}diff --git a/packages/workflows-ui/src/workflow-question.module.css b/packages/workflows-ui/src/workflow-question.module.cssindex 78dec3f18..f55b8a1dc 100644--- a/packages/workflows-ui/src/workflow-question.module.css+++ b/packages/workflows-ui/src/workflow-question.module.css@@ -1,7 +1,11 @@/* screenpipe — AI that knows everything you've seen, said, or heard *//* https://screenpipe.com */-.question { display: flex; align-items: flex-start; gap: 9px; width: 100%; padding: 9px 6px; border: 0; border-radius: 4px; background: transparent; color: var(--ink, #171914); font: inherit; font-size: 13px; line-height: 1.5; text-align: left; cursor: pointer; }+.question { box-sizing: border-box; display: flex; align-items: flex-start; gap: 9px; width: 100%; padding: 9px 6px; border: 0; border-radius: 4px; background: transparent; color: var(--ink, #171914); font: inherit; font-size: 13px; line-height: 1.5; text-align: left; cursor: pointer; }.question span { flex: 1; min-width: 0; overflow-wrap: anywhere; }.question svg { flex-shrink: 0; margin-top: 3px; color: var(--muted, #78786f); }.question:hover { background: var(--soft, #f1f2ed); }.question:focus-visible { outline: 1px solid currentColor; outline-offset: 2px; }++.question > svg:last-child { opacity: 0; }+.question:hover > svg:last-child, .question:focus-visible > svg:last-child { opacity: 1; }+@media (hover: none) { .question { min-height: 44px; } .question > svg:last-child { opacity: 1; } }diff --git a/packages/workflows-ui/src/workflow-step-evidence.module.css b/packages/workflows-ui/src/workflow-step-evidence.module.cssindex ef21d3c5a..1fbed0add 100644--- a/packages/workflows-ui/src/workflow-step-evidence.module.css+++ b/packages/workflows-ui/src/workflow-step-evidence.module.css@@ -22,7 +22,7 @@.rawSource > summary > span:last-child { display: inline-flex; gap: 4px; align-items: center; }.rawText { max-height: 160px; overflow: auto; overscroll-behavior: contain; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; line-height: 1.6; padding: 10px 12px; background: var(--soft); border-radius: 4px; color: var(--muted); }.questions { font-size: 12px; color: var(--muted); }-.questions ul { padding-left: 18px; line-height: 1.6; }+.questions ul { margin: 0; padding: 0; list-style: none; line-height: 1.6; }.player { position: relative; padding-top: 22px; }.player > section { margin: 0 0 8px; border-radius: 6px; }.player .close { position: absolute; right: 0; top: -6px; }