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(activity): render persisted history immediately (#6622)
Ezra Ellettea7b7c739cd25
diff --git a/apps/screenpipe-app-tauri/components/activity-ledger.test.tsx b/apps/screenpipe-app-tauri/components/activity-ledger.test.tsxindex e02580502..4403f2b54 100644--- a/apps/screenpipe-app-tauri/components/activity-ledger.test.tsx+++ b/apps/screenpipe-app-tauri/components/activity-ledger.test.tsx@@ -484,6 +484,7 @@ describe("activity history helpers", () => {expect(artifacts.pathname).toBe("/activity-ledger");expect(artifacts.searchParams.get("depth")).toBe("task");expect(artifacts.searchParams.get("include_artifacts")).toBe("true");+ expect(artifacts.searchParams.get("refresh")).toBe("false");});it("requires more than 10 uncovered minutes before appending", () => {@@ -921,7 +922,7 @@ describe("activity history helpers", () => {expect(within(previews[0]).getByText("github.com")).toBeVisible();});- it("shows the complete icon set together before preview loading starts", async () => {+ it("shows persisted evidence before enriching the complete icon set", async () => {const persisted = parseActivityHistoryResponse(HISTORY_RESPONSE, {start: new Date("2026-08-17T16:00:00Z"),end: new Date("2026-08-17T20:00:00Z"),@@ -961,10 +962,18 @@ describe("activity history helpers", () => {mocks.localFetch.mock.calls.filter(([path]) =>String(path).startsWith("/frames/preview-samples?"),);- await waitFor(() =>- expect(screen.getByTestId("activity-ledger-skeleton")).toBeVisible(),- );- expect(screen.queryByRole("link", { name: /Open Arc/ })).toBeNull();+ expect(+ await screen.findByRole("heading", {+ name: "Fixed a capture reliability regression",+ }),+ ).toBeVisible();+ expect(+ screen.getByRole("link", { name: /Open Arc .* in Timeline/ }),+ ).toBeVisible();+ expect(+ screen.getByRole("link", { name: /Open Transcript .* in Timeline/ }),+ ).toBeVisible();+ expect(screen.queryByTestId("activity-ledger-skeleton")).toBeNull();expect(previewCalls()).toHaveLength(0);await act(async () => {@@ -1745,15 +1754,7 @@ describe("ActivityLedger", () => {});it("loads a completed encrypted ledger without regenerating it", async () => {- mocks.localFetch.mockImplementation((path: string) =>- path.startsWith("/activity-ledger?")- ? Promise.resolve({- ok: true,- status: 200,- json: async () => LEDGER_ARTIFACTS_RESPONSE,- })- : new Promise(() => undefined),- );+ mocks.localFetch.mockImplementation(() => new Promise(() => undefined));mocks.loadPersistedActivityHistory.mockImplementation(async (_producer: string, range: { start: Date; end: Date }) => ({entries: parseActivityHistoryResponse(HISTORY_RESPONSE, range).entries,@@ -1768,6 +1769,20 @@ describe("ActivityLedger", () => {render(<ActivityLedger />);+ expect(+ await screen.findByText("Fixed a capture reliability regression"),+ ).toBeVisible();+ expect(mocks.generateActivityHistory).not.toHaveBeenCalled();+ expect(+ mocks.localFetch.mock.calls.some(([path]) => {+ const url = new URL(String(path), "http://localhost");+ return (+ url.pathname === "/activity-ledger" &&+ url.searchParams.get("refresh") === "false"+ );+ }),+ ).toBe(true);+expect(await screen.findByRole("heading", {name: "Fixed a capture reliability regression",diff --git a/apps/screenpipe-app-tauri/components/activity-ledger.tsx b/apps/screenpipe-app-tauri/components/activity-ledger.tsxindex 224346883..9ba7649c4 100644--- a/apps/screenpipe-app-tauri/components/activity-ledger.tsx+++ b/apps/screenpipe-app-tauri/components/activity-ledger.tsx@@ -296,6 +296,7 @@ export function buildActivityLedgerArtifactsPath(range: TimeRange): string {end_time: range.end.toISOString(),depth: "task",include_artifacts: "true",+ refresh: "false",});return `/activity-ledger?${params.toString()}`;}@@ -1090,10 +1091,12 @@ function ArtifactPreviewTooltip({function ActivityEntryArtifacts({entry,intervals,+ artifactsLoading,openEvidence,}: {entry: ActivityHistoryEntry;intervals: ActivityLedgerArtifactInterval[];+ artifactsLoading: boolean;openEvidence: (evidence: ActivityArtifact) => void;}) {const artifacts = useMemo(@@ -1172,7 +1175,7 @@ function ActivityEntryArtifacts({key={artifactKey(evidence)}evidence={evidence}artifactName={artifactName}- artifactsLoading={false}+ artifactsLoading={artifactsLoading}loadPreviewFrames={loadPreviewFrames}onPreviewLoaded={onPreviewLoaded}>@@ -1988,7 +1991,7 @@ Re-query Screenpipe only inside the cited time range and use the cited frames an</div></div>)- ) : history && ledgerArtifactsReady ? (+ ) : history ? (<section aria-label="Activity history">{groupedEntries.map(([day, entries]) => (<div key={day} className="mb-12 last:mb-0">@@ -2034,6 +2037,7 @@ Re-query Screenpipe only inside the cited time range and use the cited frames an<ActivityEntryArtifactsentry={entry}intervals={ledgerIntervals}+ artifactsLoading={!ledgerArtifactsReady}openEvidence={openEvidence}/><span aria-hidden="true">·</span>@@ -2061,7 +2065,7 @@ Re-query Screenpipe only inside the cited time range and use the cited frames an</div>))}</section>- ) : !ledgerArtifactsReady || (loading && !summary) ? (+ ) : loading && !summary ? (<ActivityLedgerSkeleton label="Reading your day…" />) : error ? (<p className="text-sm text-muted-foreground">{error}</p>diff --git a/crates/screenpipe-engine/src/routes/activity_ledger.rs b/crates/screenpipe-engine/src/routes/activity_ledger.rsindex 83e829bbe..e5e734738 100644--- a/crates/screenpipe-engine/src/routes/activity_ledger.rs+++ b/crates/screenpipe-engine/src/routes/activity_ledger.rs@@ -40,6 +40,15 @@ pub struct ActivityLedgerQuery {/// context they did not request.#[serde(default)]pub include_artifacts: bool,+ /// Refresh the deterministic ledger before reading it. The desktop+ /// Activities page disables this because generated history is already+ /// persisted and artifact enrichment must not block first paint.+ #[serde(default = "default_refresh")]+ pub refresh: bool,+}++fn default_refresh() -> bool {+ true}#[derive(Debug, Clone, Serialize, OaSchema)]@@ -116,15 +125,17 @@ pub async fn get_activity_ledger(if query.end_time - query.start_time > Duration::days(31) {return Err(bad_request("activity ledger ranges are limited to 31 days"));}- crate::activity_ledger::reconcile_range(&state.db, query.start_time, query.end_time)- .await- .map_err(|error| {- error!(%error, "activity ledger generation failed");- (- StatusCode::INTERNAL_SERVER_ERROR,- JsonResponse(json!({"error": "activity ledger generation failed"})),- )- })?;+ if query.refresh {+ crate::activity_ledger::reconcile_range(&state.db, query.start_time, query.end_time)+ .await+ .map_err(|error| {+ error!(%error, "activity ledger generation failed");+ (+ StatusCode::INTERNAL_SERVER_ERROR,+ JsonResponse(json!({"error": "activity ledger generation failed"})),+ )+ })?;+ }let include_actions = query.depth == ActivityLedgerDepth::Action;let include_evidence = include_actions || query.include_artifacts;let records = state