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 enrichment handoffs and report actual update coverage
louis1cc5b2589804
diff --git a/apps/screenpipe-app-tauri/app/dev/workflows-ux/page.tsx b/apps/screenpipe-app-tauri/app/dev/workflows-ux/page.tsxindex eb1976237..b7da57bcb 100644--- a/apps/screenpipe-app-tauri/app/dev/workflows-ux/page.tsx+++ b/apps/screenpipe-app-tauri/app/dev/workflows-ux/page.tsx@@ -20,6 +20,11 @@ for (const workflow of legacyAnalysis.analysis.workflows) {}}const legacyFixture = createFixtureWorkflowsPlatform(legacyAnalysis);+const unchangedAnalysis: WorkflowAnalysis = { ...fixtureWorkflowAnalysis,+ analyzedAt: "2026-09-17T17:55:00Z", checkedThrough: "2026-09-16T21:08:00Z", changes: {created:0,updated:0} };+const unchangedFixture = { ...createFixtureWorkflowsPlatform(unchangedAnalysis), managesAnalysis:true,+ getLatestAnalysisJob: async () => ({id:"unchanged-preview",status:"complete" as const,result:unchangedAnalysis}) };+// Fictional receipt for the installed-state design only; no filesystem calls.const installedSkillFixture = { ...fixture, skillInstallMode: "local" as const,saveWorkflowSkill: async (draft: WorkflowSkillDraft) => ({ name: draft.name, path: `/example/skills/${draft.name}/SKILL.md`, updated: false,@@ -44,17 +49,17 @@ const processingFixture = { ...fixture, managesAnalysis: true,// This route never enables fixtures in a packaged application.export default function WorkflowUxPreview() {const [accessRequested, setAccessRequested] = useState(false);- const [screen, setScreen] = useState<"onboarding" | "empty" | "catalog" | "processing" | "tasks" | "skill" | "allowance" | "business" | "legacy">("processing");+ const [screen, setScreen] = useState<"onboarding" | "empty" | "catalog" | "processing" | "tasks" | "skill" | "allowance" | "business" | "legacy" | "no-changes">("processing");if (process.env.NEXT_PUBLIC_SCREENPIPE_WEB_DEV !== "mock") return null;return <div className="h-screen bg-background text-foreground"><nav aria-label="Preview states" className="flex h-10 items-center justify-between gap-4 border-b border-border px-4 text-xs"><span className="text-muted-foreground">UX preview · fictional data</span>- <div className="flex gap-4"><button onClick={() => setScreen("legacy")}>SOP screenshots</button><button onClick={() => setScreen("allowance")}>Low allowance</button><button onClick={() => setScreen("business")}>Business access</button><button onClick={() => setScreen("skill")}>Skill install result</button><button onClick={() => setScreen("tasks")}>Enable tasks</button><button onClick={() => setScreen("onboarding")}>First task</button><button onClick={() => setScreen("empty")}>New history</button><button onClick={() => setScreen("catalog")}>Existing history</button><button onClick={() => setScreen("processing")}>Processing preview</button></div>+ <div className="flex gap-4"><button onClick={() => setScreen("no-changes")}>No changes</button><button onClick={() => setScreen("legacy")}>SOP screenshots</button><button onClick={() => setScreen("allowance")}>Low allowance</button><button onClick={() => setScreen("business")}>Business access</button><button onClick={() => setScreen("skill")}>Skill install result</button><button onClick={() => setScreen("tasks")}>Enable tasks</button><button onClick={() => setScreen("onboarding")}>First task</button><button onClick={() => setScreen("empty")}>New history</button><button onClick={() => setScreen("catalog")}>Existing history</button><button onClick={() => setScreen("processing")}>Processing preview</button></div></nav><WorkflowTasksPrompt active={screen === "tasks"} tasks={previewTasks} /><div style={{height:"calc(100vh - 40px)", overflow:"auto"}}>{screen === "onboarding" ? <div className="flex min-h-full items-center"><FirstTaskChoice onComplete={async (mode) => { if(mode === "screenpipe") window.location.assign("/home?mode=screenpipe"); else setScreen("empty"); }} /></div>- : <WorkflowsApp onAnalysisUnavailable={() => setAccessRequested(true)} analysisUnavailableReason={screen === "allowance" || screen === "business" ? "Workflow updates are paused" : undefined} key={screen} statusNotice={screen === "allowance" || screen === "business" ? <WorkflowAccessNotice open={accessRequested} onOpenChange={setAccessRequested} access={screen === "allowance" ? {state:"paused",resetAt:undefined,message:"Workflow updates are paused to preserve AI allowance for chat."} : {state:"upgrade",message:"Automatic workflow discovery is included with Business. Your saved workflows remain available."}} onRetry={() => {}} onAccount={() => {}} onUsage={() => {}} /> : undefined} platform={screen === "legacy" ? legacyFixture : screen === "processing" ? processingFixture : screen === "skill" ? installedSkillFixture : fixture} storageKey={null} initialAnalysis={screen === "legacy" ? legacyAnalysis : (screen === "catalog" || screen === "tasks" || screen === "skill" || screen === "processing" || screen === "allowance" || screen === "business") ? fixtureWorkflowAnalysis : null} navigationBrand={<ProductSwitcher mode="workflows" onChange={mode => {if(mode === "screenpipe") window.location.assign("/home?mode=screenpipe");}} />} />}+ : <WorkflowsApp onAnalysisUnavailable={() => setAccessRequested(true)} analysisUnavailableReason={screen === "allowance" || screen === "business" ? "Workflow updates are paused" : undefined} key={screen} statusNotice={screen === "allowance" || screen === "business" ? <WorkflowAccessNotice open={accessRequested} onOpenChange={setAccessRequested} access={screen === "allowance" ? {state:"paused",resetAt:undefined,message:"Workflow updates are paused to preserve AI allowance for chat."} : {state:"upgrade",message:"Automatic workflow discovery is included with Business. Your saved workflows remain available."}} onRetry={() => {}} onAccount={() => {}} onUsage={() => {}} /> : undefined} platform={screen === "no-changes" ? unchangedFixture : screen === "legacy" ? legacyFixture : screen === "processing" ? processingFixture : screen === "skill" ? installedSkillFixture : fixture} storageKey={null} initialAnalysis={screen === "no-changes" ? unchangedAnalysis : screen === "legacy" ? legacyAnalysis : (screen === "catalog" || screen === "tasks" || screen === "skill" || screen === "processing" || screen === "allowance" || screen === "business") ? fixtureWorkflowAnalysis : null} navigationBrand={<ProductSwitcher mode="workflows" onChange={mode => {if(mode === "screenpipe") window.location.assign("/home?mode=screenpipe");}} />} />}</div></div>;}diff --git a/apps/screenpipe-app-tauri/components/workflows/workflow-run-progress.test.tsx b/apps/screenpipe-app-tauri/components/workflows/workflow-run-progress.test.tsxindex e428a0c9d..97fb820cc 100644--- a/apps/screenpipe-app-tauri/components/workflows/workflow-run-progress.test.tsx+++ b/apps/screenpipe-app-tauri/components/workflows/workflow-run-progress.test.tsx@@ -41,7 +41,7 @@ it("cleans up late subscriptions and ignores stale events after switching runs",it("shows no-change success and never labels a failed run with older change counts", () => {const view = render(<WorkflowRunProgress active={false} job={{ id: "1", status: "complete" }} changes={{ created: 0, updated: 0 }} analyze={vi.fn()} />);- expect(screen.getByRole("status")).toHaveTextContent("Up to date");+ expect(screen.getByRole("status")).toHaveTextContent("No changes saved");view.rerender(<WorkflowRunProgress active={false} job={{ id: "2", status: "failed" }} changes={{ created: 0, updated: 2 }} analyze={vi.fn()} />);expect(screen.getByRole("status")).toHaveTextContent("Update failed");expect(screen.queryByText("0 new · 2 updated")).not.toBeInTheDocument();@@ -55,3 +55,12 @@ it("shows an incomplete pipeline as resumable without claiming the catalog savedfireEvent.click(screen.getByRole("button", { name: "Resume update" }));expect(analyze).toHaveBeenCalledOnce();});++it("shows actual reviewed coverage after reload rather than calling yesterday's batch current", () => {+ render(<WorkflowRunProgress active={false} updatedAt="2026-09-17T17:55:00Z" checkedThrough="2026-09-16T21:08:00Z" changes={{created:0,updated:0}} analyze={vi.fn()} />);+ expect(screen.getByRole("status")).toHaveTextContent("No changes saved");+ expect(screen.getByRole("status")).toHaveTextContent("Sep 16");+ fireEvent.click(screen.getByRole("button",{name:/Show agent activity/}));+ expect(screen.getByRole("region",{name:"Agent activity"})).toHaveTextContent("Data reviewed through");+ expect(screen.queryByText(/Waiting for the next agent/)).not.toBeInTheDocument();+});diff --git a/apps/screenpipe-app-tauri/lib/workflows/scheduled-discovery.test.ts b/apps/screenpipe-app-tauri/lib/workflows/scheduled-discovery.test.tsindex c94b029c1..0b7d3baa2 100644--- a/apps/screenpipe-app-tauri/lib/workflows/scheduled-discovery.test.ts+++ b/apps/screenpipe-app-tauri/lib/workflows/scheduled-discovery.test.ts@@ -138,3 +138,8 @@ describe("workflow scheduled-task adapter", () => {});vi.mock("@/lib/workflows/rollout", () => ({ useWorkflowsRolloutEnabled: () => true, requireWorkflowsRollout: vi.fn() }));++it("offers resume for a restart interruption, including executions stored as failed", async () => {+ fetchMock.mockResolvedValueOnce(response({data:{id:51,status:"failed",error_type:"interrupted",error_message:"interrupted by system restart"}}));+ expect(await getWorkflowJob("51")).toMatchObject({status:"incomplete",message:expect.stringContaining("Screenpipe restarted")});+});diff --git a/apps/screenpipe-app-tauri/lib/workflows/scheduled-discovery.ts b/apps/screenpipe-app-tauri/lib/workflows/scheduled-discovery.tsindex 5c412b318..d1efbc94d 100644--- a/apps/screenpipe-app-tauri/lib/workflows/scheduled-discovery.ts+++ b/apps/screenpipe-app-tauri/lib/workflows/scheduled-discovery.ts@@ -55,11 +55,13 @@ export async function loadScheduledCatalog(): Promise<WorkflowAnalysis | null> {}function job(execution: any): WorkflowAnalysisJob {- const status = execution.status === "completed" ? "complete"+ const interrupted = execution.error_type === "interrupted" || execution.status === "interrupted";+ const status = interrupted ? "incomplete" : execution.status === "completed" ? "complete": ["failed", "cancelled", "interrupted", "timed_out"].includes(execution.status) ? "failed": execution.status === "running" ? "processing" : "queued";return { id: String(execution.id), status, startedAt: execution.started_at,- message: execution.status === "cancelled" ? "Update stopped. Your saved workflows are still available."+ message: interrupted ? "Screenpipe restarted during the update. Resume to continue from saved progress."+ : execution.status === "cancelled" ? "Update stopped. Your saved workflows are still available.": String(`${execution.error_type || ""} ${execution.error_message || ""}`).includes("workflow_allowance_paused") ? "Workflow updates paused to preserve AI allowance. Manage usage to increase capacity or check reset times.": String(`${execution.error_type || ""} ${execution.error_message || ""}`).includes("workflow_business_required") ? "Automatic workflow discovery requires Business. Your saved workflows are still available.": String(`${execution.error_type || ""} ${execution.error_message || ""}`).includes("workflow_usage_unavailable") ? "Could not check AI allowance. Reconnect and try again."diff --git a/apps/screenpipe-app-tauri/lib/workflows/workflow-save-contract.test.ts b/apps/screenpipe-app-tauri/lib/workflows/workflow-save-contract.test.tsindex 43f0ecc0e..c009d6a3b 100644--- a/apps/screenpipe-app-tauri/lib/workflows/workflow-save-contract.test.ts+++ b/apps/screenpipe-app-tauri/lib/workflows/workflow-save-contract.test.ts@@ -1,7 +1,7 @@// screenpipe — AI that knows everything you've seen, said, or heard// https://screenpipe.comimport { afterEach, expect, it, vi } from "vitest";-import workflowCatalog from "@screenpipe-ext/workflow-catalog";+import workflowCatalog, { validateStageHandoff } from "@screenpipe-ext/workflow-catalog";import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from "node:fs";import { tmpdir } from "node:os";import { join } from "node:path";@@ -9,17 +9,17 @@ const directories: string[] = [];const priorExitCode = process.exitCode;afterEach(() => { vi.restoreAllMocks(); vi.unstubAllGlobals(); process.exitCode = priorExitCode; for (const dir of directories.splice(0)) rmSync(dir, { recursive: true, force: true }); });const stopped = { messages: [{ role: "assistant", stopReason: "stop" }] };-async function harness() {+async function harness(stage = 4, items: any[] = []) {const events: Record<string, (event?: any, ctx?: any) => Promise<any>> = {};const tools: Record<string, any> = {};const pi = { on: (name: string, run: any) => { events[name] = run; }, registerTool: (tool: any) => { tools[tool.name] = tool; }, setActiveTools: vi.fn(), sendMessage: vi.fn() };workflowCatalog(pi as any);const parent = mkdtempSync(join(tmpdir(), "workflow-save-test-"));directories.push(parent);- const cwd = join(parent, "workflow-discovery"); mkdirSync(cwd);+ const cwd = join(parent, ["workflow-activity", "workflow-patterns", "workflow-procedures", "workflow-timing", "workflow-discovery"][stage]); mkdirSync(cwd);writeFileSync(join(cwd, ".screenpipe-permissions.json"), JSON.stringify({ pipe_token: "fixture", api_base: "http://127.0.0.1:3030" }));await events.session_start({}, { cwd });- const context = { revision: 3, now: "2026-09-15T12:00:00Z", ready: true, inputRevision: 2, checkedThrough: "2026-09-15T12:00:00Z" };+ const context = { stage, input: {items, coverage: []}, revision: 3, now: "2026-09-15T12:00:00Z", ready: true, inputRevision: 2, checkedThrough: "2026-09-15T12:00:00Z" };const fetch = vi.fn().mockImplementation(async () => Response.json(context));vi.stubGlobal("fetch", fetch);await tools.workflow_context.execute("context", {});@@ -112,3 +112,34 @@ it("allows a missing capture to be omitted without blocking a supported update",h.fetch.mockResolvedValueOnce(Response.json({revision:4,checkedThrough:h.context.now}));await expect(h.commit()).resolves.toBeDefined();});++it("preserves every candidate through timing, even when one occurrence cannot be measured", () => {+ const known = {candidateId: "invoice", workflowId: "wf-invoice", concreteSteps: ["Save receipt"], sources: [{timestamp:"2026-09-16T10:00:00Z",app:"Receipts",quote:"Receipt saved"}]};+ const unknown = {candidateId: "follow-up", workflowId: "wf-follow-up", concreteSteps: ["Draft follow-up"]};+ const pipeline = {stage:3,input:{items:[known,unknown]}};+ const measured = {...known,timingRuns:[{start:{timestamp:"2026-09-16T09:58:00Z",app:"Receipts",quote:"Start receipt"},end:known.sources[0],summary:"Save one receipt"}]};+ expect(() => validateStageHandoff(pipeline,[measured])).toThrow("dropped");+ expect(() => validateStageHandoff(pipeline,[{candidateId:"recent-meeting",timingRuns:[],timingNote:"Start unknown"}])).toThrow("upstream");+ expect(() => validateStageHandoff(pipeline,[known,unknown])).toThrow("timingRuns");+ expect(() => validateStageHandoff(pipeline,[measured,{...unknown,timingRuns:[],timingNote:"No completed outcome captured"}])).not.toThrow();+});+it("rejects identity changes and duplicates in procedure enrichment", () => {+ const input = {candidateId:"receipt",workflowId:"wf-receipt"};+ const pipeline = {stage:2,input:{items:[input]}};+ expect(() => validateStageHandoff(pipeline,[{...input,workflowId:"wf-meeting"}])).toThrow("workflow IDs");+ expect(() => validateStageHandoff(pipeline,[input,input])).toThrow("one item");+ expect(() => validateStageHandoff(pipeline,[{...input,exclusionReason:"Only an unread request"}])).not.toThrow();+});++it("rejects lost handoff data before writing and preserves the backend checkpoint receipt", async () => {+ const candidate = {candidateId:"receipt",workflowId:"wf-receipt",stages:[{name:"Save receipt"}]};+ const h = await harness(3,[candidate]);+ await expect(h.tools.workflow_stage_commit.execute("save",{items:[],coverage:[]})).rejects.toThrow("dropped");+ expect(h.fetch).toHaveBeenCalledTimes(2);+ const items = [{...candidate,timingRuns:[],timingNote:"Start not captured"}];+ h.fetch.mockResolvedValueOnce(Response.json({revision:4,checkedThrough:"2026-09-14T12:00:00Z"}));+ await expect(h.tools.workflow_stage_commit.execute("save",{items,coverage:[]})).rejects.toThrow("save receipt");+ h.fetch.mockResolvedValueOnce(Response.json({revision:4,checkedThrough:h.context.checkedThrough}));+ await expect(h.tools.workflow_stage_commit.execute("save",{items,coverage:[]})).resolves.toBeDefined();+ expect(JSON.parse(h.fetch.mock.calls.at(-1)?.[1].body).items[0]).toMatchObject(candidate);+});diff --git a/crates/screenpipe-core/assets/extensions/workflow-catalog.ts b/crates/screenpipe-core/assets/extensions/workflow-catalog.tsindex d5f2015d3..ec03e9d79 100644--- a/crates/screenpipe-core/assets/extensions/workflow-catalog.ts+++ b/crates/screenpipe-core/assets/extensions/workflow-catalog.ts@@ -15,6 +15,30 @@ export function requireInspectedFrames(workflows: any[], inspected: Set<number>)}}+// Enrichment may add evidence, but cannot silently replace the jobs handed to it.+export function validateStageHandoff(pipeline: any, items: any[]) {+ if (![2, 3].includes(pipeline.stage)) return;+ const upstream = pipeline.input?.items ?? [];+ const identity = (item: any) => item.candidateId || item.workflowId;+ const expected = new Map(upstream.map((item: any) => [identity(item), item]));+ const seen = new Set<string>();+ for (const item of items) {+ const id = identity(item);+ if (!id || seen.has(id)) throw new Error("Keep one item per upstream candidate with its stable candidateId/workflowId.");+ seen.add(id);+ if (upstream.length) {+ const prior: any = expected.get(id);+ if (!prior || (prior.workflowId ?? null) !== (item.workflowId ?? null)) throw new Error("Enrich the upstream candidates; do not replace them with newly discovered jobs or change their workflow IDs.");+ if (pipeline.stage === 3 && Object.keys(prior).some(key => !(key in item))) throw new Error("Keep the full upstream procedure and sources when adding timing. Missing timing must not erase procedure fields.");+ }+ if (pipeline.stage === 3 && (!Array.isArray(item.timingRuns)+ || (!item.timingRuns.length && (typeof item.timingNote !== "string" || !item.timingNote.trim())))) {+ throw new Error("Return timingRuns for every candidate. If no complete occurrence is supported, keep the procedure with timingRuns: [] and a short timingNote explaining the missing boundary.");+ }+ }+ if (upstream.some((item: any) => !seen.has(identity(item)))) throw new Error("An upstream candidate was dropped. Keep every candidate and its supported procedure, even when timing is unknown. Explain unsupported candidates with an exclusionReason for final review.");+}+export default function workflowCatalog(pi: ExtensionAPI) {let ready = false;let task = "workflow-discovery";@@ -93,6 +117,15 @@ export default function workflowCatalog(pi: ExtensionAPI) {context = await readJson("/workflows/context", undefined, signal);context.pipeline = await readJson(`/workflows/pipeline?task=${encodeURIComponent(task)}`, undefined, signal);blocked = !context.pipeline.ready;+ // The catalog schema is only the final task's output, not an enrichment schema.+ if (context.pipeline.stage < 4) {+ context.outputContract = {+ saveTool: "workflow_stage_commit",+ instruction: "Follow your stage prompt. Return items and completed coverage; do not publish catalog cards here.",+ ...(context.pipeline.stage >= 2 ? { identity: "Retain every upstream candidateId and workflowId. Add evidence to the same jobs; do not rediscover unrelated activity." } : {}),+ ...(context.pipeline.stage === 3 ? { timing: "Keep the full procedure. Add timingRuns: [{start: {timestamp, app, quote}, end: {timestamp, app, quote}, summary}]. When boundaries are unknown, use timingRuns: [] and timingNote; never discard the procedure." } : {}),+ };+ }return result(context);});tool("workflow_inspect_frame", "View the actual captured image. Attach it only if it visibly supports the claimed step. Blank/loading pages are not useful evidence.", {@@ -127,14 +160,15 @@ export default function workflowCatalog(pi: ExtensionAPI) {}, ["items", "coverage"], async (input, signal) => {const pipeline = context?.pipeline;if (!pipeline?.ready || pipeline.stage === 4) throw new Error("Read this stage's current workflow_context before saving.");+ validateStageHandoff(pipeline, input.items);input = { ...input, expected_revision: pipeline.revision, input_revision: pipeline.inputRevision, checked_through: input.checked_through || pipeline.checkedThrough };if (pipeline.stage > 0 && input.checked_through !== pipeline.checkedThrough) throw new Error("Preserve upstream coverage.");if (pipeline.stage === 0 && (Date.parse(input.checked_through) > Date.parse(pipeline.checkedThrough) || !input.coverage.length || input.coverage.some((r: any) => Date.parse(r.start) < Date.parse(pipeline.window.start)))) throw new Error("Save only completed coverage inside this batch.");const coverage = pipeline.stage === 0 ? input.coverage : pipeline.input.coverage;const receipt = await readJson("/workflows/pipeline", { ...input, coverage, task }, signal);- if (!Number.isInteger(receipt.revision) || receipt.revision <= input.expected_revision) throw new Error("Missing stage save receipt.");+ if (!Number.isInteger(receipt.revision) || receipt.revision <= input.expected_revision || receipt.checkedThrough !== input.checked_through) throw new Error("Missing stage save receipt.");committed = true;- return result(receipt);+ return result({ ...receipt, itemCount: input.items.length });});tool("workflow_commit", "Validate and save only new or materially improved workflows. An empty array checkpoints a successful no-change investigation. Existing IDs and corrections remain intact.", {workflows: { type: "array", maxItems: 30, items: { type: "object", additionalProperties: true } },diff --git a/crates/screenpipe-core/assets/pipes/workflow-discovery/pipe.md b/crates/screenpipe-core/assets/pipes/workflow-discovery/pipe.mdindex ddcd63802..d7138f58b 100644--- a/crates/screenpipe-core/assets/pipes/workflow-discovery/pipe.md+++ b/crates/screenpipe-core/assets/pipes/workflow-discovery/pipe.md@@ -104,3 +104,16 @@ the source and fix or omit that claim; do not route around validation. A revisioconflict means someone edited the catalog: read it again and preserve their edit.Finish with one short factual sentence describing the committed changes. Use theexisting task history for failures; never claim a save without a tool receipt.++Review every upstream candidate independently. A missing timing run, absent+screenshot or rejected candidate must not discard other supported improvements.+Existing workflows can receive better evidenced steps from a single new+occurrence; do not require the current batch alone to reprove all recurrence.+Use upstream workflowId as the catalog id. Translate supported procedures into+stages with source-linked procedure entries; preserve earlier valid steps and+timingRuns. Unsupported suggestions belong outside the published procedure.+Before an empty commit, check whether any candidate adds a supported step,+correction, source or timing run to an existing workflow. Repair rejected fields+using the original evidence rather than discarding all candidates at once.+After saving report the receipt's actual created/updated counts and checkedThrough.+A successful empty commit means "No changes saved", not that all history is current.diff --git a/crates/screenpipe-core/assets/pipes/workflow-patterns/pipe.md b/crates/screenpipe-core/assets/pipes/workflow-patterns/pipe.mdindex f994d27ac..e02e68b0a 100644--- a/crates/screenpipe-core/assets/pipes/workflow-patterns/pipe.md+++ b/crates/screenpipe-core/assets/pipes/workflow-patterns/pipe.md@@ -43,3 +43,9 @@ Call workflow_stage_commit with your items and coverage. The tool carries thecorrect revisions and checkpoint automatically. A valid empty items array is useful.Finish with one factual sentence after the save receipt. Keep intermediateresults concise; the final review task publishes the user-facing catalog.++Keep a candidate for each professional episode that improves an existing job,+even if this batch has only one new occurrence. Prior catalog evidence counts+when matching a recurring job; recurrence need not be rediscovered in every batch.+Do not discard useful procedure evidence merely because timing or screenshots+are unavailable. Carry stable candidateId/workflowId and source references forward.diff --git a/crates/screenpipe-core/assets/pipes/workflow-procedures/pipe.md b/crates/screenpipe-core/assets/pipes/workflow-procedures/pipe.mdindex 075ba51ac..dbfad7853 100644--- a/crates/screenpipe-core/assets/pipes/workflow-procedures/pipe.md+++ b/crates/screenpipe-core/assets/pipes/workflow-procedures/pipe.md@@ -43,3 +43,14 @@ Call workflow_stage_commit with your items and coverage. The tool carries thecorrect revisions and checkpoint automatically. A valid empty items array is useful.Finish with one factual sentence after the save receipt. Keep intermediateresults concise; the final review task publishes the user-facing catalog.++Work through every item in pipeline.input.items. Preserve its candidateId and+workflowId. Return the full supported procedure for each, retaining existing+source references and occurrences. Do not replace the input with a new scan of+recent activity. For a rejected candidate retain its identity and a concise+exclusionReason so final review can account for it. If upstream is empty and a+review was requested, refine relevant existing catalog workflows using their+existing IDs and corrections; otherwise save an empty stage without a new scan.+Write each concrete step with its exact supporting timestamp, app and quote,+using the catalog's stages/procedure format where possible. A bare list of action+suggestions cannot establish that the user actually performed those steps.diff --git a/crates/screenpipe-core/assets/pipes/workflow-timing/pipe.md b/crates/screenpipe-core/assets/pipes/workflow-timing/pipe.mdindex c188d7bf6..fdfdf62dc 100644--- a/crates/screenpipe-core/assets/pipes/workflow-timing/pipe.md+++ b/crates/screenpipe-core/assets/pipes/workflow-timing/pipe.md@@ -49,3 +49,18 @@ Call workflow_stage_commit with your items and coverage. The tool carries thecorrect revisions and checkpoint automatically. Keep the enriched procedures in items, including those with unknown timing.Finish with one factual sentence after the save receipt. Keep intermediateresults concise; the final review task publishes the user-facing catalog.++Return every upstream candidate with the same candidateId and workflowId and+its full supported procedure, sources and occurrences. Timing is an enrichment,+not a second discovery pass or a filter for which procedures survive. Investigate+the supplied occurrences with explicit source time windows, not a default "last+hour" search. Keep this batch's checkedThrough; later activity belongs to a later+activity task. Never substitute a recent meeting for a different upstream job.+Add timingRuns using the exact shape:+[{"start":{"timestamp":"ISO timestamp","app":"app","quote":"verbatim source"},+"end":{"timestamp":"ISO timestamp","app":"app","quote":"verbatim source"},+"summary":"Which occurrence these boundaries establish"}].+When a start, completed outcome or continuity cannot be verified, keep the+candidate with timingRuns: [] and a short timingNote identifying the missing+boundary. Preserve its useful procedure improvements for final review. Never+invent a duration to make the card look complete.diff --git a/packages/workflows-ui/src/workflow-run-progress.tsx b/packages/workflows-ui/src/workflow-run-progress.tsxindex 86a43014e..1bc211920 100644--- a/packages/workflows-ui/src/workflow-run-progress.tsx+++ b/packages/workflows-ui/src/workflow-run-progress.tsx@@ -6,11 +6,11 @@ import { Check, ChevronDown, Circle, Loader2, RefreshCw, Square, AlertCircle } fimport type { WorkflowAnalysisJob, WorkflowRunActivity, WorkflowsPlatform } from "./platform";import styles from "./workflows-app.module.css";-export function WorkflowRunProgress({ job, active, subscribe, stop, analyze, updatedAt, changes, disabledReason }: {+export function WorkflowRunProgress({ job, active, subscribe, stop, analyze, updatedAt, checkedThrough, changes, disabledReason }: {disabledReason?: string;job?: WorkflowAnalysisJob | null; active: boolean;subscribe?: WorkflowsPlatform["subscribeAnalysisActivity"];- stop?: () => void; analyze: () => void; updatedAt?: string;+ stop?: () => void; analyze: () => void; updatedAt?: string; checkedThrough?: string;changes?: { created: number; updated: number };}) {const [activity, setActivity] = useState<{ jobId: string; items: WorkflowRunActivity[] }>({ jobId: "", items: [] });@@ -46,24 +46,28 @@ export function WorkflowRunProgress({ job, active, subscribe, stop, analyze, updconst items = activity.jobId === job?.id ? activity.items : [];const current = [...items].reverse().find(item => item.status === "running") ?? items.at(-1);const seconds = job?.startedAt ? Math.max(0, Math.floor((now - Date.parse(job.startedAt)) / 1000)) : NaN;- const result = changes ? changes.created === 0 && changes.updated === 0 ? "Up to date" : `${changes.created} new · ${changes.updated} updated` : "Workflows updated";+ changes = job?.result?.changes ?? changes;+ checkedThrough = job?.result?.checkedThrough ?? checkedThrough;+ const reviewed = checkedThrough && Number.isFinite(Date.parse(checkedThrough)) ? new Date(checkedThrough).toLocaleString([], { month: "short", day: "numeric", hour: "numeric", minute: "2-digit" }) : undefined;+ const result = changes ? changes.created === 0 && changes.updated === 0 ? "No changes saved" : `${changes.created} new · ${changes.updated} updated` : "Workflows updated";const label = active ? current?.label ?? (job?.message || (job?.status === "queued" ? "Waiting for agent" : "Agent working")): job?.status === "incomplete" ? "Update incomplete" : job?.status === "failed" ? "Update failed" : job?.status === "complete" ? result- : updatedAt ? `Updated ${new Date(updatedAt).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" })}` : "";+ : updatedAt ? result : "";return <div className={styles.refreshControls}>- {(active || items.length > 0) ? <div ref={root} className={styles.runProgress}>+ {(active || items.length > 0 || job || updatedAt) ? <div ref={root} className={styles.runProgress}><button ref={toggle} type="button" className={styles.runToggle} aria-expanded={open} aria-label={`${label}. Show agent activity`} onClick={() => setOpen(!open)}>{active ? <Loader2 size={14} className={styles.runSpinner} /> : job?.status === "failed" ? <AlertCircle size={14} /> : job?.status === "incomplete" ? <Circle size={14} /> : <Check size={14} />}- <span role="status">{label}</span>+ <span role="status">{label}{!active && reviewed && <small style={{ display: "block" }}>Through {reviewed}</small>}</span>{active && Number.isFinite(seconds) && <time>{Math.floor(seconds / 60)}:{String(seconds % 60).padStart(2, "0")}</time>}<ChevronDown size={12} style={{ transform: open ? "rotate(180deg)" : undefined }} /></button>{open && <section className={styles.runActivity} aria-label="Agent activity"><header><strong>{active ? "Updating workflows" : "Workflow update"}</strong><span>{active ? "Live activity" : "Recent activity"}</span></header>+ {reviewed && !active && <p>Data reviewed through <time dateTime={checkedThrough}>{reviewed}</time></p>}{items.length ? <ol>{items.map(item => <li key={item.id}>{item.status === "error" ? <AlertCircle size={13} /> : item.status === "complete" ? <Check size={13} /> : active ? <Loader2 size={13} className={styles.runSpinner} /> : <Circle size={13} />}<span>{item.label}{!active && item.status === "running" ? " · ended" : ""}</span>- </li>)}</ol> : <p>{unavailable ? "Live activity is unavailable. The task status will keep updating." : "Waiting for the next agent action…"}</p>}+ </li>)}</ol> : active ? <p>{unavailable ? "Live activity is unavailable. The task status will keep updating." : "Waiting for the next agent action…"}</p> : null}<footer>{active ? "Your saved workflows stay available." : (job?.status === "failed" || job?.status === "incomplete") ? job.message : result}</footer></section>}</div> : <span role="status">{label}</span>}diff --git a/packages/workflows-ui/src/workflows-app.tsx b/packages/workflows-ui/src/workflows-app.tsxindex 1fc75d76b..32484461e 100644--- a/packages/workflows-ui/src/workflows-app.tsx+++ b/packages/workflows-ui/src/workflows-app.tsx@@ -691,7 +691,7 @@ function OverviewView({);}-function WorkflowsView({ workflows, knownWorkflowCount, activityPeriod, filters, setFilters, openWorkflow, analyze, analyzing, error, stop, updatedAt, changes, job, subscribe, analysisUnavailableReason }: { analysisUnavailableReason?: string; workflows: WorkflowMap[]; knownWorkflowCount: number; activityPeriod: WorkflowActivityPeriod; filters: WorkflowFilters; setFilters: (filters: WorkflowFilters) => void; openWorkflow: (index: number) => void; analyze: () => void; analyzing: boolean; error: string; stop?: () => void; updatedAt?: string; changes?: { created: number; updated: number }; job?: WorkflowAnalysisJob | null; subscribe?: WorkflowsPlatform["subscribeAnalysisActivity"] }) {+function WorkflowsView({ workflows, knownWorkflowCount, activityPeriod, filters, setFilters, openWorkflow, analyze, analyzing, error, stop, updatedAt, checkedThrough, changes, job, subscribe, analysisUnavailableReason }: { analysisUnavailableReason?: string; workflows: WorkflowMap[]; knownWorkflowCount: number; activityPeriod: WorkflowActivityPeriod; filters: WorkflowFilters; setFilters: (filters: WorkflowFilters) => void; openWorkflow: (index: number) => void; analyze: () => void; analyzing: boolean; error: string; stop?: () => void; updatedAt?: string; checkedThrough?: string; changes?: { created: number; updated: number }; job?: WorkflowAnalysisJob | null; subscribe?: WorkflowsPlatform["subscribeAnalysisActivity"] }) {const [filtersOpen, setFiltersOpen] = useState(false);const visible = useMemo(() => filterWorkflows(workflows, filters), [filters, workflows]);const availableApps = useMemo(() => [...new Set(workflows.flatMap((workflow) => workflow.apps))].sort((a, b) => a.localeCompare(b)), [workflows]);@@ -703,7 +703,7 @@ function WorkflowsView({ workflows, knownWorkflowCount, activityPeriod, filters,return (<>- <div className={`${styles.pageHeader} ${styles.catalogHeader}`}><div><h1>Your workflows</h1></div><WorkflowRunProgress disabledReason={analysisUnavailableReason} job={job} active={analyzing} subscribe={subscribe} stop={stop} analyze={analyze} updatedAt={updatedAt} changes={changes} /></div>+ <div className={`${styles.pageHeader} ${styles.catalogHeader}`}><div><h1>Your workflows</h1></div><WorkflowRunProgress disabledReason={analysisUnavailableReason} job={job} active={analyzing} subscribe={subscribe} stop={stop} analyze={analyze} updatedAt={updatedAt} checkedThrough={checkedThrough} changes={changes} /></div>{error && <p role="alert" className={styles.depthNotice}>{error}</p>}{!knownWorkflowCount ? <EmptyWorkMap analyzing={analyzing} analyze={analyze} /> : !workflows.length ? <section className={styles.emptyState}><Clock3 size={23} /><h2>No known workflows were active in this period</h2><p>Your {knownWorkflowCount} known workflows are still in the catalog. Choose “All known” to see them.</p></section> : <><section className={styles.filterBar} aria-label="Workflow filters">@@ -1558,7 +1558,7 @@ export function WorkflowsApp({ platform, initialAnalysis = null, storageKey = "sswitch (view) {case "overview": content = <OverviewView analysis={analysis ? { ...analysis, analysis: { workflows } } : null} analyzing={analyzing} error={analysisError} analyze={() => void analyze()} openWorkflow={openWorkflow} navigate={navigate} knownWorkflowCount={knownWorkflows.length} activityPeriod={activityPeriod} runtime={runtime} workProfile={workProfile} refreshRuntime={refreshRuntime} openAccount={platform.openAccount} />; break;case "time": content = <TimeView analysis={analysis} analyze={() => void analyze()} analyzing={analyzing} workProfile={workProfile} lens={timeLens} setLens={setTimeLens} />; break;- case "workflows": content = <WorkflowsView analysisUnavailableReason={onAnalysisUnavailable ? undefined : analysisUnavailableReason} workflows={workflows} knownWorkflowCount={knownWorkflows.length} activityPeriod={activityPeriod} filters={filters} setFilters={setFilters} openWorkflow={openWorkflow} analyze={() => void analyze()} analyzing={analyzing} error={analysisError} stop={platform.cancelAnalysisJob ? () => { void platform.cancelAnalysisJob!().catch(error => setAnalysisError(String(error))); } : undefined} updatedAt={analysis?.analyzedAt} changes={analysis?.changes} job={analysisJob} subscribe={platform.subscribeAnalysisActivity} />; break;+ case "workflows": content = <WorkflowsView analysisUnavailableReason={onAnalysisUnavailable ? undefined : analysisUnavailableReason} workflows={workflows} knownWorkflowCount={knownWorkflows.length} activityPeriod={activityPeriod} filters={filters} setFilters={setFilters} openWorkflow={openWorkflow} analyze={() => void analyze()} analyzing={analyzing} error={analysisError} stop={platform.cancelAnalysisJob ? () => { void platform.cancelAnalysisJob!().catch(error => setAnalysisError(String(error))); } : undefined} updatedAt={analysis?.analyzedAt} checkedThrough={analysis?.checkedThrough} changes={analysis?.changes} job={analysisJob} subscribe={platform.subscribeAnalysisActivity} />; break;case "workflow": content = <WorkflowDetail onShareWorkflow={onShareWorkflow} workflow={activeWorkflow} navigate={navigate} platform={platform} workProfile={workProfile} saveCorrection={!analyzing && platform.saveCapturedWork && (!activeScope || activeScope.kind === "personal") ? async (note) => {if (!analysis || !activeWorkflow) return;const updated = { ...analysis, analysis: { workflows: analysis.analysis.workflows.map((workflow) => (workflow.id && activeWorkflow.id ? workflow.id === activeWorkflow.id : workflow.title === activeWorkflow.title) ? { ...workflow, userCorrection: note } : workflow) } };