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

[codex] simplify Brain navigation and Live View focus (#5775)

Louis Beaumontf9709b0b89cf
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.tsx
index 691d9e65b..b4d58f1ac 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
@@ -29,6 +29,8 @@ const mocks = vi.hoisted(() => ({
toast: vi.fn(),
refetchPipes: vi.fn(),
capture: vi.fn(),
+ usageState: null as any,
+ openBusinessUpgradeSurface: vi.fn(),
}));
const localStorageMock = (() => {
@@ -117,6 +119,12 @@ vi.mock("@/lib/hooks/use-settings", () => ({
},
}),
}));
+vi.mock("@/lib/hooks/use-usage-status", () => ({
+ useUsageStatus: () => mocks.usageState,
+}));
+vi.mock("@/lib/upgrade-flow", () => ({
+ openBusinessUpgradeSurface: mocks.openBusinessUpgradeSurface,
+}));
vi.mock("@/lib/hooks/use-health-check", () => ({
useHealthCheck: () => ({
health: { status: "healthy" },
@@ -306,6 +314,8 @@ const dailyMemoryTemplate = {
beforeEach(() => {
vi.clearAllMocks();
+ mocks.usageState = null;
+ mocks.openBusinessUpgradeSurface.mockResolvedValue(undefined);
Object.defineProperty(window, "localStorage", {
configurable: true,
value: localStorageMock,
@@ -889,6 +899,10 @@ describe("BrainOverview", () => {
expect(screen.queryByTestId("live-view-ai-options")).toBeNull();
fireEvent.focus(prompt);
expect(screen.getByTestId("live-view-ai-options")).toBeTruthy();
+ fireEvent.change(prompt, { target: { value: "keep this draft" } });
+ fireEvent.blur(prompt, { relatedTarget: null });
+ expect(prompt.rows).toBe(1);
+ expect(screen.queryByTestId("live-view-ai-options")).toBeNull();
await openDashboardMenu();
expect(await screen.findByTestId("overview-new-dashboard")).toBeTruthy();
@@ -897,6 +911,38 @@ describe("BrainOverview", () => {
);
});
+ it("disables exhausted hosted AI and opens the native upgrade surface", async () => {
+ mocks.usageState = {
+ tier: "logged_in",
+ used_today: 30,
+ limit_today: 30,
+ remaining: 0,
+ resets_at: "2026-08-03T00:00:00.000Z",
+ upsell_banner: true,
+ upgrade_eligible: true,
+ };
+ mocks.listBrainViews.mockResolvedValue({
+ status: "ok",
+ data: [populatedView],
+ });
+ render(<BrainOverview />);
+
+ const prompt = (await screen.findByTestId(
+ "live-view-ai-prompt",
+ )) as HTMLTextAreaElement;
+ expect(prompt).toBeDisabled();
+ expect(prompt.placeholder).toBe("Hosted AI limit reached");
+ expect(screen.queryByTestId("live-view-ai-options")).toBeNull();
+ expect(screen.queryByTestId("live-view-ai-generate")).toBeNull();
+
+ fireEvent.click(screen.getByTestId("live-view-ai-upgrade"));
+ await waitFor(() =>
+ expect(mocks.openBusinessUpgradeSurface).toHaveBeenCalledWith(
+ "live-view-ai-composer",
+ ),
+ );
+ });
+
it("hides time-range UI when the dashboard owns a fixed period", async () => {
mocks.listBrainViews.mockResolvedValue({
status: "ok",
diff --git a/apps/screenpipe-app-tauri/components/settings/__tests__/brain-section.filter.test.tsx b/apps/screenpipe-app-tauri/components/settings/__tests__/brain-section.filter.test.tsx
index 7748681bf..1749376a7 100644
--- a/apps/screenpipe-app-tauri/components/settings/__tests__/brain-section.filter.test.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/__tests__/brain-section.filter.test.tsx
@@ -133,6 +133,10 @@ vi.mock("@/components/settings/compact-markdown", () => ({
),
}));
+vi.mock("@/components/settings/brain-overview", () => ({
+ BrainOverview: () => <div data-testid="brain-overview-stub" />,
+}));
+
vi.mock("@/components/ui/use-toast", () => ({
useToast: () => ({ toast: vi.fn() }),
}));
@@ -200,26 +204,60 @@ const openDetailMenu = () =>
pointerType: "mouse",
});
+const openBrainViewMenu = () =>
+ fireEvent.pointerDown(screen.getByTestId("brain-view-switcher"), {
+ button: 0,
+ ctrlKey: false,
+ pointerType: "mouse",
+ });
+
+const selectBrainView = (view: "overview" | "memories" | "artifacts") => {
+ openBrainViewMenu();
+ fireEvent.click(screen.getByTestId(`brain-filter-${view}`));
+};
+
describe("BrainSection type filter", () => {
it("loads all tab totals before the user opens each tab", async () => {
render(<BrainSection />);
await waitFor(() => {
- expect(screen.getByTestId("brain-filter-overview")).toHaveTextContent("Live Views3");
- expect(screen.getByTestId("brain-filter-memories")).toHaveTextContent("Memories8");
- expect(screen.getByTestId("brain-filter-artifacts")).toHaveTextContent("Artifacts5");
+ expect(screen.getByTestId("brain-view-switcher")).toHaveTextContent("Memories8");
});
+
+ openBrainViewMenu();
+ expect(screen.getByTestId("brain-filter-overview")).toHaveTextContent("Live Views3");
+ expect(screen.getByTestId("brain-filter-memories")).toHaveTextContent("Memories8");
+ expect(screen.getByTestId("brain-filter-artifacts")).toHaveTextContent("Artifacts5");
});
it("shows memories by default", async () => {
render(<BrainSection />);
await waitFor(() => expect(memoryRows().length).toBe(8));
expect(artifactRows().length).toBe(0);
+ expect(screen.getByTestId("brain-view-switcher")).toHaveTextContent("Memories8");
expect(analyticsMocks.capture).toHaveBeenCalledWith("brain_viewed", {
tab: "memories",
});
});
+ it("keeps the same dropdown switcher in every Brain view", async () => {
+ render(<BrainSection />);
+ await waitFor(() => expect(memoryRows().length).toBe(8));
+
+ selectBrainView("artifacts");
+ await waitFor(() => expect(artifactRows().length).toBe(5));
+ expect(screen.getByTestId("brain-view-switcher")).toHaveTextContent("Artifacts5");
+
+ selectBrainView("overview");
+ await waitFor(() =>
+ expect(screen.getByTestId("brain-view-switcher")).toHaveTextContent("Live Views3"),
+ );
+
+ selectBrainView("memories");
+ await waitFor(() => expect(memoryRows().length).toBe(8));
+ expect(screen.getByTestId("brain-view-switcher")).toHaveTextContent("Memories8");
+ });
+
it("keeps the stale warning specific to memories", async () => {
const now = vi
.spyOn(Date, "now")
@@ -246,7 +284,7 @@ describe("BrainSection type filter", () => {
render(<BrainSection />);
await waitFor(() => expect(memoryRows().length).toBeGreaterThan(0));
- fireEvent.click(screen.getAllByTestId("brain-filter-artifacts")[0]);
+ selectBrainView("artifacts");
await waitFor(() => expect(artifactRows().length).toBe(5));
expect(memoryRows().length).toBe(0);
@@ -258,10 +296,10 @@ describe("BrainSection type filter", () => {
it("memories tab switches back from artifacts", async () => {
render(<BrainSection />);
- fireEvent.click(screen.getAllByTestId("brain-filter-artifacts")[0]);
+ selectBrainView("artifacts");
await waitFor(() => expect(artifactRows().length).toBe(5));
- fireEvent.click(screen.getAllByTestId("brain-filter-memories")[0]);
+ selectBrainView("memories");
await waitFor(() => expect(memoryRows().length).toBe(8));
expect(artifactRows().length).toBe(0);
@@ -312,7 +350,7 @@ describe("BrainSection type filter", () => {
render(<BrainSection />);
await waitFor(() => expect(memoryRows().length).toBe(8));
- fireEvent.click(screen.getAllByTestId("brain-filter-artifacts")[0]);
+ selectBrainView("artifacts");
fireEvent.change(screen.getByTestId("brain-search-input"), {
target: { value: "source:glob-pipe content:artifact" },
});
@@ -328,7 +366,7 @@ describe("BrainSection type filter", () => {
render(<BrainSection />);
await waitFor(() => expect(memoryRows().length).toBe(8));
- fireEvent.click(screen.getAllByTestId("brain-filter-artifacts")[0]);
+ selectBrainView("artifacts");
fireEvent.change(screen.getByTestId("brain-search-input"), {
target: { value: "yoo" },
});
@@ -346,7 +384,7 @@ describe("BrainSection type filter", () => {
render(<BrainSection />);
await waitFor(() => expect(memoryRows().length).toBe(8));
- fireEvent.click(screen.getAllByTestId("brain-filter-artifacts")[0]);
+ selectBrainView("artifacts");
await waitFor(() => {
expect(screen.getByTestId("brain-artifacts-error")).toBeTruthy();
@@ -395,7 +433,7 @@ describe("BrainSection type filter", () => {
render(<BrainSection />);
await waitFor(() => expect(memoryRows().length).toBe(8));
- fireEvent.click(screen.getAllByTestId("brain-filter-artifacts")[0]);
+ selectBrainView("artifacts");
await waitFor(() => expect(artifactRows().length).toBe(5));
fireEvent.click(screen.getByTestId("brain-item-artifact-100"));
@@ -422,7 +460,7 @@ describe("BrainSection type filter", () => {
render(<BrainSection />);
await waitFor(() => expect(memoryRows().length).toBe(8));
- fireEvent.click(screen.getAllByTestId("brain-filter-artifacts")[0]);
+ selectBrainView("artifacts");
await waitFor(() => expect(artifactRows().length).toBe(5));
fireEvent.click(screen.getByTestId("brain-item-artifact-100"));
@@ -450,7 +488,7 @@ describe("BrainSection type filter", () => {
render(<BrainSection />);
await waitFor(() => expect(memoryRows().length).toBe(8));
- fireEvent.click(screen.getAllByTestId("brain-filter-artifacts")[0]);
+ selectBrainView("artifacts");
await waitFor(() => expect(artifactRows().length).toBe(5));
fireEvent.click(screen.getByTestId("brain-item-artifact-100"));
@@ -467,7 +505,7 @@ describe("BrainSection type filter", () => {
render(<BrainSection />);
await waitFor(() => expect(memoryRows().length).toBe(8));
- fireEvent.click(screen.getAllByTestId("brain-filter-artifacts")[0]);
+ selectBrainView("artifacts");
await waitFor(() => expect(artifactRows().length).toBe(5));
const variants = () => artifactRows().map((row) => row.dataset.variant);
@@ -491,7 +529,7 @@ describe("BrainSection type filter", () => {
render(<BrainSection />);
await waitFor(() => expect(memoryRows().length).toBe(8));
- fireEvent.click(screen.getAllByTestId("brain-filter-artifacts")[0]);
+ selectBrainView("artifacts");
await waitFor(() => expect(artifactRows().length).toBe(5));
fireEvent.click(screen.getByTestId("brain-item-artifact-100"));
@@ -517,7 +555,7 @@ describe("BrainSection type filter", () => {
render(<BrainSection />);
await waitFor(() => expect(memoryRows().length).toBe(8));
- fireEvent.click(screen.getAllByTestId("brain-filter-artifacts")[0]);
+ selectBrainView("artifacts");
await waitFor(() => expect(artifactRows().length).toBe(5));
const first = artifactTitleAt(0);
@@ -555,7 +593,7 @@ describe("BrainSection type filter", () => {
render(<BrainSection />);
await waitFor(() => expect(memoryRows().length).toBe(8));
- fireEvent.click(screen.getAllByTestId("brain-filter-artifacts")[0]);
+ selectBrainView("artifacts");
await waitFor(() => expect(artifactRows().length).toBe(5));
const first = artifactTitleAt(0);
@@ -573,7 +611,7 @@ describe("BrainSection type filter", () => {
const firstRender = render(<BrainSection />);
await waitFor(() => expect(memoryRows().length).toBe(8));
- fireEvent.click(screen.getAllByTestId("brain-filter-artifacts")[0]);
+ selectBrainView("artifacts");
await waitFor(() => expect(artifactRows().length).toBe(5));
expect(memoryRows().length).toBe(0);
diff --git a/apps/screenpipe-app-tauri/components/settings/brain-section.tsx b/apps/screenpipe-app-tauri/components/settings/brain-section.tsx
index 33792c79e..b4f0a1a51 100644
--- a/apps/screenpipe-app-tauri/components/settings/brain-section.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/brain-section.tsx
@@ -1404,6 +1404,30 @@ export function BrainSection() {
? Math.floor((Date.now() - new Date(newestCreatedAt).getTime()) / 86400000)
: 0;
const isStale = staleDays >= 1;
+ const brainViewOptions = [
+ {
+ value: "overview" as const,
+ label: "Live Views",
+ count: liveViewsTabCount,
+ Icon: LayoutDashboard,
+ },
+ {
+ value: "memories" as const,
+ label: "Memories",
+ count: memoriesTabCount,
+ Icon: Eye,
+ },
+ {
+ value: "artifacts" as const,
+ label: "Artifacts",
+ count: artifactsTabCount,
+ Icon: FolderOpen,
+ },
+ ];
+ const activeBrainView =
+ brainViewOptions.find(({ value }) => value === typeFilter) ??
+ brainViewOptions[0];
+ const ActiveBrainViewIcon = activeBrainView.Icon;
return (
<div data-testid="section-brain" className="h-full overflow-hidden">
@@ -1442,93 +1466,48 @@ export function BrainSection() {
)}
<div className="flex items-center justify-between gap-3">
- {typeFilter === "overview" ? (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <button
- type="button"
- data-testid="brain-filter-overview"
- className="inline-flex h-8 items-center gap-2 border border-border bg-background px-2.5 text-xs font-medium transition-colors hover:bg-foreground hover:text-background"
- aria-label="switch Brain view"
- >
- <LayoutDashboard className="h-3.5 w-3.5" />
- <span>Live Views</span>
- {liveViewsTabCount !== null && (
- <span className="font-mono text-[10px] tabular-nums text-muted-foreground">
- {liveViewsTabCount.toLocaleString()}
- </span>
- )}
- <ChevronDown className="h-3 w-3" />
- </button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="start" className="w-56 rounded-none">
- <DropdownMenuItem
- className="bg-muted/50"
- onSelect={() => switchTypeFilter("overview")}
- >
- <LayoutDashboard className="mr-2 h-3.5 w-3.5" />
- <span className="flex-1">Live Views</span>
- {liveViewsTabCount !== null && (
- <span className="font-mono text-[10px] tabular-nums text-muted-foreground">
- {liveViewsTabCount.toLocaleString()}
- </span>
- )}
- </DropdownMenuItem>
- <DropdownMenuItem
- data-testid="brain-filter-memories"
- onSelect={() => switchTypeFilter("memories")}
- >
- <Eye className="mr-2 h-3.5 w-3.5" />
- <span className="flex-1">Memories</span>
- {memoriesTabCount !== null && (
- <span className="font-mono text-[10px] tabular-nums text-muted-foreground">
- {memoriesTabCount.toLocaleString()}
- </span>
- )}
- </DropdownMenuItem>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <button
+ type="button"
+ data-testid="brain-view-switcher"
+ className="inline-flex h-8 items-center gap-2 border border-border bg-background px-2.5 text-xs font-medium transition-colors hover:bg-foreground hover:text-background"
+ aria-label={`switch Brain view, current: ${activeBrainView.label}`}
+ >
+ <ActiveBrainViewIcon className="h-3.5 w-3.5" />
+ <span>{activeBrainView.label}</span>
+ {activeBrainView.count !== null && (
+ <span className="font-mono text-[10px] tabular-nums text-muted-foreground">
+ {activeBrainView.count.toLocaleString()}
+ </span>
+ )}
+ <ChevronDown className="h-3 w-3" />
+ </button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent
+ align="start"
+ className="w-56 rounded-none"
+ data-testid="brain-view-menu"
+ >
+ {brainViewOptions.map(({ value, label, count, Icon }) => (
<DropdownMenuItem
- data-testid="brain-filter-artifacts"
- onSelect={() => switchTypeFilter("artifacts")}
- >
- <FolderOpen className="mr-2 h-3.5 w-3.5" />
- <span className="flex-1">Artifacts</span>
- {artifactsTabCount !== null && (
- <span className="font-mono text-[10px] tabular-nums text-muted-foreground">
- {artifactsTabCount.toLocaleString()}
- </span>
- )}
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- ) : (
- <div className="inline-flex items-center gap-1 border-b border-border">
- {(
- [
- { value: "overview", label: "Live Views", count: liveViewsTabCount ?? undefined },
- { value: "memories", label: "Memories", count: memoriesTabCount ?? undefined },
- { value: "artifacts", label: "Artifacts", count: artifactsTabCount ?? undefined },
- ] as { value: TypeFilter; label: string; count?: number }[]
- ).map(({ value, label, count }) => (
- <button
key={value}
data-testid={`brain-filter-${value}`}
- onClick={() => switchTypeFilter(value)}
- className={`border-b-2 px-3 py-2 text-sm font-medium transition-colors ${
- typeFilter === value
- ? "border-foreground text-foreground"
- : "border-transparent text-muted-foreground hover:text-foreground"
- }`}
+ className={typeFilter === value ? "bg-muted/50" : undefined}
+ aria-current={typeFilter === value ? "page" : undefined}
+ onSelect={() => switchTypeFilter(value)}
>
- {label}
- {count !== undefined && (
- <span className="ml-2 text-xs text-muted-foreground">
+ <Icon className="mr-2 h-3.5 w-3.5" />
+ <span className="flex-1">{label}</span>
+ {count !== null && (
+ <span className="font-mono text-[10px] tabular-nums text-muted-foreground">
{count.toLocaleString()}
</span>
)}
- </button>
+ </DropdownMenuItem>
))}
- </div>
- )}
+ </DropdownMenuContent>
+ </DropdownMenu>
{showFilterButton && (
<Popover
open={filterOpen}
diff --git a/apps/screenpipe-app-tauri/components/settings/live-view-ai-composer.tsx b/apps/screenpipe-app-tauri/components/settings/live-view-ai-composer.tsx
index c789378d1..e2f62d5bd 100644
--- a/apps/screenpipe-app-tauri/components/settings/live-view-ai-composer.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/live-view-ai-composer.tsx
@@ -9,6 +9,8 @@ import { AIPresetsSelector } from "@/components/rewind/ai-presets-selector";
import { Button } from "@/components/ui/button";
import { Textarea } from "@/components/ui/textarea";
import { useSettings } from "@/lib/hooks/use-settings";
+import { useUsageStatus } from "@/lib/hooks/use-usage-status";
+import { openBusinessUpgradeSurface } from "@/lib/upgrade-flow";
import type { AIPreset } from "@/lib/utils/tauri";
import type { LiveViewGenerationScope } from "@/lib/live-views/generate-live-view-with-pi";
@@ -69,6 +71,7 @@ export function LiveViewAiComposer({
onGenerate,
}: LiveViewAiComposerProps) {
const { settings } = useSettings();
+ const usage = useUsageStatus();
const presets = useMemo(
() => (settings.aiPresets ?? []) as AIPreset[],
[settings.aiPresets],
@@ -90,9 +93,24 @@ export function LiveViewAiComposer({
const selectedPreset = presets.find(
(preset) => preset.id === selectedPresetId,
);
- const canSubmit = Boolean(prompt.trim() && selectedPreset && !busy);
+ const hostedUsageExhausted = Boolean(
+ selectedPreset?.provider === "screenpipe-cloud" &&
+ usage &&
+ usage.remaining <= 0,
+ );
+ const canUpgrade = Boolean(
+ hostedUsageExhausted &&
+ usage?.upgrade_eligible === true &&
+ usage.upsell_banner !== false &&
+ usage.tier !== "subscribed" &&
+ usage.tier !== "business_max" &&
+ usage.tier !== "business_ultra",
+ );
+ const canSubmit = Boolean(
+ prompt.trim() && selectedPreset && !busy && !hostedUsageExhausted,
+ );
const compactExpanded =
- compact && (compactFocused || Boolean(prompt.trim()) || busy);
+ compact && !hostedUsageExhausted && (compactFocused || busy);
const intent = inferLiveViewGenerationIntent(
prompt,
Boolean(currentViewTitle),
@@ -122,7 +140,15 @@ export function LiveViewAiComposer({
<div
data-testid="live-view-ai-composer"
onFocusCapture={() => {
- if (compact) setCompactFocused(true);
+ if (compact && !hostedUsageExhausted) setCompactFocused(true);
+ }}
+ onBlurCapture={(event) => {
+ if (
+ compact &&
+ !event.currentTarget.contains(event.relatedTarget as Node | null)
+ ) {
+ setCompactFocused(false);
+ }
}}
className={
compact
@@ -143,7 +169,7 @@ export function LiveViewAiComposer({
data-testid="live-view-ai-prompt"
autoFocus={autoFocus}
value={prompt}
- disabled={busy}
+ disabled={busy || hostedUsageExhausted}
rows={compactExpanded ? 2 : compact ? 1 : 3}
maxLength={1_500}
className={
@@ -154,11 +180,16 @@ export function LiveViewAiComposer({
: "min-h-16 resize-none rounded-none border-0 px-4 py-3 text-sm shadow-none focus-visible:ring-0"
}
placeholder={
- compact
- ? "Ask AI to change this Live View..."
- : "For example: show how I spend my time and what changed this week"
+ hostedUsageExhausted
+ ? "Hosted AI limit reached"
+ : compact
+ ? "Ask AI to change this Live View..."
+ : "For example: show how I spend my time and what changed this week"
}
- onChange={(event) => setPrompt(event.target.value)}
+ onChange={(event) => {
+ setPrompt(event.target.value);
+ if (compact) setCompactFocused(true);
+ }}
onKeyDown={(event) => {
if (event.key === "Enter" && !event.shiftKey) {
event.preventDefault();
@@ -166,25 +197,38 @@ export function LiveViewAiComposer({
}
}}
/>
- {compact && (
- <Button
- data-testid="live-view-ai-generate"
- type="button"
- size="icon"
- className="h-10 w-10 shrink-0 rounded-none"
- aria-label={actionLabel}
- title={actionLabel}
- disabled={!canSubmit}
- onClick={submit}
- >
- {busy ? (
- <Loader2 className="h-3.5 w-3.5 animate-spin" />
- ) : (
- <ArrowUp className="h-3.5 w-3.5" />
- )}
- <span className="sr-only">{actionLabel}</span>
- </Button>
- )}
+ {compact &&
+ (canUpgrade ? (
+ <Button
+ data-testid="live-view-ai-upgrade"
+ type="button"
+ size="sm"
+ className="h-10 shrink-0 rounded-none px-3 text-xs"
+ onClick={() =>
+ void openBusinessUpgradeSurface("live-view-ai-composer")
+ }
+ >
+ upgrade
+ </Button>
+ ) : (
+ <Button
+ data-testid="live-view-ai-generate"
+ type="button"
+ size="icon"
+ className="h-10 w-10 shrink-0 rounded-none"
+ aria-label={actionLabel}
+ title={actionLabel}
+ disabled={!canSubmit}
+ onClick={submit}
+ >
+ {busy ? (
+ <Loader2 className="h-3.5 w-3.5 animate-spin" />
+ ) : (
+ <ArrowUp className="h-3.5 w-3.5" />
+ )}
+ <span className="sr-only">{actionLabel}</span>
+ </Button>
+ ))}
</div>
{compact ? (
compactExpanded && (
@@ -232,28 +276,42 @@ export function LiveViewAiComposer({
</span>
)}
</div>
- <Button
- data-testid="live-view-ai-generate"
- type="button"
- size="sm"
- className="h-8 rounded-none"
- disabled={!canSubmit}
- onClick={submit}
- >
- {busy ? (
- <>
- <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
- <span>creating</span>
- </>
- ) : (
- <>
- <span className="mr-1.5">
- {intent === "pipe-agent" ? "open agent" : "generate"}
- </span>
- <ArrowUp className="h-3.5 w-3.5" />
- </>
- )}
- </Button>
+ {canUpgrade ? (
+ <Button
+ data-testid="live-view-ai-upgrade"
+ type="button"
+ size="sm"
+ className="h-8 rounded-none"
+ onClick={() =>
+ void openBusinessUpgradeSurface("live-view-ai-composer")
+ }
+ >
+ upgrade
+ </Button>
+ ) : (
+ <Button
+ data-testid="live-view-ai-generate"
+ type="button"
+ size="sm"
+ className="h-8 rounded-none"
+ disabled={!canSubmit}
+ onClick={submit}
+ >
+ {busy ? (
+ <>
+ <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
+ <span>creating</span>
+ </>
+ ) : (
+ <>
+ <span className="mr-1.5">
+ {intent === "pipe-agent" ? "open agent" : "generate"}
+ </span>
+ <ArrowUp className="h-3.5 w-3.5" />
+ </>
+ )}
+ </Button>
+ )}
</div>
)}
{busy && (
@@ -296,7 +354,7 @@ export function LiveViewAiComposer({
<button
key={suggestion}
type="button"
- disabled={busy}
+ disabled={busy || hostedUsageExhausted}
className="border border-border px-2 py-1 text-[11px] text-muted-foreground hover:border-foreground hover:text-foreground disabled:opacity-50"
onClick={() => setPrompt(suggestion)}
>
diff --git a/apps/screenpipe-app-tauri/e2e/specs/brain-section.spec.ts b/apps/screenpipe-app-tauri/e2e/specs/brain-section.spec.ts
index a21797785..d8b8741ba 100644
--- a/apps/screenpipe-app-tauri/e2e/specs/brain-section.spec.ts
+++ b/apps/screenpipe-app-tauri/e2e/specs/brain-section.spec.ts
@@ -7,7 +7,7 @@
*
* Covers:
* - Section loads with seeded items
- * - Memories / Artifacts tab switching
+ * - Memories / Artifacts view switching
* - Search filtering
* - Individual artifact delete with toast
* - Individual memory delete with toast
@@ -130,6 +130,14 @@ async function reloadBrainSection() {
await waitForTestId("section-brain", 10_000);
}
+async function selectBrainView(view: "overview" | "memories" | "artifacts") {
+ const switcher = await $('[data-testid="brain-view-switcher"]');
+ await switcher.click();
+ const option = await $(`[data-testid="brain-filter-${view}"]`);
+ await option.waitForDisplayed({ timeout: t(5_000) });
+ await option.click();
+}
+
// KNOWN-BROKEN (quarantined): the #4436 Brain redesign broke this spec —
// seeded memories/artifacts don't render under the new fetch/merge UI, so
// every test here times out ("Seeded memory not visible"). Skipped to unblock
@@ -300,9 +308,10 @@ describe.skip("Brain section", function () {
await saveScreenshot("brain-section-loaded");
});
- it("switches between memories and artifacts tabs", async () => {
- // Memories is the default tab.
- const memFilter = await $('[data-testid="brain-filter-memories"]');
+ it("switches between memories and artifacts with one dropdown", async () => {
+ // Memories is the default view.
+ const switcher = await $('[data-testid="brain-view-switcher"]');
+ expect(await switcher.getText()).toContain("Memories");
// Seeded memory should be visible
const memItem = await $(
@@ -317,9 +326,9 @@ describe.skip("Brain section", function () {
expect(await artItem.isExisting()).toBe(false);
// Switch to artifacts.
- const artFilter = await $('[data-testid="brain-filter-artifacts"]');
- await artFilter.click();
+ await selectBrainView("artifacts");
await browser.pause(500);
+ expect(await switcher.getText()).toContain("Artifacts");
// Now artifact should be visible, memory should not
const artItem2 = await $(
@@ -332,8 +341,9 @@ describe.skip("Brain section", function () {
expect(await memItem2.isExisting()).toBe(false);
// Switch back to memories.
- await memFilter.click();
+ await selectBrainView("memories");
await browser.pause(500);
+ expect(await switcher.getText()).toContain("Memories");
});
it("search filters items", async () => {
@@ -354,8 +364,7 @@ describe.skip("Brain section", function () {
});
it("artifact search finds content beyond the preview", async () => {
- const artFilter = await $('[data-testid="brain-filter-artifacts"]');
- await artFilter.click();
+ await selectBrainView("artifacts");
await browser.pause(500);
const searchInput = await $('[data-testid="brain-search-input"]');
@@ -738,8 +747,7 @@ describe.skip("Brain section", function () {
it("artifact markdown preview opens full content in the viewer window", async () => {
// Filter to artifacts so the seeded artifact is visible
- const artFilter = await $('[data-testid="brain-filter-artifacts"]');
- await artFilter.click();
+ await selectBrainView("artifacts");
await browser.pause(500);
// Wait for seeded artifact
diff --git a/docs/assets/pr/brain-view-switcher/consistent-dropdown.jpg b/docs/assets/pr/brain-view-switcher/consistent-dropdown.jpg
new file mode 100644
index 000000000..05407240a
Binary files /dev/null and b/docs/assets/pr/brain-view-switcher/consistent-dropdown.jpg differ