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): open step recordings in native Timeline

louis38ceb5bc23d4
diff --git a/apps/screenpipe-app-tauri/components/workflows/step-evidence.test.tsx b/apps/screenpipe-app-tauri/components/workflows/step-evidence.test.tsx
index bc8b4315e..96309f73f 100644
--- a/apps/screenpipe-app-tauri/components/workflows/step-evidence.test.tsx
+++ b/apps/screenpipe-app-tauri/components/workflows/step-evidence.test.tsx
@@ -14,6 +14,26 @@ const play = () => fireEvent.click(screen.getByRole("button", { name: `View reco
afterEach(cleanup);
describe("step evidence media", () => {
+ it("opens verified captures in native Timeline without loading an inline video", async () => {
+ const open = vi.fn().mockResolvedValue(undefined);
+ const load = vi.fn();
+ render(<WorkflowStepEvidence workflow={workflow} stage={stage} platform={{ openCapturedMoment: open, loadWorkflowRecording: load } as unknown as WorkflowsPlatform} />);
+ fireEvent.click(screen.getByRole("button", { name: `Open recording for ${stage.name}` }));
+ await waitFor(() => expect(open).toHaveBeenCalledWith(stage.screenshot!.frameId, stage.screenshot!.timestamp));
+ expect(load).not.toHaveBeenCalled();
+ expect(screen.queryByLabelText("Local recording")).toBeNull();
+ });
+
+ it("resolves legacy captures, opens Timeline and releases the temporary media", async () => {
+ const open = vi.fn().mockResolvedValue(undefined);
+ const load = vi.fn().mockResolvedValue({ kind: "video", url: "https://fixture.invalid/legacy.mp4", frameId: 123, timestamp: stage.evidence[0].timestamp });
+ const release = vi.fn().mockResolvedValue(undefined);
+ render(<WorkflowStepEvidence workflow={workflow} stage={{ ...stage, screenshot: null }} platform={{ openCapturedMoment: open, loadWorkflowRecording: load, releaseWorkflowRecording: release } as unknown as WorkflowsPlatform} />);
+ fireEvent.click(screen.getByRole("button", { name: `Open recording for ${stage.name}` }));
+ await waitFor(() => expect(open).toHaveBeenCalledWith(123, stage.evidence[0].timestamp));
+ expect(release).toHaveBeenCalledWith("https://fixture.invalid/legacy.mp4");
+ });
+
it("loads only on request and releases the media when closed", async () => {
const load = vi.fn().mockResolvedValue({ kind: "video", url: "https://fixture.invalid/clip.mp4", timestamp: stage.evidence[0].timestamp, frameId: 1, offsetSeconds: 2 });
const release = vi.fn().mockResolvedValue(undefined);
diff --git a/packages/workflows-ui/src/workflow-step-evidence.tsx b/packages/workflows-ui/src/workflow-step-evidence.tsx
index 4d092becf..b23204c5e 100644
--- a/packages/workflows-ui/src/workflow-step-evidence.tsx
+++ b/packages/workflows-ui/src/workflow-step-evidence.tsx
@@ -6,7 +6,7 @@ import { useMemo, useState } from "react";
import { ChevronDown, Maximize2, Minimize2, Play, X } from "lucide-react";
import type { WorkflowMap, WorkflowStage } from "./model";
import type { WorkflowsPlatform } from "./platform";
-import { CapturedMomentButton, WorkflowReplay } from "./workflow-replay";
+import { WorkflowReplay } from "./workflow-replay";
import styles from "./workflow-step-evidence.module.css";
const when = (value: string) => Number.isFinite(Date.parse(value))
@@ -17,26 +17,49 @@ export function WorkflowStepEvidence({ workflow, stage, platform }: {
}) {
const [expanded, setExpanded] = useState(false);
const [playing, setPlaying] = useState(false);
+ const [opening, setOpening] = useState(false);
+ const [openError, setOpenError] = useState(false);
const replay = useMemo(() => ({ ...workflow, stages: [stage] }), [workflow, stage]);
const screenshot = stage.screenshot?.visualVerified ? stage.screenshot : null;
const sources = [...(stage.procedure ?? []).filter(p => p.quote).map(p => ({ text: p.quote, timestamp: p.timestamp, app: p.app })),
...stage.evidence.map(e => ({ text: e.detail, timestamp: e.timestamp, app: e.app }))]
.filter((entry, index, all) => entry.text && all.findIndex(e => e.text === entry.text && e.timestamp === entry.timestamp && e.app === entry.app) === index);
const canReplay = platform.loadWorkflowRecording && stage.evidence.some(e => !["audio", "meeting"].includes(e.source ?? "") && Number.isFinite(Date.parse(e.timestamp)));
+ const openRecording = async () => {
+ if (!platform.openCapturedMoment) { setPlaying(true); return; }
+ setOpening(true); setOpenError(false);
+ let media: Awaited<ReturnType<NonNullable<WorkflowsPlatform["loadWorkflowRecording"]>>> = null;
+ try {
+ if (screenshot) await platform.openCapturedMoment(screenshot.frameId, screenshot.timestamp);
+ else {
+ const entry = stage.evidence.find(e => !["audio", "meeting"].includes(e.source ?? "") && Number.isFinite(Date.parse(e.timestamp)));
+ if (!entry || !platform.loadWorkflowRecording) throw new Error("Missing capture");
+ media = await platform.loadWorkflowRecording(entry.timestamp, entry.app);
+ if (!media) throw new Error("Capture unavailable");
+ await platform.openCapturedMoment(media.frameId, media.timestamp);
+ }
+ } catch { setOpenError(true); }
+ finally {
+ setOpening(false);
+ if (media?.url.startsWith("blob:")) URL.revokeObjectURL(media.url);
+ else if (media?.url && platform.releaseWorkflowRecording) void platform.releaseWorkflowRecording(media.url).catch(() => {});
+ }
+ };
return <section className={`${styles.evidence} ph-no-capture ph-mask`} aria-label={`References for ${stage.name}`}>
{screenshot && !playing && <figure className={`${styles.figure} ${expanded ? styles.expanded : ""}`}>
<button className={styles.imageButton} type="button" aria-label={`${expanded ? "Reduce" : "Enlarge"} screenshot for ${stage.name}`} aria-expanded={expanded} onClick={() => setExpanded(!expanded)}>
<img src={screenshot.dataUrl} alt={`Captured reference for ${stage.name}`} loading="lazy" draggable={false} data-lm-disable="true" />
<span className={styles.zoom}>{expanded ? <Minimize2 size={15} /> : <Maximize2 size={15} />}</span>
</button>
- <figcaption><span>{screenshot.app} · {when(screenshot.timestamp)}</span><CapturedMomentButton compact frameId={screenshot.frameId} timestamp={screenshot.timestamp} open={platform.openCapturedMoment} /></figcaption>
+ <figcaption><span>{screenshot.app} · {when(screenshot.timestamp)}</span></figcaption>
</figure>}
{playing && <div className={styles.player}>
<button type="button" className={styles.close} aria-label={`Close recording for ${stage.name}`} title="Close recording" onClick={() => setPlaying(false)}><X size={15} /></button>
<WorkflowReplay workflow={replay} loadRecording={platform.loadWorkflowRecording} releaseRecording={platform.releaseWorkflowRecording} openCapturedMoment={platform.openCapturedMoment} />
</div>}
<div className={styles.links}>
- {canReplay && !playing && <button type="button" onClick={() => setPlaying(true)} aria-label={`View recording for ${stage.name}`}><Play size={13} />View recording</button>}
+ {(canReplay || (screenshot && platform.openCapturedMoment)) && !playing && <button type="button" disabled={opening} onClick={() => void openRecording()} aria-label={`${platform.openCapturedMoment ? "Open" : "View"} recording for ${stage.name}`}><Play size={13} />{opening ? "Opening…" : platform.openCapturedMoment ? "Open recording" : "View recording"}</button>}
+ {openError && <span role="alert">Could not open this capture. Try again.</span>}
{!!sources.length && <details className={styles.sources}>
<summary>{sources.length} source{sources.length === 1 ? "" : "s"}<ChevronDown size={12} /></summary>
<div className={styles.sourceList}>