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): include SOP images in web handoff by default

Louis Beaumont7332cddc4fc5
diff --git a/apps/screenpipe-app-tauri/lib/workflows/guide-web-images.ts b/apps/screenpipe-app-tauri/lib/workflows/guide-web-images.ts
new file mode 100644
index 000000000..be5b73844
--- /dev/null
+++ b/apps/screenpipe-app-tauri/lib/workflows/guide-web-images.ts
@@ -0,0 +1,69 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+import { guideScreenshot, guideSourceStage, guideStepIncludesImage, type WorkflowGuide } from "@screenpipe/workflows-ui";
+import type { WorkflowMap } from "@screenpipe/workflows-ui/model";
+import { loadOriginalWorkflowScreenshot } from "./original-screenshot";
+import { findWorkflowScreenshot } from "./source-screenshot";
+import { screenpipeWebUrl, PROD_WEB_BASE } from "@/lib/web-url";
+
+/** Called only by the user's Share/Open on web action, never background sync. */
+export async function uploadGuideImages(guide: WorkflowGuide, workflow: WorkflowMap, token: string) {
+ const controller = new AbortController();
+ const timer = setTimeout(() => controller.abort(), 120_000);
+ const images: Record<string, string> = {};
+ const uploaded = new Map<number, string>();
+ try {
+ for (const [index, step] of guide.steps.entries()) {
+ if (!guideStepIncludesImage(step)) continue;
+ const stageIndex = guideSourceStage(guide, step, workflow);
+ if (stageIndex === undefined) throw Error("Reconnect the SOP’s screenshot sources before sharing, or remove those images.");
+ if (stageIndex === null) continue;
+ const stage = workflow.stages[stageIndex];
+ if (!stage) continue;
+ let source = guideScreenshot(workflow, stageIndex, step.imageReview);
+ if (!source && step.imageReview) throw Error("A selected image is unavailable. Remove or replace it before sharing.");
+ if (!source) {
+ for (const evidence of stage.evidence ?? []) {
+ if (["audio", "meeting"].includes(evidence.source ?? "") || !evidence.app || !Number.isFinite(Date.parse(evidence.timestamp))) continue;
+ source = await findWorkflowScreenshot(evidence.timestamp, evidence.app, controller.signal);
+ if (source) break;
+ }
+ }
+ if (!source) continue;
+ let url = uploaded.get(source.frameId);
+ if (!url) {
+ const original = await loadOriginalWorkflowScreenshot(source.frameId, controller.signal);
+ const blob = await shareImage(original);
+ controller.signal.throwIfAborted();
+ const response = await fetch(screenpipeWebUrl("/api/sops/images", PROD_WEB_BASE), {
+ method: "POST", signal: controller.signal,
+ headers: { Authorization: `Bearer ${token}`, "Content-Type": blob.type }, body: blob,
+ });
+ if (!response.ok) throw Error("An image could not be uploaded. Your SOP is saved on this device. Try again or remove the image.");
+ const result = await response.json();
+ if (typeof result.url !== "string" || !/^\/api\/sops\/images\/[a-f0-9]{64}\/[a-f0-9]{64}$/.test(result.url))
+ throw Error("Invalid screenshot upload response.");
+ url = result.url as string;
+ uploaded.set(source.frameId, url);
+ }
+ images[`step/${step.blockId ?? `step-${index}`}`] = url;
+ }
+ return images;
+ } finally { clearTimeout(timer); controller.abort(); }
+}
+
+async function shareImage(original: Blob): Promise<Blob> {
+ if (original.size <= 3 * 1024 * 1024) return original;
+ const bitmap = await createImageBitmap(original);
+ try {
+ const scale = Math.min(1, 2400 / Math.max(bitmap.width, bitmap.height));
+ const canvas = document.createElement("canvas");
+ canvas.width = Math.round(bitmap.width * scale); canvas.height = Math.round(bitmap.height * scale);
+ const context = canvas.getContext("2d");
+ if (!context) throw Error("Could not prepare screenshot.");
+ context.drawImage(bitmap, 0, 0, canvas.width, canvas.height);
+ const blob = await new Promise<Blob | null>(resolve => canvas.toBlob(resolve, "image/jpeg", 0.9));
+ if (!blob || blob.size > 3 * 1024 * 1024) throw Error("An image is too large to share. Remove or replace it.");
+ return blob;
+ } finally { bitmap.close(); }
+}
diff --git a/apps/screenpipe-app-tauri/lib/workflows/guide.test.tsx b/apps/screenpipe-app-tauri/lib/workflows/guide.test.tsx
index a8107f621..e6181f7dc 100644
--- a/apps/screenpipe-app-tauri/lib/workflows/guide.test.tsx
+++ b/apps/screenpipe-app-tauri/lib/workflows/guide.test.tsx
@@ -377,6 +377,7 @@ describe("guide editor", () => {
);
await screen.findByRole("textbox", { name: "SOP title" });
document.getElementById("guide-completion")!.scrollIntoView = scroll;
+ fireEvent.click(screen.getByRole("button", { name: "Contents" }));
const event = new MouseEvent("click", { bubbles: true, cancelable: true });
screen
.getByRole("link", { name: "Check your result" })
@@ -472,7 +473,7 @@ describe("SOP assistant and web editor", () => {
expect(openWeb).not.toHaveBeenCalled();
expect(screen.queryByText("Create a short video")).not.toBeInTheDocument();
fireEvent.click(screen.getByText("Continue to web editor"));
- await waitFor(() => expect(openWeb).toHaveBeenCalledWith(guideWithBlockIds(guide)));
+ await waitFor(() => expect(openWeb).toHaveBeenCalledWith(guideWithBlockIds(guide), workflow));
});
it("edits with the existing harness adapter and cancels an in-flight edit", async () => {
let signal: AbortSignal | undefined;
diff --git a/apps/screenpipe-app-tauri/lib/workflows/guides-adapter.test.ts b/apps/screenpipe-app-tauri/lib/workflows/guides-adapter.test.ts
index 8568b1fb5..38d6be03c 100644
--- a/apps/screenpipe-app-tauri/lib/workflows/guides-adapter.test.ts
+++ b/apps/screenpipe-app-tauri/lib/workflows/guides-adapter.test.ts
@@ -9,11 +9,13 @@ const mocks = vi.hoisted(() => ({
save: vi.fn(),
dialog: vi.fn(),
write: vi.fn(),
+ screenshot: vi.fn(),
}));
vi.mock("@/lib/utils/tauri", () => ({
commands: { getCloudToken: mocks.token },
}));
vi.mock("@tauri-apps/plugin-shell", () => ({ open: mocks.open }));
+vi.mock("./original-screenshot", () => ({ loadOriginalWorkflowScreenshot: mocks.screenshot }));
vi.mock("./agent-runner", () => ({ runWorkflowAgent: mocks.run }));
vi.mock("./assistant", () => ({
assistantProviderConfig: { provider: "screenpipe-cloud", model: "auto" },
@@ -81,24 +83,30 @@ it("does not write when the native export dialog is cancelled", async () => {
expect(mocks.write).toHaveBeenCalledWith("/selected/guide.html", "html");
});
-it("uploads only reviewed SOP text with existing authentication", async () => {
+it("uploads included screenshots with the SOP and existing authentication", async () => {
mocks.token.mockResolvedValue("test-token");
const id = "12345678-1234-1234-1234-123456789abc";
- const fetcher = vi
- .fn()
- .mockResolvedValue(new Response(JSON.stringify({ id }), { status: 201 }));
+ mocks.screenshot.mockResolvedValue(new Blob(["image"], { type: "image/png" }));
+ const imageUrl = `/api/sops/images/${"a".repeat(64)}/${"b".repeat(64)}`;
+ const fetcher = vi.fn()
+ .mockResolvedValueOnce(Response.json({ url: imageUrl }))
+ .mockResolvedValueOnce(Response.json({ id }, { status: 201 }));
vi.stubGlobal("fetch", fetcher);
try {
- await desktopGuides.openWeb!(guide as any);
- const request = fetcher.mock.calls[0][1];
+ await desktopGuides.openWeb!(guide as any, workflow);
+ const request = fetcher.mock.calls[1][1];
+ expect(fetcher.mock.calls[0][1].body).toBeInstanceOf(Blob);
expect(request.headers.Authorization).toBe("Bearer test-token");
const payload = JSON.parse(request.body);
expect(Object.keys(payload).sort()).toEqual([
"content",
+ "previousContent",
"title",
"workflowKey",
]);
expect(payload.content).toContain("Read sources");
+ expect(payload.content).toContain(imageUrl);
+ expect(payload.previousContent).not.toContain(imageUrl);
expect(mocks.open).toHaveBeenCalledWith(
`https://screenpipe.com/sops/${id}`,
);
@@ -107,13 +115,14 @@ it("uploads only reviewed SOP text with existing authentication", async () => {
}
});
it("keeps the local draft when hosting is unavailable", async () => {
+ mocks.screenshot.mockResolvedValue(new Blob(["image"], { type: "image/png" }));
mocks.token.mockResolvedValue("test-token");
vi.stubGlobal(
"fetch",
vi.fn().mockResolvedValue(new Response("", { status: 503 })),
);
try {
- await expect(desktopGuides.openWeb!(guide as any)).rejects.toThrow(
+ await expect(desktopGuides.openWeb!(guide as any, workflow)).rejects.toThrow(
"saved on this device",
);
expect(mocks.open).not.toHaveBeenCalled();
@@ -135,3 +144,20 @@ it("preserves separate video edits when the written SOP is edited", async () =>
expect(edited.title).toBe("New SOP title");
expect(edited.video).toEqual(video);
});
+
+it("never loads or uploads explicitly removed images", async () => {
+ const fetcher = vi.fn().mockResolvedValue(Response.json({ id: "12345678-1234-1234-1234-123456789abc" }));
+ vi.stubGlobal("fetch", fetcher);
+ await desktopGuides.openWeb!({ ...guide, steps: guide.steps.map(step => ({ ...step, imageExcluded: true })) } as any, workflow);
+ expect(mocks.screenshot).not.toHaveBeenCalled();
+ expect(fetcher).toHaveBeenCalledTimes(1);
+ expect(fetcher.mock.calls[0][0]).toBe("https://screenpipe.com/api/sops");
+});
+it("does not create/open a text-only page after an image upload fails", async () => {
+ mocks.screenshot.mockResolvedValue(new Blob(["image"], { type: "image/png" }));
+ const fetcher = vi.fn().mockResolvedValue(new Response("", { status: 503 }));
+ vi.stubGlobal("fetch", fetcher);
+ await expect(desktopGuides.openWeb!(guide as any, workflow)).rejects.toThrow("image could not be uploaded");
+ expect(fetcher).toHaveBeenCalledTimes(1);
+ expect(mocks.open).not.toHaveBeenCalled();
+});
diff --git a/apps/screenpipe-app-tauri/lib/workflows/guides.ts b/apps/screenpipe-app-tauri/lib/workflows/guides.ts
index ccb1ed4cd..2842edc98 100644
--- a/apps/screenpipe-app-tauri/lib/workflows/guides.ts
+++ b/apps/screenpipe-app-tauri/lib/workflows/guides.ts
@@ -1,5 +1,6 @@
// screenpipe — AI that knows everything you've seen, said, or heard
// https://screenpipe.com
+import { uploadGuideImages } from "./guide-web-images";
import { findWorkflowScreenshot } from "./source-screenshot";
import { loadOriginalWorkflowScreenshot } from "./original-screenshot";
import { trackWorkflowOutcome } from "./notification";
@@ -52,10 +53,11 @@ export const desktopGuides: NonNullable<WorkflowsPlatform["guides"]> = {
return { ...frame, dataUrl: URL.createObjectURL(await loadOriginalWorkflowScreenshot(frame.frameId, signal)) };
},
loadScreenshot: async (frameId, signal) => URL.createObjectURL(await loadOriginalWorkflowScreenshot(frameId, signal)),
- async openWeb(guide) {
+ async openWeb(guide, workflow) {
const token = await commands.getCloudToken();
if (!token)
throw new Error("Sign in to Screenpipe to open your SOP on the web.");
+ const images = await uploadGuideImages(guide, workflow, token);
const response = await fetch(screenpipeWebUrl("/api/sops", PROD_WEB_BASE), {
method: "POST",
signal: AbortSignal.timeout(30000),
@@ -66,7 +68,8 @@ export const desktopGuides: NonNullable<WorkflowsPlatform["guides"]> = {
body: JSON.stringify({
workflowKey: guide.workflowKey,
title: guide.title,
- content: guideMarkdown(guide),
+ content: guideMarkdown(guide, images),
+ previousContent: guideMarkdown(guide),
}),
});
if (!response.ok)
diff --git a/apps/screenpipe-app-tauri/lib/workflows/sop-images.test.tsx b/apps/screenpipe-app-tauri/lib/workflows/sop-images.test.tsx
new file mode 100644
index 000000000..4d0c64f44
--- /dev/null
+++ b/apps/screenpipe-app-tauri/lib/workflows/sop-images.test.tsx
@@ -0,0 +1,29 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+import React from "react";
+import { it, expect, vi, afterEach } from "vitest";
+import { render, screen, fireEvent, cleanup } from "@testing-library/react";
+import { SopDocument } from "@screenpipe/workflows-ui/sop-document";
+afterEach(cleanup);
+const path = `/api/sops/images/${"a".repeat(64)}/${"b".repeat(64)}`;
+it("renders a hosted screenshot and persists removal with undo", () => {
+ const save = vi.fn();
+ render(<SopDocument title="Review" content={`Check the form.\n\n![Form](<${path}>)`} onContentChange={save} imageUrl={src => src} />);
+ expect(screen.getByRole("img", { name: "Form" })).toHaveAttribute("src", path);
+ fireEvent.click(screen.getByRole("button", { name: "Remove image: Form" }));
+ expect(save.mock.lastCall![0]).not.toContain(path);
+ expect(screen.queryByRole("img")).toBeNull();
+ fireEvent.click(screen.getByRole("button", { name: "Undo" }));
+ expect(screen.getByRole("img", { name: "Form" })).toBeVisible();
+ expect(save.mock.lastCall![0]).toContain(path);
+});
+it("leaves ordinary evidence images as references without an explicit resolver", () => {
+ render(<SopDocument title="Review" content="![Private](http://localhost:3030/frames/1)" />);
+ expect(document.querySelector("img[src]")).toBeNull();
+});
+
+it("shows the imported title once above the same editable document", () => {
+ render(<SopDocument title="Review" content="# Review\n\nFollow the steps." onContentChange={vi.fn()} />);
+ expect(screen.getAllByRole("heading", { name: "Review" })).toHaveLength(1);
+ expect(screen.getByRole("textbox", { name: "SOP text" })).toHaveTextContent("Follow the steps.");
+});
diff --git a/docs/pr-assets/sop-share-images/after.png b/docs/pr-assets/sop-share-images/after.png
new file mode 100644
index 000000000..9b06cfe7b
Binary files /dev/null and b/docs/pr-assets/sop-share-images/after.png differ
diff --git a/docs/pr-assets/sop-share-images/before.png b/docs/pr-assets/sop-share-images/before.png
new file mode 100644
index 000000000..af6cd3660
Binary files /dev/null and b/docs/pr-assets/sop-share-images/before.png differ
diff --git a/docs/pr-assets/sop-share-images/share.png b/docs/pr-assets/sop-share-images/share.png
new file mode 100644
index 000000000..93fe39d38
Binary files /dev/null and b/docs/pr-assets/sop-share-images/share.png differ
diff --git a/packages/workflows-ui/src/guide.ts b/packages/workflows-ui/src/guide.ts
index 9c9257aac..a902d5ead 100644
--- a/packages/workflows-ui/src/guide.ts
+++ b/packages/workflows-ui/src/guide.ts
@@ -1,6 +1,6 @@
// screenpipe — AI that knows everything you've seen, said, or heard
// https://screenpipe.com
-import { orderedBlockIds, parseDocumentLayout, type AddedDocumentBlock, type DocumentLayout } from "./document-blocks";
+import { orderedBlockIds, parseDocumentLayout, safeBlockMediaUrl, type AddedDocumentBlock, type DocumentLayout } from "./document-blocks";
import { parseVideoDraft, type VideoDraft } from "./video-tool";
import { stageScreenshots } from "./screenshots";
import type { WorkflowMap } from "./model";
@@ -240,8 +240,8 @@ export function guideHtml(
return `<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data: https:; media-src https:; style-src 'unsafe-inline'"><title>${escape(guide.title)}</title><style>body{font:16px/1.65 system-ui;color:#20221d;background:#fafaf7;max-width:820px;margin:60px auto;padding:0 28px}h1{font-size:38px;line-height:1.15}h2{font-size:22px}section,article{margin:30px 0}article{border-top:1px solid #ddd;padding-top:20px}img,video{max-width:100%;border:1px solid #ddd;border-radius:8px}p{white-space:pre-wrap}small{color:#666}@media print{body{margin:0}article{break-inside:avoid}}</style><body><small>SCREENPIPE · STANDARD OPERATING PROCEDURE · DRAFT FOR REVIEW</small><h1>${escape(guide.title)}</h1>${content}<footer><small>Based on workflow revision ${guide.sourceRevision}. Review before use.</small></footer></body></html>`;
}
-/** Text-only SOP for the hosted editor. Never serializes raw evidence or image data. */
-export function guideMarkdown(guide: WorkflowGuide): string {
+/** Text projection unless the sharing adapter supplies uploaded screenshot URLs. */
+export function guideMarkdown(guide: WorkflowGuide, images?: Record<string, string>): string {
const section = (title: string, values: string[]) =>
values.filter(Boolean).length
? `\n## ${title}\n\n${values
@@ -254,13 +254,13 @@ export function guideMarkdown(guide: WorkflowGuide): string {
["prerequisites", section("Before you start", guide.prerequisites)],
...guide.steps.flatMap((step, index): Array<[string,string]> => {
const id = `step/${step.blockId ?? `step-${index}`}`;
- return [[`${id}/title`, `\n## ${index + 1}. ${step.title}\n`], [`${id}/text`, step.instruction], [`${id}/image`, ""], [`${id}/result`, step.expectedResult ? `**Expected result:** ${step.expectedResult}` : ""]];
+ return [[`${id}/title`, `\n## ${index + 1}. ${step.title}\n`], [`${id}/text`, step.instruction], [`${id}/image`, images?.[id] && guideStepIncludesImage(step) ? `![${step.title.replace(/[\[\]\\]/g, "")}](<${images[id]}>)` : ""], [`${id}/result`, step.expectedResult ? `**Expected result:** ${step.expectedResult}` : ""]];
}),
["exceptions", section("Exceptions", guide.exceptions)],
["completion", section("Check your result", guide.completion)],
["questions", section("Still to confirm", guide.questions)],
];
- return `# ${guide.title}\n\n` + renderDocumentEntries(entries, guide.documentLayout, block => block.type === "divider" ? "---" : block.type === "heading" ? `## ${block.text}` : block.text, "\n\n");
+ return `# ${guide.title}\n\n` + renderDocumentEntries(entries, guide.documentLayout, block => block.type === "divider" ? "---" : block.type === "heading" ? `## ${block.text}` : images && block.type === "image" && block.url && safeBlockMediaUrl(block.url) ? `![${block.text.replace(/[\[\]\\]/g, "")}](<${block.url}>)` : block.text, "\n\n");
}
diff --git a/packages/workflows-ui/src/platform.ts b/packages/workflows-ui/src/platform.ts
index 7cc94fd92..f4bc4d789 100644
--- a/packages/workflows-ui/src/platform.ts
+++ b/packages/workflows-ui/src/platform.ts
@@ -124,7 +124,7 @@ export type WorkflowsPlatform = {
signal: AbortSignal,
progress: (message: string) => void,
) => Promise<WorkflowGuide>;
- openWeb?: (guide: WorkflowGuide) => Promise<void>;
+ openWeb?: (guide: WorkflowGuide, workflow: WorkflowMap) => Promise<void>;
export: (html: string, title: string) => Promise<boolean>;
};
generateWorkflowSkill?: (
diff --git a/packages/workflows-ui/src/rich-text.module.css b/packages/workflows-ui/src/rich-text.module.css
index 02bd040b9..a2229648e 100644
--- a/packages/workflows-ui/src/rich-text.module.css
+++ b/packages/workflows-ui/src/rich-text.module.css
@@ -92,3 +92,7 @@
@media print { .toolbar { display: none; } }
.root .toolbar button svg { flex-shrink: 0; }
+
+.image { display: inline-flex; flex-direction: column; gap: 8px; max-width: 100%; margin: 16px 0; }
+.image img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line, #deded5); border-radius: 8px; }
+.image button { align-self: flex-start; font: inherit; font-size: 12px; }
diff --git a/packages/workflows-ui/src/rich-text.tsx b/packages/workflows-ui/src/rich-text.tsx
index 84e33962a..a107a6f4f 100644
--- a/packages/workflows-ui/src/rich-text.tsx
+++ b/packages/workflows-ui/src/rich-text.tsx
@@ -30,6 +30,7 @@ export function WorkflowRichText({
maxLength = 4000,
className = "",
fullDocument = false,
+ imageUrl,
}: {
value: string;
onChange?: (value: string) => void;
@@ -38,11 +39,12 @@ export function WorkflowRichText({
maxLength?: number;
className?: string;
fullDocument?: boolean;
+ imageUrl?: (src: string) => string | null;
}) {
const host = useRef<HTMLDivElement>(null);
const view = useRef<EditorView>();
- const current = useRef({ value, onChange, maxLength });
- current.current = { value, onChange, maxLength };
+ const current = useRef({ value, onChange, maxLength, imageUrl });
+ current.current = { value, onChange, maxLength, imageUrl };
const emitted = useRef(value);
const [expanded, setExpanded] = useState(false);
const [long, setLong] = useState(false);
@@ -59,6 +61,31 @@ export function WorkflowRichText({
plugins: editable ? procedureMarkdownPlugins() : [],
}),
editable: () => editable,
+ nodeViews: imageUrl ? {
+ image(node, editor, getPos) {
+ const dom = document.createElement("span");
+ dom.className = styles.image;
+ dom.contentEditable = "false";
+ const url = current.current.imageUrl?.(node.attrs.src);
+ if (!url) { dom.textContent = node.attrs.alt || "Image reference"; return { dom }; }
+ const img = document.createElement("img");
+ img.src = url; img.alt = node.attrs.alt || "SOP screenshot";
+ img.loading = "lazy"; img.referrerPolicy = "no-referrer";
+ dom.append(img);
+ if (editable) {
+ const remove = document.createElement("button");
+ remove.type = "button"; remove.textContent = "Remove image";
+ remove.setAttribute("aria-label", `Remove image: ${img.alt}`);
+ remove.addEventListener("click", event => {
+ event.preventDefault();
+ const position = getPos();
+ if (typeof position === "number") editor.dispatch(editor.state.tr.delete(position, position + node.nodeSize));
+ });
+ dom.append(remove);
+ }
+ return { dom, stopEvent: event => (event.target as HTMLElement).closest("button") !== null };
+ },
+ } : undefined,
attributes: (state) => ({
"data-empty": String(state.doc.content.size === 2),
...(editable
@@ -141,7 +168,7 @@ export function WorkflowRichText({
editor.destroy();
view.current = undefined;
};
- }, [editable, id, label, placeholder, fullDocument]);
+ }, [editable, id, label, placeholder, fullDocument, imageUrl]);
useEffect(() => {
if (!view.current || value === emitted.current) return;
diff --git a/packages/workflows-ui/src/sop-document.tsx b/packages/workflows-ui/src/sop-document.tsx
index 2bfde2c4a..8095d1c37 100644
--- a/packages/workflows-ui/src/sop-document.tsx
+++ b/packages/workflows-ui/src/sop-document.tsx
@@ -1,7 +1,7 @@
// screenpipe — AI that knows everything you've seen, said, or heard
// https://screenpipe.com
"use client";
-import type { ReactNode } from "react";
+import { useRef, type ReactNode } from "react";
import { InlineText } from "./inline-text";
import { WorkflowRichText } from "./rich-text";
import styles from "./sop-document.module.css";
@@ -15,6 +15,7 @@ export function SopDocument({
onContentChange,
children,
kind = "sop",
+ imageUrl,
}: {
title: string;
subtitle?: ReactNode;
@@ -23,7 +24,10 @@ export function SopDocument({
onContentChange?: (content: string) => void;
children?: ReactNode;
kind?: "sop" | "skill";
+ imageUrl?: (src: string) => string | null;
}) {
+ const importedTitle = useRef(title);
+ const heading = [title, importedTitle.current].find(value => content?.startsWith(`# ${value}\n`));
return (
<article className={styles.document} aria-label={kind === "skill" ? "Skill document" : "SOP document"}>
<header className={styles.heading}>
@@ -43,7 +47,8 @@ export function SopDocument({
</header>
{content !== undefined && (
<WorkflowRichText
- value={content}
+ imageUrl={imageUrl}
+ value={heading ? content.slice(heading.length + 3).trimStart() : content}
onChange={onContentChange}
label={kind === "skill" ? "Instructions" : "SOP text"}
maxLength={kind === "skill" ? 20000 : 60000}
diff --git a/packages/workflows-ui/src/source-sop-screenshot.tsx b/packages/workflows-ui/src/source-sop-screenshot.tsx
index 43ba67c95..ed4d1ff1c 100644
--- a/packages/workflows-ui/src/source-sop-screenshot.tsx
+++ b/packages/workflows-ui/src/source-sop-screenshot.tsx
@@ -5,11 +5,12 @@ import { useSourceScreenshot } from "./use-source-screenshot";
import type { WorkflowsPlatform } from "./platform";
import styles from "./workflow-guide.module.css";
-export function SourceSopScreenshot({ stage, load, title, alt }: {
+export function SourceSopScreenshot({ stage, load, title, alt, onRemove }: {
stage: Parameters<typeof useSourceScreenshot>[0];
load: NonNullable<WorkflowsPlatform["guides"]>["loadSourceScreenshot"];
title: string;
alt?: string;
+ onRemove?: () => void;
}) {
const source = useSourceScreenshot(stage, false, load);
return <figure ref={source.ref}>
@@ -17,5 +18,6 @@ export function SourceSopScreenshot({ stage, load, title, alt }: {
: <p className={styles.muted} role="status">{source.status === "loading" ? "Loading screenshot…" : "No captured screenshot available for this step."}
{source.canRetry && source.status !== "loading" && <button onClick={source.retry}>Try again</button>}
</p>}
+ {source.image && onRemove && <button onClick={onRemove}>Remove screenshot</button>}
</figure>;
}
diff --git a/packages/workflows-ui/src/workflow-guide.module.css b/packages/workflows-ui/src/workflow-guide.module.css
index c9e80dae3..c284ebed3 100644
--- a/packages/workflows-ui/src/workflow-guide.module.css
+++ b/packages/workflows-ui/src/workflow-guide.module.css
@@ -87,7 +87,7 @@
}
.layout {
display: grid;
- grid-template-columns: 205px minmax(0, 820px);
+ grid-template-columns: minmax(0, 900px);
gap: 48px;
justify-content: center;
padding-top: 24px;
@@ -487,7 +487,7 @@
}
@media (max-width: 1050px) {
.layout {
- grid-template-columns: minmax(0, 820px);
+ grid-template-columns: minmax(0, 900px);
gap: 0;
}
.outline {
@@ -543,7 +543,7 @@
}
@container sop-guide (max-width: 1050px) {
.layout {
- grid-template-columns: minmax(0, 780px);
+ grid-template-columns: minmax(0, 900px);
}
.outline {
display: none;
@@ -632,3 +632,13 @@
.sourceReviewRow { align-items: flex-start; gap: 10px; }
.sourceReviewRow img { width: 72px; max-height: 56px; }
}
+
+.withOutline { grid-template-columns: 205px minmax(0, 900px); }
+.outline[hidden], .layout[hidden] { display: none; }
+@media (max-width: 900px) { .withOutline { grid-template-columns: minmax(0, 900px); } }
+
+.withOutline .outline { display: block; }
+@container sop-guide (max-width: 1050px) {
+ .withOutline { grid-template-columns: minmax(0, 900px); }
+ .withOutline .outline { position: static; border-bottom: 1px solid var(--line, #deded5); padding: 0 0 16px; margin-bottom: 20px; }
+}
diff --git a/packages/workflows-ui/src/workflow-guide.tsx b/packages/workflows-ui/src/workflow-guide.tsx
index d1828b56e..81a4bc1de 100644
--- a/packages/workflows-ui/src/workflow-guide.tsx
+++ b/packages/workflows-ui/src/workflow-guide.tsx
@@ -78,7 +78,8 @@ export function WorkflowGuide({
const [saved, setSaved] = useState("");
const [announcement, setAnnouncement] = useState("");
const root = useRef<HTMLDivElement>(null);
- const [images, setImages] = useState(false);
+ const [images, setImages] = useState(true);
+ const [outlineOpen, setOutlineOpen] = useState(false);
const [exporting, setExporting] = useState(false);
const [openingWeb, setOpeningWeb] = useState(false);
const webDialog = useRef<HTMLDialogElement>(null);
@@ -267,7 +268,8 @@ export function WorkflowGuide({
)}
{draft && (
<>
- <DocumentActions document={{ kind: "sop", title: draft.title, markdown: guideMarkdown(draft) }} onShare={onShareDocument} download={downloadDocument} />
+ <button className={styles.actionButton} aria-expanded={outlineOpen} onClick={() => setOutlineOpen(!outlineOpen)}>Contents</button>
+ <DocumentActions document={{ kind: "sop", title: draft.title, markdown: guideMarkdown(draft) }} onShare={platform.openWeb ? () => { setWebError(""); webDialog.current?.showModal(); } : onShareDocument} download={downloadDocument} />
{platform.video && <GuideVideoPanel container={videoContainer} onOpenChange={setVideoOpen} ref={videoHandle} guide={draft} workflow={workflow} platform={platform.video} loadScreenshot={platform.loadScreenshot} loadSourceScreenshot={platform.loadSourceScreenshot} save={persist} onVideoMode={setVideoMode} onLayoutChange={videoLayout => update({ ...latest.current!, videoLayout })} assistantBusy={videoBusy} onCreate={platform.video.edit ? () => {
if (videoRequested.current) return;
videoRequested.current = true;
@@ -297,7 +299,7 @@ export function WorkflowGuide({
aria-label={ui("Export SOP")}
title={ui("Export SOP")}
onClick={() => {
- setImages(false);
+ setImages(true);
setExportError("");
dialog.current?.showModal();
}}
@@ -358,9 +360,9 @@ export function WorkflowGuide({
</button>
</div>
<p>
- Save this SOP’s text to your Screenpipe account to edit and share it.
- Recordings and screenshots stay on this device. Existing web edits are
- preserved.
+ Save this SOP and its included images to your Screenpipe account.
+ Remove any image from the SOP before continuing if you don’t want to share it.
+ Your draft stays private until you publish it on the web. Existing web edits are preserved.
</p>
{webError && <p role="alert">{webError}</p>}
<div className={styles.dialogActions}>
@@ -378,7 +380,7 @@ export function WorkflowGuide({
setOpeningWeb(true);
setWebError("");
try {
- await platform.openWeb?.(draft);
+ await platform.openWeb?.(draft, workflow);
webDialog.current?.close();
} catch (e) {
setWebError(
@@ -404,8 +406,8 @@ export function WorkflowGuide({
{error && <button onClick={() => void openGuide()}>Try again</button>}
</SopDocument>
) : (
- <div className={styles.layout} hidden={videoOpen}>
- <aside className={styles.outline}>
+ <div className={`${styles.layout} ${outlineOpen ? styles.withOutline : ""}`} hidden={videoOpen}>
+ <aside className={styles.outline} hidden={!outlineOpen}>
<p className={styles.eyebrow}>In this guide</p>
<a onClick={jump} href="#guide-prerequisites">
Before you start
@@ -591,7 +593,7 @@ export function WorkflowGuide({
}}
/>
) : !image && !stale && guideStepIncludesImage(step) && !step.imageReview && sourceStage !== null && workflow.stages[sourceStage] ? (
- <SourceSopScreenshot stage={workflow.stages[sourceStage!]} load={platform.loadSourceScreenshot} title={step.title} />
+ <SourceSopScreenshot onRemove={() => changeStep(i, { includeImage: false, imageExcluded: true })} stage={workflow.stages[sourceStage!]} load={platform.loadSourceScreenshot} title={step.title} />
) : !image ? (
<p className={styles.muted}>
{stale
@@ -678,7 +680,7 @@ export function WorkflowGuide({
disabled={Boolean(stale)}
onChange={(e) => setImages(e.target.checked)}
/>
- Include screenshots I have reviewed
+ Include images
</label>
<small>
Screenshots can contain customer information. Only the selected guide