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): keep context fill running across navigation (#7272)

Louis Beaumont52b349970782
diff --git a/.github/pr-assets/context-fill-navigation/README.md b/.github/pr-assets/context-fill-navigation/README.md
new file mode 100644
index 000000000..45465c12e
--- /dev/null
+++ b/.github/pr-assets/context-fill-navigation/README.md
@@ -0,0 +1,9 @@
+# Context fill navigation
+
+Real shared Workflows UI, using fictional notes and a delayed fixture adapter in the maintained web preview. No customer logs, names, or recordings are included.
+
+- `before.png`: baseline `68d02ba05`, after starting Fill context, opening Home before the first result, waiting for completion, and returning to Context. The notes and results are lost.
+- `after.png`: the same sequence and 1280 × 1000 viewport after the fix. Both proposed fields are saved and the pasted draft remains.
+- `loading.png`: the initial in-progress state with Stop available.
+
+The temporary preview route was removed before commit. Browser checks establish the shared UI lifecycle, not real model output or installed Windows-app recovery. The field adapter in this preview returns fictional results after a fixed delay.
diff --git a/.github/pr-assets/context-fill-navigation/after.png b/.github/pr-assets/context-fill-navigation/after.png
new file mode 100644
index 000000000..fb915ec74
Binary files /dev/null and b/.github/pr-assets/context-fill-navigation/after.png differ
diff --git a/.github/pr-assets/context-fill-navigation/before.png b/.github/pr-assets/context-fill-navigation/before.png
new file mode 100644
index 000000000..baaba84ae
Binary files /dev/null and b/.github/pr-assets/context-fill-navigation/before.png differ
diff --git a/.github/pr-assets/context-fill-navigation/loading.png b/.github/pr-assets/context-fill-navigation/loading.png
new file mode 100644
index 000000000..cf52afaf4
Binary files /dev/null and b/.github/pr-assets/context-fill-navigation/loading.png differ
diff --git a/apps/screenpipe-app-tauri/components/workflows/context-navigation.test.tsx b/apps/screenpipe-app-tauri/components/workflows/context-navigation.test.tsx
new file mode 100644
index 000000000..bad7ae766
--- /dev/null
+++ b/apps/screenpipe-app-tauri/components/workflows/context-navigation.test.tsx
@@ -0,0 +1,123 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+
+import React from "react";
+import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { afterEach, expect, it, vi } from "vitest";
+import { WorkflowsApp } from "@screenpipe/workflows-ui";
+import { createFixtureWorkflowsPlatform, fixtureWorkflowAnalysis, fixturePersonalWorkProfile } from "@screenpipe/workflows-ui/fixture";
+import type { ContextFillRequest } from "@screenpipe/workflows-ui/context";
+
+afterEach(cleanup);
+function setup(scoped = false) {
+ window.history.replaceState(null, "", "/?view=profile");
+ const platform = createFixtureWorkflowsPlatform();
+ platform.loadCapturedWork = async () => structuredClone(fixtureWorkflowAnalysis);
+ platform.loadWorkProfile = vi.fn().mockResolvedValue({ ...fixturePersonalWorkProfile, company: "", summary: "" });
+ platform.saveWorkProfile = vi.fn().mockImplementation(async p => p);
+ platform.contextDiscovery = true;
+ if (scoped) {
+ const ensureRuntime = platform.ensureRuntime;
+ platform.ensureRuntime = async () => ({ ...await ensureRuntime(), availableScopes: [
+ { id: "personal", kind: "personal", label: "Personal" },
+ { id: "team", kind: "team", label: "Team" },
+ ] });
+ }
+ let request!: ContextFillRequest;
+ let finish!: () => void;
+ let fail!: (error: Error) => void;
+ platform.fillContext = vi.fn().mockImplementation((req: ContextFillRequest) => {
+ request = req;
+ req.onActivity("Reading sources…");
+ return new Promise<void>((resolve, reject) => {
+ finish = resolve; fail = reject;
+ req.signal.addEventListener("abort", () => resolve(), { once: true });
+ });
+ });
+ const app = render(<WorkflowsApp platform={platform} storageKey={null} />);
+ const start = async () => {
+ fireEvent.click(await screen.findByRole("button", { name: "Fill context", exact: true }));
+ await waitFor(() => expect(platform.fillContext).toHaveBeenCalledOnce());
+ return request;
+ };
+ return { ...app, platform, start, finish: () => finish(), fail: () => fail(new Error("Source unavailable. Try again.")) };
+}
+
+it("fills and saves in the background across navigation, preserving draft and manual edits", async () => {
+ const app = setup();
+ fireEvent.change(await screen.findByRole("textbox", { name: "Paste context" }), { target: { value: "My research notes" } });
+ const req = await app.start();
+ fireEvent.change(screen.getByRole("textbox", { name: "Role and responsibilities" }), { target: { value: "My newer edit" } });
+ fireEvent.click(screen.getByRole("button", { name: /^Home/ }));
+ expect(screen.queryByRole("textbox", { name: "Paste context" })).toBeNull();
+ expect(req.signal.aborted).toBe(false);
+ await act(async () => {
+ req.onField({ field: "summary", value: "Older proposal" });
+ req.onField({ field: "company", value: "Example Studio organizes research." });
+ app.finish();
+ });
+ await waitFor(() => expect(app.platform.saveWorkProfile).toHaveBeenCalledWith(expect.objectContaining({ company: "Example Studio organizes research.", summary: "My newer edit" }), undefined));
+ fireEvent.click(screen.getByRole("button", { name: "Context", exact: true }));
+ expect(screen.getByRole("textbox", { name: "Paste context" })).toHaveValue("My research notes");
+ expect(screen.getByRole("textbox", { name: "Company overview" })).toHaveValue("Example Studio organizes research.");
+ expect(screen.getByText(/1 section filled/)).toBeVisible();
+ expect(app.platform.fillContext).toHaveBeenCalledOnce();
+});
+
+it("keeps Stop available on return, preserves partial results, and ignores late fields", async () => {
+ const app = setup(); const req = await app.start();
+ act(() => req.onField({ field: "company", value: "Kept result" }));
+ fireEvent.click(screen.getByRole("button", { name: /^Home/ }));
+ fireEvent.click(screen.getByRole("button", { name: "Context", exact: true }));
+ await act(async () => fireEvent.click(screen.getByRole("button", { name: "Stop", exact: true })));
+ expect(req.signal.aborted).toBe(true);
+ act(() => req.onField({ field: "summary", value: "Too late" }));
+ expect(screen.getByRole("textbox", { name: "Company overview" })).toHaveValue("Kept result");
+ expect(screen.getByRole("textbox", { name: "Role and responsibilities" })).toHaveValue("");
+ expect(screen.getByText("Stopped. Filled fields were kept.")).toBeVisible();
+ expect(screen.getByRole("button", { name: "Fill context", exact: true })).toBeEnabled();
+});
+
+it("does not cancel when the Workflows surface is hidden or the browser loses focus", async () => {
+ const app = setup(); const req = await app.start();
+ app.rerender(<WorkflowsApp platform={app.platform} storageKey={null} active={false} />);
+ fireEvent(window, new Event("blur"));
+ fireEvent(document, new Event("visibilitychange"));
+ expect(req.signal.aborted).toBe(false);
+ await act(async () => { req.onField({ field: "company", value: "Background result" }); app.finish(); });
+ app.rerender(<WorkflowsApp platform={app.platform} storageKey={null} active />);
+ expect(screen.getByRole("textbox", { name: "Company overview" })).toHaveValue("Background result");
+});
+
+it("aborts when the app actually closes", async () => {
+ const app = setup(); const req = await app.start();
+ app.unmount();
+ expect(req.signal.aborted).toBe(true);
+ act(() => req.onField({ field: "company", value: "Too late" }));
+ expect(app.platform.saveWorkProfile).not.toHaveBeenCalled();
+});
+
+
+it("cancels a fill at the scope boundary and never saves its late fields into the new scope", async () => {
+ const app = setup(true); const req = await app.start();
+ fireEvent.change(screen.getByRole("combobox", { name: "Workflows scope" }), { target: { value: "team" } });
+ await waitFor(() => expect(req.signal.aborted).toBe(true));
+ await screen.findByRole("button", { name: "Fill context", exact: true });
+ act(() => req.onField({ field: "company", value: "Private previous-scope result" }));
+ expect(screen.getByRole("textbox", { name: "Company overview" })).toHaveValue("");
+ expect(app.platform.saveWorkProfile).not.toHaveBeenCalled();
+ expect(app.platform.loadWorkProfile).toHaveBeenLastCalledWith(expect.objectContaining({ id: "team" }));
+});
+
+
+it("keeps a background failure visible on return and allows a retry", async () => {
+ const app = setup(); await app.start();
+ fireEvent.click(screen.getByRole("button", { name: /^Home/ }));
+ await act(async () => app.fail());
+ fireEvent.click(screen.getByRole("button", { name: "Context", exact: true }));
+ expect(screen.getByRole("alert")).toHaveTextContent("Source unavailable. Try again.");
+ fireEvent.click(screen.getByRole("button", { name: "Fill context", exact: true }));
+ expect(app.platform.fillContext).toHaveBeenCalledTimes(2);
+ expect(screen.queryByRole("alert")).toBeNull();
+ await act(async () => app.finish());
+});
diff --git a/packages/workflows-ui/src/workflows-app.tsx b/packages/workflows-ui/src/workflows-app.tsx
index 5aa25f6c4..bd1c8c5f8 100644
--- a/packages/workflows-ui/src/workflows-app.tsx
+++ b/packages/workflows-ui/src/workflows-app.tsx
@@ -1662,7 +1662,7 @@ export function WorkflowsApp({ platform, initialAnalysis = null, storageKey = "s
setAnalysis(updated);
} : undefined} />; break;
case "bottlenecks": content = <BottlenecksView workflows={workflows} openWorkflow={openWorkflow} />; break;
- case "profile": content = workProfile ? <ProfileView contextDiscovery={platform.contextDiscovery} fillContext={platform.fillContext} profile={workProfile} workspaceView={workspaceProfile} saving={contextProfile.status === "saving"} saved={contextProfile.status === "saved"} error={contextProfile.error} update={contextProfile.update} retry={contextProfile.retry} /> : <div className={styles.contextPage}><h1>Context</h1>{contextProfile.error ? <p role="alert">{contextProfile.error} <button type="button" onClick={contextProfile.retry}>Retry</button></p> : <p role="status">Loading context…</p>}</div>; break;
+ case "profile": content = null; break;
case "evidence": content = <EvidenceView workflows={workflows} openWorkflow={openWorkflow} runtime={runtime} />; break;
case "privacy": content = <PrivacyView runtime={runtime} />; break;
}
@@ -1678,7 +1678,13 @@ export function WorkflowsApp({ platform, initialAnalysis = null, storageKey = "s
}
return <>
- <AppShell modelControl={platform.modelPreference ? <WorkflowModelControl preference={platform.modelPreference} /> : undefined} composerAccessory={composerAccessory} active={active} fullscreen={fullscreen} navigationFooter={navigationFooter} navigationBrand={navigationBrand} recordingStatus={recordingStatus} view={view} navigate={navigate} runtime={runtime} workflowCount={knownWorkflows.length} query={filters.query} setQuery={(query) => setFilters((current) => ({ ...current, query }))} activeScope={activeScope} scopes={scopes} setScope={selectScope} embedded={embedded} startWindowDrag={platform.startWindowDrag} openCommandPalette={() => setCommandPaletteOpen(true)} assistant={platform.assistant ? { platform: platform.assistant, context: view === "workflow" && activeWorkflow ? { key: `workflow:${activeWorkflow.title}`, title: activeWorkflow.title, workflow: activeWorkflow } : view === "profile" ? { key: "profile", title: ui("Context"), profile: workProfile } : { key: "workflows", title: ui("Your workflows"), catalog: workflows.map(({ title, description }) => ({ title, description })) } } : undefined}>{statusNotice}{content}</AppShell>
+ <AppShell modelControl={platform.modelPreference ? <WorkflowModelControl preference={platform.modelPreference} /> : undefined} composerAccessory={composerAccessory} active={active} fullscreen={fullscreen} navigationFooter={navigationFooter} navigationBrand={navigationBrand} recordingStatus={recordingStatus} view={view} navigate={navigate} runtime={runtime} workflowCount={knownWorkflows.length} query={filters.query} setQuery={(query) => setFilters((current) => ({ ...current, query }))} activeScope={activeScope} scopes={scopes} setScope={selectScope} embedded={embedded} startWindowDrag={platform.startWindowDrag} openCommandPalette={() => setCommandPaletteOpen(true)} assistant={platform.assistant ? { platform: platform.assistant, context: view === "workflow" && activeWorkflow ? { key: `workflow:${activeWorkflow.title}`, title: activeWorkflow.title, workflow: activeWorkflow } : view === "profile" ? { key: "profile", title: ui("Context"), profile: workProfile } : { key: "workflows", title: ui("Your workflows"), catalog: workflows.map(({ title, description }) => ({ title, description })) } } : undefined}>{statusNotice}
+ {/* Keep drafts, imports and the active fill alive when navigating away.
+ A different scope must tear down the old request before accepting fields. */}
+ <div key={`${activeScope?.kind ?? "personal"}:${activeScope?.id ?? ""}`} hidden={view !== "profile"}>
+ {workProfile ? <ProfileView contextDiscovery={platform.contextDiscovery} fillContext={platform.fillContext} profile={workProfile} workspaceView={workspaceProfile} saving={contextProfile.status === "saving"} saved={contextProfile.status === "saved"} error={contextProfile.error} update={contextProfile.update} retry={contextProfile.retry} /> : view === "profile" ? <div className={styles.contextPage}><h1>Context</h1>{contextProfile.error ? <p role="alert">{contextProfile.error} <button type="button" onClick={contextProfile.retry}>Retry</button></p> : <p role="status">Loading context…</p>}</div> : null}
+ </div>
+ {content}</AppShell>
<CommandPalette open={active && commandPaletteOpen} commands={paletteCommands} close={() => setCommandPaletteOpen(false)} />
</>;
}