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: lock dashboard controls during AI generation
Louis Beaumontbd5152819872
diff --git a/apps/screenpipe-app-tauri/components/settings/__tests__/brain-overview.test.tsx b/apps/screenpipe-app-tauri/components/settings/__tests__/brain-overview.test.tsxindex 08156bc30..9d2912050 100644--- a/apps/screenpipe-app-tauri/components/settings/__tests__/brain-overview.test.tsx+++ b/apps/screenpipe-app-tauri/components/settings/__tests__/brain-overview.test.tsx@@ -4,7 +4,13 @@import React from "react";import { beforeEach, describe, expect, it, vi } from "vitest";-import { fireEvent, render, screen, waitFor } from "@testing-library/react";+import {+ act,+ fireEvent,+ render,+ screen,+ waitFor,+} from "@testing-library/react";const mocks = vi.hoisted(() => ({listBrainViews: vi.fn(),@@ -860,6 +866,68 @@ describe("BrainOverview", () => {);});+ it("locks dashboard navigation while AI generation is in progress", async () => {+ mocks.listBrainViews.mockResolvedValue({+ status: "ok",+ data: [+ populatedView,+ { ...populatedView, id: "projects", title: "Projects" },+ ],+ });+ let finishGeneration:+ | ((result: {+ title: string;+ timeRange: "today";+ note: string;+ blocks: Array<{+ title: string;+ component: "metric.v1";+ width: 6;+ pipeName: string;+ }>;+ }) => void)+ | null = null;+ mocks.generateLiveViewWithPi.mockImplementation(+ () =>+ new Promise((resolve) => {+ finishGeneration = resolve;+ }),+ );+ render(<BrainOverview />);++ fireEvent.change(+ await screen.findByPlaceholderText(/Ask AI to create a dashboard/),+ { target: { value: "track my time" } },+ );+ const generateButton = screen.getByTestId("live-view-ai-generate");+ await waitFor(() => expect(generateButton).not.toBeDisabled());+ fireEvent.click(generateButton);++ await waitFor(() =>+ expect(mocks.generateLiveViewWithPi).toHaveBeenCalledTimes(1),+ );+ expect(screen.getByTestId("overview-dashboard-selector")).toBeDisabled();+ expect(screen.getByTestId("overview-new-dashboard")).toBeDisabled();+ expect(screen.getByTestId("overview-edit")).toBeDisabled();++ await act(async () => {+ finishGeneration?.({+ title: "Time tracking",+ timeRange: "today",+ note: "A time dashboard.",+ blocks: [+ {+ title: "Active time",+ component: "metric.v1",+ width: 6,+ pipeName: "daily-summary",+ },+ ],+ });+ });+ await screen.findByText("AI draft");+ });+it("creates whole-dashboard AI drafts as a new named dashboard by default", async () => {const existingProjectPulse: ViewDefinition = {...populatedView,diff --git a/apps/screenpipe-app-tauri/components/settings/brain-overview.tsx b/apps/screenpipe-app-tauri/components/settings/brain-overview.tsxindex 566a1adad..3826318b6 100644--- a/apps/screenpipe-app-tauri/components/settings/brain-overview.tsx+++ b/apps/screenpipe-app-tauri/components/settings/brain-overview.tsx@@ -617,6 +617,7 @@ export function BrainOverview() {preset: AIPreset,intent: LiveViewGenerationIntent,) => {+ setTemplateGalleryOpen(false);setGenerating(true);try {const generated = await generateLiveViewWithPi({@@ -1563,6 +1564,7 @@ export function BrainOverview() {const refreshIsActive =dataRefresh?.viewId === view.id &&(dataRefresh.status === "starting" || dataRefresh.status === "running");+ const dashboardBusy = saving || refreshIsActive || generating;return (<div className="min-h-0 flex-1 overflow-y-auto pb-8 pr-4 [scrollbar-gutter:stable]"><div className="mb-5 grid gap-4 border-b border-border pb-4 xl:grid-cols-[minmax(0,1fr)_auto] xl:items-end">@@ -1570,7 +1572,7 @@ export function BrainOverview() {<LiveViewDashboardSwitcherviews={views}current={view}- busy={saving || refreshIsActive}+ busy={dashboardBusy}onSelect={selectDashboard}onCreate={beginCreate}onRename={renameDashboard}@@ -1590,7 +1592,7 @@ export function BrainOverview() {data-testid="overview-time-range"aria-label="Live View time range"value={view.timeRange}- disabled={saving || refreshIsActive}+ disabled={dashboardBusy}className="h-9 min-w-36 flex-1 border border-border bg-background px-3 text-xs outline-none focus:border-foreground disabled:opacity-50 sm:flex-none"onChange={(event) =>void changeTimeRange(event.target.value as BrainViewTimeRange)@@ -1608,6 +1610,7 @@ export function BrainOverview() {variant="outline"size="sm"className="h-9 flex-1 rounded-none px-3 sm:flex-none"+ disabled={dashboardBusy}onClick={() => setTemplateGalleryOpen((open) => !open)}><LayoutTemplate className="mr-1.5 h-3.5 w-3.5" /> templates@@ -1620,7 +1623,7 @@ export function BrainOverview() {size="sm"className="h-9 flex-1 rounded-none px-3 sm:flex-none"aria-label={refreshIsActive ? "loading data" : "refresh data"}- disabled={refreshIsActive}+ disabled={dashboardBusy}onClick={() => void refreshConnectedPipes(view)}><RefreshCw@@ -1636,6 +1639,7 @@ export function BrainOverview() {variant="outline"size="sm"className="h-9 flex-1 rounded-none px-3 sm:flex-none"+ disabled={dashboardBusy}onClick={beginEdit}><SlidersHorizontal className="mr-1.5 h-3.5 w-3.5" /> customize