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

feat: add time-aware advanced Live Views

Louis Beaumontff033afb6da2
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 84207eb18..b80b6e9ec 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
@@ -87,6 +87,7 @@ const populatedView: ViewDefinition = {
id: "my-overview",
title: "How I worked today",
revision: 3,
+ timeRange: "today",
createdAt: "2026-07-23T16:00:00Z",
updatedAt: "2026-07-23T17:00:00Z",
slots: [
@@ -123,6 +124,7 @@ const workdayTemplate = {
title: "Workday overview",
description: "Time, accomplishments, key moments, and unfinished work.",
version: 1,
+ timeRange: "today" as const,
pipes: [
{ name: "time-breakdown", distribution: "bundled" },
{ name: "day-recap", distribution: "bundled" },
@@ -194,6 +196,109 @@ describe("BrainOverview", () => {
expect(screen.queryByText("loading data")).toBeNull();
});
+ it("persists a time window and sends its exact bounds to connected Pipes", async () => {
+ mocks.listBrainViews.mockResolvedValue({
+ status: "ok",
+ data: [populatedView],
+ });
+ mocks.saveBrainView.mockImplementation(async (request) => ({
+ status: "ok",
+ data: {
+ ...populatedView,
+ ...request,
+ revision: 4,
+ slots: populatedView.slots,
+ },
+ }));
+ render(<BrainOverview />);
+
+ fireEvent.change(await screen.findByTestId("overview-time-range"), {
+ target: { value: "7d" },
+ });
+
+ await waitFor(() =>
+ expect(mocks.saveBrainView).toHaveBeenCalledWith(
+ expect.objectContaining({
+ id: "my-overview",
+ expectedRevision: 3,
+ timeRange: "7d",
+ }),
+ ),
+ );
+ await waitFor(() => expect(mocks.localFetch).toHaveBeenCalled());
+ const runCall = mocks.localFetch.mock.calls.find(([path]) =>
+ String(path).endsWith("/run"),
+ );
+ const payload = JSON.parse(String(runCall?.[1]?.body));
+ expect(payload.notification_context.time_range).toEqual(
+ expect.objectContaining({
+ preset: "7d",
+ label: "Last 7 days",
+ timezone: expect.any(String),
+ start: expect.any(String),
+ end: expect.any(String),
+ }),
+ );
+ });
+
+ it("renders time-series and dense data inside reliable card scroll regions", async () => {
+ const advancedView: ViewDefinition = {
+ ...populatedView,
+ timeRange: "7d",
+ slots: [
+ {
+ ...populatedView.slots[0],
+ id: "focus-trend",
+ title: "Focus trend",
+ component: "line-chart.v1",
+ value: {
+ ...populatedView.slots[0].value!,
+ payload: {
+ items: [
+ { timestamp: "Mon", value: 2 },
+ { timestamp: "Tue", value: 5 },
+ { timestamp: "Wed", value: 3 },
+ ],
+ },
+ },
+ },
+ {
+ ...populatedView.slots[0],
+ id: "project-table",
+ title: "Project detail",
+ component: "table.v1",
+ order: 1,
+ value: {
+ ...populatedView.slots[0].value!,
+ payload: {
+ items: Array.from({ length: 30 }, (_, index) => ({
+ label: `Project ${index + 1}`,
+ value: `${index + 1} hours`,
+ detail: "Source-backed detail",
+ })),
+ },
+ },
+ },
+ ],
+ };
+ mocks.listBrainViews.mockResolvedValue({
+ status: "ok",
+ data: [advancedView],
+ });
+ render(<BrainOverview />);
+
+ expect(
+ await screen.findByRole("img", { name: "Focus trend time series" }),
+ ).toBeTruthy();
+ expect(screen.getByText("Line chart · Last 7 days")).toBeTruthy();
+ expect(screen.getByText("Project 30")).toBeTruthy();
+ expect(
+ screen
+ .getByTestId("overview-card-scroll-project-table")
+ .className.includes("overflow-auto"),
+ ).toBe(true);
+ });
+
it("does not render raw HTML from a markdown card", async () => {
const markdownView: ViewDefinition = {
...populatedView,
@@ -357,6 +462,7 @@ describe("BrainOverview", () => {
mocks.listBrainViews.mockResolvedValue({ status: "ok", data: [] });
mocks.generateLiveViewWithPi.mockResolvedValue({
title: "My working week",
+ timeRange: "7d",
note: "A time overview with automation opportunities.",
blocks: [
{
@@ -435,6 +541,7 @@ describe("BrainOverview", () => {
});
mocks.generateLiveViewWithPi.mockResolvedValue({
title: "Automation opportunities",
+ timeRange: "today",
note: "Added one action list.",
blocks: [
{
@@ -482,6 +589,7 @@ describe("BrainOverview", () => {
});
mocks.generateLiveViewWithPi.mockResolvedValue({
title: "A different dashboard",
+ timeRange: "7d",
note: "Rebuilt around projects.",
blocks: [
{
@@ -653,6 +761,7 @@ describe("BrainOverview", () => {
});
mocks.generateLiveViewWithPi.mockResolvedValue({
title: "Time by project",
+ timeRange: "today",
note: "Changed the breakdown.",
blocks: [
{
diff --git a/apps/screenpipe-app-tauri/components/settings/brain-overview.tsx b/apps/screenpipe-app-tauri/components/settings/brain-overview.tsx
index 9b65f9b80..6c00599de 100644
--- a/apps/screenpipe-app-tauri/components/settings/brain-overview.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/brain-overview.tsx
@@ -39,6 +39,7 @@ import {
type BrainViewDefinition,
type BrainViewSlot,
type BrainViewTemplateKit,
+ type BrainViewTimeRange,
} from "@/lib/utils/tauri";
export type ViewComponent = BrainViewComponent;
@@ -76,10 +77,55 @@ const COMPONENTS: Array<{
label: "Bar chart",
schema: "labels and numeric values",
},
+ {
+ value: "line-chart.v1",
+ label: "Line chart",
+ schema: "numeric values changing over time",
+ },
+ {
+ value: "table.v1",
+ label: "Table",
+ schema: "scrollable rows with values and details",
+ },
{ value: "timeline.v1", label: "Timeline", schema: "timestamped events" },
{ value: "markdown.v1", label: "Text", schema: "a short formatted brief" },
];
+const TIME_RANGES: Array<{
+ value: BrainViewTimeRange;
+ label: string;
+ milliseconds: number | null;
+}> = [
+ { value: "today", label: "Today", milliseconds: null },
+ { value: "24h", label: "Last 24 hours", milliseconds: 24 * 60 * 60 * 1000 },
+ { value: "7d", label: "Last 7 days", milliseconds: 7 * 24 * 60 * 60 * 1000 },
+ {
+ value: "30d",
+ label: "Last 30 days",
+ milliseconds: 30 * 24 * 60 * 60 * 1000,
+ },
+];
+
+function timeRangeContext(timeRange: BrainViewTimeRange) {
+ const selected =
+ TIME_RANGES.find((candidate) => candidate.value === timeRange) ??
+ TIME_RANGES[0];
+ const end = new Date();
+ const start = new Date(end);
+ if (selected.milliseconds === null) {
+ start.setHours(0, 0, 0, 0);
+ } else {
+ start.setTime(end.getTime() - selected.milliseconds);
+ }
+ return {
+ preset: selected.value,
+ label: selected.label,
+ start: start.toISOString(),
+ end: end.toISOString(),
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC",
+ };
+}
+
function DataRefreshBanner({ state }: { state: DataRefreshState }) {
const active = state.status === "starting" || state.status === "running";
const message =
@@ -292,12 +338,13 @@ export function BrainOverview() {
notification_context: {
source: "live-view",
live_view_id: targetView.id,
+ time_range: timeRangeContext(targetView.timeRange),
target_ids: boundSlots
.filter((slot) => slot.binding?.pipeName === pipeName)
.map((slot) => `live-view:${targetView.id}:${slot.id}`),
instruction: requestedSlots
- ? "Refresh only the listed structured output targets. Call structured_output get_targets first, query only source-backed Screenpipe APIs, and submit an evidence-backed value for each listed target before completing."
- : "Refresh every structured output target assigned to this pipe. Call structured_output get_targets first, query only source-backed Screenpipe APIs, and submit every valid target before completing.",
+ ? "Refresh only the listed structured output targets for the supplied time_range. Call structured_output get_targets first, query only source-backed Screenpipe APIs inside that exact time window, and submit an evidence-backed value for each listed target before completing."
+ : "Refresh every structured output target assigned to this pipe for the supplied time_range. Call structured_output get_targets first, query only source-backed Screenpipe APIs inside that exact time window, and submit every valid target before completing.",
},
}),
},
@@ -405,6 +452,7 @@ export function BrainOverview() {
id: "my-overview",
title: "My Live View",
revision: 0,
+ timeRange: "today",
slots: [],
createdAt: now,
updatedAt: now,
@@ -430,6 +478,7 @@ export function BrainOverview() {
id: view?.id ?? "my-overview",
title: kit.title,
revision: view?.revision ?? 0,
+ timeRange: kit.timeRange,
slots: kitSlots(kit),
createdAt: view?.createdAt ?? now,
updatedAt: now,
@@ -462,6 +511,7 @@ export function BrainOverview() {
currentView: view
? {
title: view.title,
+ timeRange: view.timeRange,
blocks: normalizedSlots(view.slots).map((slot) => ({
title: slot.title,
component: slot.component,
@@ -478,6 +528,7 @@ export function BrainOverview() {
id: "my-overview",
title: generated.title,
revision: 0,
+ timeRange: generated.timeRange,
slots: [],
createdAt: now,
updatedAt: now,
@@ -492,6 +543,8 @@ export function BrainOverview() {
setDraft({
...base,
title: scope === "dashboard" || !view ? generated.title : base.title,
+ timeRange:
+ scope === "dashboard" || !view ? generated.timeRange : base.timeRange,
slots,
updatedAt: now,
});
@@ -629,6 +682,7 @@ export function BrainOverview() {
})),
currentView: {
title: view.title,
+ timeRange: view.timeRange,
blocks: [
{
title: slot.title,
@@ -644,6 +698,7 @@ export function BrainOverview() {
id: view.id,
title: view.title,
expectedRevision: view.revision,
+ timeRange: view.timeRange,
slots: normalizedSlots(view.slots).map((current) =>
current.id === slot.id
? {
@@ -700,6 +755,7 @@ export function BrainOverview() {
id: draft.id,
title: draft.title.trim(),
expectedRevision: draft.revision > 0 ? draft.revision : null,
+ timeRange: draft.timeRange,
slots: normalizedSlots(draft.slots).map((slot) => ({
id: slot.id,
title: slot.title.trim(),
@@ -775,6 +831,7 @@ export function BrainOverview() {
id: view.id,
title: undoView.title,
expectedRevision: undoRevision ?? view.revision,
+ timeRange: undoView.timeRange,
slots: normalizedSlots(undoView.slots).map((slot) => ({
id: slot.id,
title: slot.title,
@@ -805,6 +862,46 @@ export function BrainOverview() {
}
};
+ const changeTimeRange = async (timeRange: BrainViewTimeRange) => {
+ if (!view || timeRange === view.timeRange) return;
+ const previousView = copyViewDefinition(view);
+ setSaving(true);
+ try {
+ const result = await commands.saveBrainView({
+ id: view.id,
+ title: view.title,
+ expectedRevision: view.revision,
+ timeRange,
+ slots: normalizedSlots(view.slots).map((slot) => ({
+ id: slot.id,
+ title: slot.title,
+ component: slot.component,
+ width: slot.width,
+ order: slot.order,
+ binding: slot.binding,
+ })),
+ });
+ if (result.status === "error") throw new Error(result.error);
+ setView(result.data);
+ setUndoView(previousView);
+ setUndoRevision(result.data.revision);
+ toast({
+ title: `showing ${timeRangeContext(timeRange).label.toLowerCase()}`,
+ });
+ void refreshConnectedPipes(result.data);
+ } catch (rangeError) {
+ toast({
+ title: "could not change the time range",
+ description:
+ rangeError instanceof Error ? rangeError.message : String(rangeError),
+ variant: "destructive",
+ });
+ void load(true);
+ } finally {
+ setSaving(false);
+ }
+ };
+
const updateSlot = (id: string, update: (slot: ViewSlot) => ViewSlot) => {
setDraft((current) =>
current
@@ -1031,7 +1128,12 @@ export function BrainOverview() {
)}
<div className="grid grid-cols-12 gap-4">
{previewSlots.map((slot) => (
- <OverviewCard key={slot.id} slot={slot} preview />
+ <OverviewCard
+ key={slot.id}
+ slot={slot}
+ timeRange={draft.timeRange}
+ preview
+ />
))}
</div>
</div>
@@ -1045,20 +1147,44 @@ export function BrainOverview() {
className="min-h-0 flex-1 space-y-5 overflow-y-auto pb-8 pr-4 [scrollbar-gutter:stable]"
>
<div className="flex items-end justify-between gap-4 border-b border-border pb-4">
- <label className="min-w-0 flex-1 space-y-1.5">
- <span className="text-[10px] uppercase tracking-wide text-muted-foreground">
- Live View name
- </span>
- <Input
- data-testid="overview-title"
- value={draft.title}
- onChange={(event) =>
- setDraft({ ...draft, title: event.target.value })
- }
- className="h-9 max-w-md rounded-none"
- maxLength={120}
- />
- </label>
+ <div className="flex min-w-0 flex-1 flex-wrap items-end gap-3">
+ <label className="min-w-64 flex-1 space-y-1.5">
+ <span className="text-[10px] uppercase tracking-wide text-muted-foreground">
+ Live View name
+ </span>
+ <Input
+ data-testid="overview-title"
+ value={draft.title}
+ onChange={(event) =>
+ setDraft({ ...draft, title: event.target.value })
+ }
+ className="h-9 max-w-md rounded-none"
+ maxLength={120}
+ />
+ </label>
+ <label className="space-y-1.5">
+ <span className="block text-[10px] uppercase tracking-wide text-muted-foreground">
+ Time window
+ </span>
+ <select
+ aria-label="template time range"
+ value={draft.timeRange}
+ className="h-9 border border-border bg-background px-2 text-xs outline-none focus:border-foreground"
+ onChange={(event) =>
+ setDraft({
+ ...draft,
+ timeRange: event.target.value as BrainViewTimeRange,
+ })
+ }
+ >
+ {TIME_RANGES.map((range) => (
+ <option key={range.value} value={range.value}>
+ {range.label}
+ </option>
+ ))}
+ </select>
+ </label>
+ </div>
<div className="flex gap-2">
<Button
variant="ghost"
@@ -1258,11 +1384,27 @@ export function BrainOverview() {
</p>
<h2 className="text-lg font-semibold tracking-tight">{view.title}</h2>
<p className="mt-1 text-xs text-muted-foreground">
- Blocks are updated by connected Pipes and stored as source-backed
- artifacts.
+ Blocks are updated by connected Pipes for the selected time window
+ and stored as source-backed artifacts.
</p>
</div>
<div className="flex flex-wrap justify-end gap-2">
+ <select
+ data-testid="overview-time-range"
+ aria-label="Live View time range"
+ value={view.timeRange}
+ disabled={saving || refreshIsActive}
+ className="h-8 border border-border bg-background px-2 text-xs outline-none focus:border-foreground disabled:opacity-50"
+ onChange={(event) =>
+ void changeTimeRange(event.target.value as BrainViewTimeRange)
+ }
+ >
+ {TIME_RANGES.map((range) => (
+ <option key={range.value} value={range.value}>
+ {range.label}
+ </option>
+ ))}
+ </select>
{templateKits.length > 0 && (
<Button
data-testid="overview-templates"
@@ -1363,6 +1505,7 @@ export function BrainOverview() {
<OverviewCard
key={slot.id}
slot={slot}
+ timeRange={view.timeRange}
refreshing={
refreshIsActive &&
Boolean(dataRefresh?.slotIds.includes(slot.id))
diff --git a/apps/screenpipe-app-tauri/components/settings/live-view-card.tsx b/apps/screenpipe-app-tauri/components/settings/live-view-card.tsx
index c7a3d3a5c..690f51c56 100644
--- a/apps/screenpipe-app-tauri/components/settings/live-view-card.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/live-view-card.tsx
@@ -23,6 +23,7 @@ import {
import type {
BrainViewComponent,
BrainViewSlot,
+ BrainViewTimeRange,
JsonValue,
} from "@/lib/utils/tauri";
@@ -30,10 +31,19 @@ const COMPONENT_LABELS: Record<BrainViewComponent, string> = {
"metric.v1": "Metric",
"list.v1": "List",
"bar-chart.v1": "Bar chart",
+ "line-chart.v1": "Line chart",
+ "table.v1": "Table",
"timeline.v1": "Timeline",
"markdown.v1": "Text",
};
+const TIME_RANGE_LABELS: Record<BrainViewTimeRange, string> = {
+ today: "Today",
+ "24h": "Last 24 hours",
+ "7d": "Last 7 days",
+ "30d": "Last 30 days",
+};
+
function timeAgo(iso: string): string {
const elapsed = Date.now() - new Date(iso).getTime();
if (!Number.isFinite(elapsed) || elapsed < 60_000) return "just now";
@@ -176,6 +186,106 @@ function LiveViewCardBody({
);
}
+ if (slot.component === "line-chart.v1") {
+ const points = items.map((item) => ({
+ timestamp: stringValue(item.timestamp),
+ label: stringValue(item.label),
+ value: typeof item.value === "number" ? item.value : 0,
+ }));
+ const values = points.map((point) => point.value);
+ const minimum = values.length > 0 ? Math.min(...values) : 0;
+ const maximum = values.length > 0 ? Math.max(...values) : 0;
+ const spread = maximum > minimum ? maximum - minimum : 1;
+ const polyline = points
+ .map((point, index) => {
+ const x = points.length <= 1 ? 50 : (index / (points.length - 1)) * 100;
+ const y = 92 - ((point.value - minimum) / spread) * 84;
+ return `${x.toFixed(2)},${y.toFixed(2)}`;
+ })
+ .join(" ");
+ return (
+ <div className="space-y-3">
+ <div className="flex items-baseline justify-between gap-3 text-xs">
+ <span className="text-muted-foreground">
+ {points[0]?.label || points[0]?.timestamp}
+ </span>
+ <span className="tabular-nums">
+ {minimum.toLocaleString()} to {maximum.toLocaleString()}
+ </span>
+ </div>
+ <svg
+ role="img"
+ aria-label={`${slot.title} time series`}
+ viewBox="0 0 100 100"
+ preserveAspectRatio="none"
+ className="h-44 w-full overflow-visible"
+ >
+ {[8, 36, 64, 92].map((y) => (
+ <line
+ key={y}
+ x1="0"
+ x2="100"
+ y1={y}
+ y2={y}
+ className="stroke-border"
+ strokeWidth="0.5"
+ vectorEffect="non-scaling-stroke"
+ />
+ ))}
+ <polyline
+ points={polyline}
+ fill="none"
+ className="stroke-foreground"
+ strokeWidth="2"
+ strokeLinejoin="round"
+ strokeLinecap="round"
+ vectorEffect="non-scaling-stroke"
+ />
+ </svg>
+ <div className="flex justify-between gap-3 text-[10px] text-muted-foreground">
+ <span>{points[0]?.timestamp}</span>
+ <span>{points.at(-1)?.timestamp}</span>
+ </div>
+ </div>
+ );
+ }
+
+ if (slot.component === "table.v1") {
+ return (
+ <div className="min-w-[28rem]">
+ <table className="w-full border-collapse text-left text-xs">
+ <tbody>
+ {items.map((item, index) => (
+ <tr
+ key={`${stringValue(item.label)}-${index}`}
+ className="border-t border-border first:border-t-0"
+ >
+ <th className="w-1/3 py-2.5 pr-4 align-top font-medium">
+ {stringValue(item.label)}
+ </th>
+ <td className="py-2.5 align-top">
+ <p>{stringValue(item.value)}</p>
+ {typeof item.detail === "string" && (
+ <p className="mt-0.5 text-muted-foreground">
+ {item.detail}
+ </p>
+ )}
+ </td>
+ <td className="py-2.5 pl-4 text-right align-top">
+ {typeof item.status === "string" && (
+ <span className="border border-border px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground">
+ {item.status}
+ </span>
+ )}
+ </td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ </div>
+ );
+ }
+
if (slot.component === "timeline.v1") {
return (
<div className="space-y-0">
@@ -237,6 +347,7 @@ function LiveViewCardBody({
export function LiveViewCard({
slot,
+ timeRange = "today",
preview = false,
refreshing = false,
feedback = null,
@@ -247,6 +358,7 @@ export function LiveViewCard({
onAiEdit,
}: {
slot: BrainViewSlot;
+ timeRange?: BrainViewTimeRange;
preview?: boolean;
refreshing?: boolean;
feedback?: "up" | "down" | null;
@@ -303,7 +415,7 @@ export function LiveViewCard({
<div className={`min-w-0 ${hasActions ? "pr-32" : ""}`}>
<h3 className="truncate text-sm font-medium">{slot.title}</h3>
<p className="mt-0.5 text-[10px] uppercase tracking-wide text-muted-foreground">
- {COMPONENT_LABELS[slot.component]}
+ {COMPONENT_LABELS[slot.component]} · {TIME_RANGE_LABELS[timeRange]}
</p>
</div>
{slot.value && !hasActions && (
@@ -489,7 +601,14 @@ export function LiveViewCard({
</Popover>
</div>
)}
- <div className="flex-1">
+ <div
+ data-testid={`overview-card-scroll-${slot.id}`}
+ className={`min-h-0 flex-1 ${
+ slot.component === "metric.v1"
+ ? ""
+ : "max-h-[min(26rem,55vh)] overflow-auto overscroll-contain pr-2 [scrollbar-gutter:stable]"
+ }`}
+ >
<LiveViewCardBody
slot={slot}
preview={preview}
diff --git a/apps/screenpipe-app-tauri/components/settings/live-view-template-gallery.tsx b/apps/screenpipe-app-tauri/components/settings/live-view-template-gallery.tsx
index 07299c49c..36db97f6c 100644
--- a/apps/screenpipe-app-tauri/components/settings/live-view-template-gallery.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/live-view-template-gallery.tsx
@@ -7,6 +7,13 @@ import { Check, Download, LayoutTemplate } from "lucide-react";
import { Button } from "@/components/ui/button";
import type { BrainViewTemplateKit } from "@/lib/utils/tauri";
+const TIME_RANGE_LABELS = {
+ today: "Today",
+ "24h": "24 hours",
+ "7d": "7 days",
+ "30d": "30 days",
+} as const;
+
export function LiveViewTemplateGallery({
kits,
installedPipeNames,
@@ -47,7 +54,8 @@ export function LiveViewTemplateGallery({
</p>
</div>
<span className="shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground">
- {kit.slots.length} sections
+ {kit.slots.length} sections ·{" "}
+ {TIME_RANGE_LABELS[kit.timeRange]}
</span>
</div>
<div className="mt-3 flex flex-wrap gap-1.5">
diff --git a/apps/screenpipe-app-tauri/e2e/specs/brain-overview.spec.ts b/apps/screenpipe-app-tauri/e2e/specs/brain-overview.spec.ts
index 6d67e83da..71fccdb35 100644
--- a/apps/screenpipe-app-tauri/e2e/specs/brain-overview.spec.ts
+++ b/apps/screenpipe-app-tauri/e2e/specs/brain-overview.spec.ts
@@ -78,6 +78,7 @@ describe("Brain Live Views", function () {
id: "my-overview",
title: "How I worked today",
expectedRevision: null,
+ timeRange: "today",
slots: slots.map((slot) => ({
...slot,
binding: { pipeName: slot.binding.pipe_name },
diff --git a/apps/screenpipe-app-tauri/lib/live-views/__tests__/generate-live-view-with-pi.test.ts b/apps/screenpipe-app-tauri/lib/live-views/__tests__/generate-live-view-with-pi.test.ts
index 6f62e2f24..a457d3648 100644
--- a/apps/screenpipe-app-tauri/lib/live-views/__tests__/generate-live-view-with-pi.test.ts
+++ b/apps/screenpipe-app-tauri/lib/live-views/__tests__/generate-live-view-with-pi.test.ts
@@ -13,6 +13,7 @@ describe("parseGeneratedLiveView", () => {
const result = parseGeneratedLiveView(
JSON.stringify({
title: "How I worked",
+ timeRange: "7d",
note: "A useful overview.",
blocks: [
{
@@ -27,6 +28,18 @@ describe("parseGeneratedLiveView", () => {
width: "half",
pipeName: "time-tracker",
},
+ {
+ title: "Focus trend",
+ component: "line-chart",
+ width: 12,
+ pipeName: "time-tracker",
+ },
+ {
+ title: "Project detail",
+ component: "table.v1",
+ width: 12,
+ pipeName: "daily-summary",
+ },
],
}),
["daily-summary", "time-tracker"],
@@ -35,6 +48,7 @@ describe("parseGeneratedLiveView", () => {
expect(result).toEqual({
title: "How I worked",
+ timeRange: "7d",
note: "A useful overview.",
blocks: [
{
@@ -49,6 +63,18 @@ describe("parseGeneratedLiveView", () => {
width: 6,
pipeName: "time-tracker",
},
+ {
+ title: "Focus trend",
+ component: "line-chart.v1",
+ width: 12,
+ pipeName: "time-tracker",
+ },
+ {
+ title: "Project detail",
+ component: "table.v1",
+ width: 12,
+ pipeName: "daily-summary",
+ },
],
});
});
diff --git a/apps/screenpipe-app-tauri/lib/live-views/generate-live-view-with-pi.ts b/apps/screenpipe-app-tauri/lib/live-views/generate-live-view-with-pi.ts
index d27edeec7..333996288 100644
--- a/apps/screenpipe-app-tauri/lib/live-views/generate-live-view-with-pi.ts
+++ b/apps/screenpipe-app-tauri/lib/live-views/generate-live-view-with-pi.ts
@@ -7,6 +7,7 @@ import {
commands,
type AIPreset,
type BrainViewComponent,
+ type BrainViewTimeRange,
type PiProviderConfig,
} from "@/lib/utils/tauri";
import { mountAgentEventBus, registerForeground } from "@/lib/events/bus";
@@ -20,6 +21,8 @@ const COMPONENTS = new Set<BrainViewComponent>([
"metric.v1",
"list.v1",
"bar-chart.v1",
+ "line-chart.v1",
+ "table.v1",
"timeline.v1",
"markdown.v1",
]);
@@ -28,6 +31,9 @@ const COMPONENT_ALIASES: Record<string, BrainViewComponent> = {
list: "list.v1",
bar: "bar-chart.v1",
"bar-chart": "bar-chart.v1",
+ line: "line-chart.v1",
+ "line-chart": "line-chart.v1",
+ table: "table.v1",
timeline: "timeline.v1",
text: "markdown.v1",
markdown: "markdown.v1",
@@ -49,6 +55,7 @@ export type GeneratedLiveViewBlock = {
export type GeneratedLiveView = {
title: string;
+ timeRange: BrainViewTimeRange;
blocks: GeneratedLiveViewBlock[];
note: string;
};
@@ -61,6 +68,7 @@ type GenerateLiveViewOptions = {
pipes: LiveViewPipeSummary[];
currentView?: {
title: string;
+ timeRange: BrainViewTimeRange;
blocks: GeneratedLiveViewBlock[];
} | null;
};
@@ -102,6 +110,21 @@ function widthValue(value: unknown): 3 | 6 | 12 {
return 6;
}
+function timeRangeValue(value: unknown): BrainViewTimeRange {
+ if (typeof value !== "string") return "today";
+ const normalized = value.trim().toLowerCase();
+ if (["24h", "24 hours", "last 24 hours"].includes(normalized)) return "24h";
+ if (["7d", "7 days", "last 7 days", "week", "weekly"].includes(normalized)) {
+ return "7d";
+ }
+ if (
+ ["30d", "30 days", "last 30 days", "month", "monthly"].includes(normalized)
+ ) {
+ return "30d";
+ }
+ return "today";
+}
+
export function parseGeneratedLiveView(
raw: string,
allowedPipeNames: string[],
@@ -158,7 +181,12 @@ export function parseGeneratedLiveView(
? `Created ${blocks[0].title}.`
: `Created ${blocks.length} sections.`;
- return { title, blocks, note };
+ return {
+ title,
+ timeRange: timeRangeValue(parsed.timeRange ?? parsed.time_range),
+ blocks,
+ note,
+ };
}
function generationSystemPrompt(): string {
@@ -170,16 +198,19 @@ Allowed components:
- metric.v1: one important number
- list.v1: ranked or actionable items
- bar-chart.v1: categorical numeric comparison
+- line-chart.v1: one numeric measure changing across timestamps
+- table.v1: dense rows with label, value, optional detail, and optional status
- timeline.v1: events in time order
- markdown.v1: a short narrative brief
Allowed widths are 3, 6, or 12. Prefer 6 for most sections, 12 for timelines or detailed briefs, and 3 only for compact metrics.
Only use a pipeName from the installed pipes supplied by the user. Use null when none fits. Do not invent pipes.
For a whole dashboard, create 4 to 7 distinct sections. Prefer a useful mix with at least one metric, one bar chart, and one list or timeline when the request supports them. Never return placeholder titles such as "test", duplicate sections, or multiple metrics that show the same number.
+Choose one timeRange for the whole dashboard: "today", "24h", "7d", or "30d". Infer it from the request. Use "today" when the request does not specify a period. Prefer line-chart.v1 over bar-chart.v1 when the user asks how something changed over time.
For one section, return exactly one focused section.
Required JSON shape:
-{"title":"View title","blocks":[{"title":"Section title","component":"metric.v1","width":6,"pipeName":"exact-installed-pipe-name-or-null"}],"note":"One short sentence explaining what you created"}`;
+{"title":"View title","timeRange":"today","blocks":[{"title":"Section title","component":"metric.v1","width":6,"pipeName":"exact-installed-pipe-name-or-null"}],"note":"One short sentence explaining what you created"}`;
}
function generationPrompt(options: GenerateLiveViewOptions): string {
diff --git a/apps/screenpipe-app-tauri/lib/utils/tauri.ts b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
index ebdc31698..c273f5edb 100644
--- a/apps/screenpipe-app-tauri/lib/utils/tauri.ts
+++ b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
@@ -2609,16 +2609,17 @@ error: string | null;
*/
sinceEpochSecs: number }
export type BrainViewBinding = { pipeName: string }
-export type BrainViewComponent = "metric.v1" | "list.v1" | "bar-chart.v1" | "timeline.v1" | "markdown.v1"
-export type BrainViewDefinition = { id: string; title: string; revision: number; slots: BrainViewSlot[]; createdAt: string; updatedAt: string }
+export type BrainViewComponent = "metric.v1" | "list.v1" | "bar-chart.v1" | "line-chart.v1" | "table.v1" | "timeline.v1" | "markdown.v1"
+export type BrainViewDefinition = { id: string; title: string; revision: number; timeRange: BrainViewTimeRange; slots: BrainViewSlot[]; createdAt: string; updatedAt: string }
export type BrainViewEvidenceRef = { eventId: number | null; frameId: number | null; transcriptionId: number | null; ts: string | null; deviceId: string | null }
export type BrainViewFeedback = { rating: BrainViewFeedbackRating; artifactOutputId: number; artifactVersion: number; correction: string | null; createdAt: string }
export type BrainViewFeedbackRating = "up" | "down"
export type BrainViewFeedbackSummary = { upCount: number; downCount: number; current: BrainViewFeedback | null }
export type BrainViewSlot = { id: string; title: string; component: BrainViewComponent; width: number; order: number; binding: BrainViewBinding | null; value: BrainViewValue | null; feedback: BrainViewFeedbackSummary }
export type BrainViewSlotInput = { id: string; title: string; component: BrainViewComponent; width: number; order: number; binding: BrainViewBinding | null }
-export type BrainViewTemplateKit = { id: string; title: string; description: string; version: number; pipes: BrainViewTemplatePipe[]; slots: BrainViewSlotInput[] }
+export type BrainViewTemplateKit = { id: string; title: string; description: string; version: number; timeRange: BrainViewTimeRange; pipes: BrainViewTemplatePipe[]; slots: BrainViewSlotInput[] }
export type BrainViewTemplatePipe = { name: string; distribution: string }
+export type BrainViewTimeRange = "today" | "24h" | "7d" | "30d"
export type BrainViewValue = { payload: JsonValue; evidence: BrainViewEvidenceRef[]; sourcePipe: string; artifactOutputId: number; artifactVersion: number; updatedAt: string }
/**
* Per-browser automation status: "granted", "denied", or "not_asked".
@@ -2874,7 +2875,7 @@ export type RemoteSyncConfig = { host: string; port: number; user: string; key_p
* Result of a sync operation.
*/
export type RemoteSyncResult = { ok: boolean; files_transferred: number; bytes_transferred: number; error: string | null }
-export type SaveBrainViewRequest = { id: string; title: string; expectedRevision: number | null; slots: BrainViewSlotInput[] }
+export type SaveBrainViewRequest = { id: string; title: string; expectedRevision: number | null; timeRange: BrainViewTimeRange; slots: BrainViewSlotInput[] }
/**
* A single schedule rule: a day-of-week + time range + what to record.
*/
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/brain_views.rs b/apps/screenpipe-app-tauri/src-tauri/src/brain_views.rs
index 90446e435..a9789eba2 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/brain_views.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/brain_views.rs
@@ -13,7 +13,7 @@ use screenpipe_core::pipes::install_bundled_pipe;
use screenpipe_engine::live_views::{
delete_live_view, list_bundled_live_view_kits, list_live_views, save_live_view, LiveView,
LiveViewBlock, LiveViewBlockKind, LiveViewKit, LiveViewSource, LiveViewTemplateBlock,
- SaveLiveViewRequest,
+ LiveViewTimeRange, SaveLiveViewRequest,
};
use screenpipe_engine::structured_outputs::{
OutputFeedbackRating, OutputFeedbackSummary, StructuredOutputValue,
@@ -28,6 +28,41 @@ pub struct BrainViewBinding {
pub pipe_name: String,
}
+#[derive(Debug, Clone, Copy, Serialize, Deserialize, specta::Type, PartialEq, Eq, Default)]
+pub enum BrainViewTimeRange {
+ #[default]
+ #[serde(rename = "today")]
+ Today,
+ #[serde(rename = "24h")]
+ Last24Hours,
+ #[serde(rename = "7d")]
+ Last7Days,
+ #[serde(rename = "30d")]
+ Last30Days,
+}
+
+impl From<BrainViewTimeRange> for LiveViewTimeRange {
+ fn from(range: BrainViewTimeRange) -> Self {
+ match range {
+ BrainViewTimeRange::Today => Self::Today,
+ BrainViewTimeRange::Last24Hours => Self::Last24Hours,
+ BrainViewTimeRange::Last7Days => Self::Last7Days,
+ BrainViewTimeRange::Last30Days => Self::Last30Days,
+ }
+ }
+}
+
+impl From<LiveViewTimeRange> for BrainViewTimeRange {
+ fn from(range: LiveViewTimeRange) -> Self {
+ match range {
+ LiveViewTimeRange::Today => Self::Today,
+ LiveViewTimeRange::Last24Hours => Self::Last24Hours,
+ LiveViewTimeRange::Last7Days => Self::Last7Days,
+ LiveViewTimeRange::Last30Days => Self::Last30Days,
+ }
+ }
+}
+
impl From<BrainViewBinding> for LiveViewSource {
fn from(binding: BrainViewBinding) -> Self {
Self::pipe(binding.pipe_name)
@@ -50,6 +85,10 @@ pub enum BrainViewComponent {
ListV1,
#[serde(rename = "bar-chart.v1")]
BarChartV1,
+ #[serde(rename = "line-chart.v1")]
+ LineChartV1,
+ #[serde(rename = "table.v1")]
+ TableV1,
#[serde(rename = "timeline.v1")]
TimelineV1,
#[serde(rename = "markdown.v1")]
@@ -62,6 +101,8 @@ impl From<BrainViewComponent> for LiveViewBlockKind {
BrainViewComponent::MetricV1 => Self::MetricV1,
BrainViewComponent::ListV1 => Self::ListV1,
BrainViewComponent::BarChartV1 => Self::BarChartV1,
+ BrainViewComponent::LineChartV1 => Self::LineChartV1,
+ BrainViewComponent::TableV1 => Self::TableV1,
BrainViewComponent::TimelineV1 => Self::TimelineV1,
BrainViewComponent::MarkdownV1 => Self::MarkdownV1,
}
@@ -74,6 +115,8 @@ impl From<LiveViewBlockKind> for BrainViewComponent {
LiveViewBlockKind::MetricV1 => Self::MetricV1,
LiveViewBlockKind::ListV1 => Self::ListV1,
LiveViewBlockKind::BarChartV1 => Self::BarChartV1,
+ LiveViewBlockKind::LineChartV1 => Self::LineChartV1,
+ LiveViewBlockKind::TableV1 => Self::TableV1,
LiveViewBlockKind::TimelineV1 => Self::TimelineV1,
LiveViewBlockKind::MarkdownV1 => Self::MarkdownV1,
}
@@ -208,6 +251,7 @@ pub struct BrainViewDefinition {
pub id: String,
pub title: String,
pub revision: u64,
+ pub time_range: BrainViewTimeRange,
pub slots: Vec<BrainViewSlot>,
pub created_at: String,
pub updated_at: String,
@@ -219,6 +263,7 @@ impl From<LiveView> for BrainViewDefinition {
id: view.id,
title: view.title,
revision: view.revision,
+ time_range: view.time_range.into(),
slots: view.blocks.into_iter().map(Into::into).collect(),
created_at: view.created_at,
updated_at: view.updated_at,
@@ -251,6 +296,7 @@ pub struct BrainViewTemplateKit {
pub title: String,
pub description: String,
pub version: u64,
+ pub time_range: BrainViewTimeRange,
pub pipes: Vec<BrainViewTemplatePipe>,
pub slots: Vec<BrainViewSlotInput>,
}
@@ -262,6 +308,7 @@ impl From<LiveViewKit> for BrainViewTemplateKit {
title: kit.title,
description: kit.description,
version: kit.version,
+ time_range: kit.template.time_range.into(),
pipes: kit
.pipes
.into_iter()
@@ -306,6 +353,7 @@ pub struct SaveBrainViewRequest {
pub id: String,
pub title: String,
pub expected_revision: Option<u64>,
+ pub time_range: BrainViewTimeRange,
pub slots: Vec<BrainViewSlotInput>,
}
@@ -323,6 +371,7 @@ impl From<SaveBrainViewRequest> for SaveLiveViewRequest {
id: request.id,
title: request.title,
expected_revision: request.expected_revision,
+ time_range: request.time_range.into(),
blocks: request.slots.into_iter().map(Into::into).collect(),
}
}
@@ -377,6 +426,7 @@ pub async fn install_brain_view_template_kit(
id: request.target_view_id,
title: kit.template.title,
expected_revision: request.expected_revision,
+ time_range: kit.template.time_range,
blocks: kit.template.blocks,
},
)
diff --git a/crates/screenpipe-engine/schemas/examples/live-view-template.v1.json b/crates/screenpipe-engine/schemas/examples/live-view-template.v1.json
index b7f90e8b2..6904bbf2d 100644
--- a/crates/screenpipe-engine/schemas/examples/live-view-template.v1.json
+++ b/crates/screenpipe-engine/schemas/examples/live-view-template.v1.json
@@ -3,6 +3,7 @@
"id": "daily-work",
"title": "Daily work",
"revision": 1,
+ "timeRange": "today",
"blocks": [
{
"id": "focus-time",
diff --git a/crates/screenpipe-engine/schemas/kits/time-and-focus.live-view-kit.v1.json b/crates/screenpipe-engine/schemas/kits/time-and-focus.live-view-kit.v1.json
index 72c6b5103..fcd8b1bf9 100644
--- a/crates/screenpipe-engine/schemas/kits/time-and-focus.live-view-kit.v1.json
+++ b/crates/screenpipe-engine/schemas/kits/time-and-focus.live-view-kit.v1.json
@@ -15,6 +15,7 @@
"id": "time-and-focus",
"title": "Time & focus",
"revision": 1,
+ "timeRange": "today",
"blocks": [
{
"id": "active-time",
@@ -49,12 +50,23 @@
"pipeName": "time-breakdown"
}
},
+ {
+ "id": "focus-over-time",
+ "title": "Focus over time",
+ "kind": "line-chart.v1",
+ "width": 6,
+ "order": 3,
+ "source": {
+ "type": "pipe.v1",
+ "pipeName": "time-breakdown"
+ }
+ },
{
"id": "time-by-project",
"title": "Time by project",
"kind": "bar-chart.v1",
"width": 6,
- "order": 3,
+ "order": 4,
"source": {
"type": "pipe.v1",
"pipeName": "time-breakdown"
@@ -65,7 +77,7 @@
"title": "Today's activity",
"kind": "timeline.v1",
"width": 6,
- "order": 4,
+ "order": 5,
"source": {
"type": "pipe.v1",
"pipeName": "time-breakdown"
diff --git a/crates/screenpipe-engine/schemas/kits/workday-overview.live-view-kit.v1.json b/crates/screenpipe-engine/schemas/kits/workday-overview.live-view-kit.v1.json
index b886cdc33..a4179b8b5 100644
--- a/crates/screenpipe-engine/schemas/kits/workday-overview.live-view-kit.v1.json
+++ b/crates/screenpipe-engine/schemas/kits/workday-overview.live-view-kit.v1.json
@@ -19,6 +19,7 @@
"id": "workday-overview",
"title": "Workday overview",
"revision": 1,
+ "timeRange": "today",
"blocks": [
{
"id": "active-time",
@@ -53,12 +54,23 @@
"pipeName": "time-breakdown"
}
},
+ {
+ "id": "focus-over-time",
+ "title": "Focus over time",
+ "kind": "line-chart.v1",
+ "width": 6,
+ "order": 3,
+ "source": {
+ "type": "pipe.v1",
+ "pipeName": "time-breakdown"
+ }
+ },
{
"id": "accomplishments",
"title": "Accomplishments",
"kind": "list.v1",
"width": 6,
- "order": 3,
+ "order": 4,
"source": {
"type": "pipe.v1",
"pipeName": "day-recap"
@@ -69,7 +81,7 @@
"title": "Key moments",
"kind": "timeline.v1",
"width": 6,
- "order": 4,
+ "order": 5,
"source": {
"type": "pipe.v1",
"pipeName": "day-recap"
@@ -80,7 +92,7 @@
"title": "Unfinished work",
"kind": "list.v1",
"width": 12,
- "order": 5,
+ "order": 6,
"source": {
"type": "pipe.v1",
"pipeName": "day-recap"
diff --git a/crates/screenpipe-engine/schemas/live-view-template.v1.schema.json b/crates/screenpipe-engine/schemas/live-view-template.v1.schema.json
index 8331e08d4..1fc67f508 100644
--- a/crates/screenpipe-engine/schemas/live-view-template.v1.schema.json
+++ b/crates/screenpipe-engine/schemas/live-view-template.v1.schema.json
@@ -30,6 +30,10 @@
"type": "integer",
"minimum": 1
},
+ "timeRange": {
+ "enum": ["today", "24h", "7d", "30d"],
+ "default": "today"
+ },
"blocks": {
"type": "array",
"maxItems": 24,
@@ -64,6 +68,8 @@
"metric.v1",
"list.v1",
"bar-chart.v1",
+ "line-chart.v1",
+ "table.v1",
"timeline.v1",
"markdown.v1"
]
diff --git a/crates/screenpipe-engine/src/cli/view.rs b/crates/screenpipe-engine/src/cli/view.rs
index f7b224246..9c1bea478 100644
--- a/crates/screenpipe-engine/src/cli/view.rs
+++ b/crates/screenpipe-engine/src/cli/view.rs
@@ -113,7 +113,12 @@ fn write_export(path: &Path, content: &str) -> anyhow::Result<()> {
fn print_view_summary(view: &LiveView) {
println!("{}", view.title);
- println!("id: {} revision: {}", view.id, view.revision);
+ println!(
+ "id: {} revision: {} time-range: {}",
+ view.id,
+ view.revision,
+ view.time_range.schema_name()
+ );
if view.blocks.is_empty() {
println!("no Blocks");
return;
@@ -183,10 +188,11 @@ fn render_html(view: &LiveView) -> String {
);
}
format!(
- "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><title>{title}</title><style>{style}</style></head><body><main><header><p>screenpipe Live View</p><h1>{title}</h1><small>updated {updated}</small></header><div class=\"grid\">{blocks}</div></main></body></html>",
+ "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><title>{title}</title><style>{style}</style></head><body><main><header><p>screenpipe Live View</p><h1>{title}</h1><small>{time_range} · updated {updated}</small></header><div class=\"grid\">{blocks}</div></main></body></html>",
title = escape_html(&view.title),
+ time_range = escape_html(view.time_range.schema_name()),
updated = escape_html(&view.updated_at),
- style = "*{box-sizing:border-box}body{margin:0;background:#f5f5f2;color:#111;font:15px/1.5 ui-sans-serif,system-ui,sans-serif}main{max-width:1100px;margin:0 auto;padding:48px 24px}header{margin-bottom:28px}header p{font:12px ui-monospace,monospace;text-transform:uppercase;letter-spacing:.12em}h1{font-size:38px;margin:4px 0}h2{font-size:16px;margin:0 0 16px}.grid{display:grid;grid-template-columns:repeat(12,1fr);gap:14px}.block{background:#fff;border:1px solid #d8d8d3;padding:20px;min-height:150px}.quarter{grid-column:span 3}.half{grid-column:span 6}.full{grid-column:span 12}.metric{font-size:34px;font-weight:650}.muted{color:#686862}.item{padding:10px 0;border-top:1px solid #e8e8e3}.bar{height:8px;background:#e8e8e3;margin:6px 0}.bar span{display:block;height:100%;background:#111}.content{white-space:pre-wrap}.meta{margin-top:18px;font-size:12px;color:#686862}@media(max-width:760px){.quarter,.half,.full{grid-column:span 12}}"
+ style = "*{box-sizing:border-box}body{margin:0;background:#f5f5f2;color:#111;font:15px/1.5 ui-sans-serif,system-ui,sans-serif}main{max-width:1100px;margin:0 auto;padding:48px 24px}header{margin-bottom:28px}header p{font:12px ui-monospace,monospace;text-transform:uppercase;letter-spacing:.12em}h1{font-size:38px;margin:4px 0}h2{font-size:16px;margin:0 0 16px}.grid{display:grid;grid-template-columns:repeat(12,1fr);gap:14px}.block{background:#fff;border:1px solid #d8d8d3;padding:20px;min-height:150px}.quarter{grid-column:span 3}.half{grid-column:span 6}.full{grid-column:span 12}.metric{font-size:34px;font-weight:650}.muted{color:#686862}.item{padding:10px 0;border-top:1px solid #e8e8e3}.bar{height:8px;background:#e8e8e3;margin:6px 0}.bar span{display:block;height:100%;background:#111}.line-chart{width:100%;height:180px}.line-chart polyline{fill:none;stroke:#111;stroke-width:2}.chart-labels{display:flex;justify-content:space-between;font-size:12px;color:#686862}.table{width:100%;border-collapse:collapse}.table th,.table td{padding:9px 8px;border-top:1px solid #e8e8e3;text-align:left;vertical-align:top}.table th{width:32%;font-weight:600}.content{white-space:pre-wrap}.meta{margin-top:18px;font-size:12px;color:#686862}@media(max-width:760px){.quarter,.half,.full{grid-column:span 12}}"
)
}
@@ -268,6 +274,75 @@ fn render_block_html(block: &LiveViewBlock) -> String {
})
.collect()
}
+ LiveViewBlockKind::LineChartV1 => {
+ let items = value
+ .payload
+ .get("items")
+ .and_then(Value::as_array)
+ .cloned()
+ .unwrap_or_default();
+ let values: Vec<f64> = items
+ .iter()
+ .map(|item| item.get("value").and_then(Value::as_f64).unwrap_or(0.0))
+ .collect();
+ let min = values.iter().copied().fold(f64::INFINITY, f64::min);
+ let max = values.iter().copied().fold(f64::NEG_INFINITY, f64::max);
+ let spread = if min.is_finite() && max.is_finite() && max > min {
+ max - min
+ } else {
+ 1.0
+ };
+ let points = values
+ .iter()
+ .enumerate()
+ .map(|(index, value)| {
+ let x = if values.len() <= 1 {
+ 50.0
+ } else {
+ index as f64 / (values.len() - 1) as f64 * 100.0
+ };
+ let y = 92.0 - ((*value - min) / spread * 84.0);
+ format!("{x:.2},{y:.2}")
+ })
+ .collect::<Vec<_>>()
+ .join(" ");
+ let first = items
+ .first()
+ .map(|item| scalar(item.get("timestamp")))
+ .unwrap_or_default();
+ let last = items
+ .last()
+ .map(|item| scalar(item.get("timestamp")))
+ .unwrap_or_default();
+ format!(
+ "<svg class=\"line-chart\" viewBox=\"0 0 100 100\" preserveAspectRatio=\"none\" role=\"img\" aria-label=\"time series\"><polyline points=\"{}\"></polyline></svg><div class=\"chart-labels\"><span>{}</span><span>{}</span></div>",
+ escape_html(&points),
+ escape_html(&first),
+ escape_html(&last)
+ )
+ }
+ LiveViewBlockKind::TableV1 => value
+ .payload
+ .get("items")
+ .and_then(Value::as_array)
+ .map(|items| {
+ let rows = items
+ .iter()
+ .map(|item| {
+ let label = scalar(item.get("label"));
+ let value = scalar(item.get("value"));
+ let detail = scalar(item.get("detail").or_else(|| item.get("status")));
+ format!(
+ "<tr><th>{}</th><td>{}<div class=\"muted\">{}</div></td></tr>",
+ escape_html(&label),
+ escape_html(&value),
+ escape_html(&detail)
+ )
+ })
+ .collect::<String>();
+ format!("<table class=\"table\"><tbody>{rows}</tbody></table>")
+ })
+ .unwrap_or_default(),
};
format!(
"{body}<div class=\"meta\">updated by {} at {}</div>",
@@ -316,6 +391,7 @@ mod tests {
id: "daily".to_string(),
title: "Daily <script>alert(1)</script>".to_string(),
revision: 1,
+ time_range: crate::live_views::LiveViewTimeRange::Today,
blocks: vec![LiveViewBlock {
id: "summary".to_string(),
title: "Summary".to_string(),
diff --git a/crates/screenpipe-engine/src/live_views.rs b/crates/screenpipe-engine/src/live_views.rs
index 41daeeeb4..c59b4a8f4 100644
--- a/crates/screenpipe-engine/src/live_views.rs
+++ b/crates/screenpipe-engine/src/live_views.rs
@@ -61,6 +61,39 @@ impl LiveViewSource {
}
}
+#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Default)]
+pub enum LiveViewTimeRange {
+ #[default]
+ #[serde(rename = "today")]
+ Today,
+ #[serde(rename = "24h")]
+ Last24Hours,
+ #[serde(rename = "7d")]
+ Last7Days,
+ #[serde(rename = "30d")]
+ Last30Days,
+}
+
+impl LiveViewTimeRange {
+ pub fn schema_name(self) -> &'static str {
+ match self {
+ Self::Today => "today",
+ Self::Last24Hours => "24h",
+ Self::Last7Days => "7d",
+ Self::Last30Days => "30d",
+ }
+ }
+
+ fn instruction(self) -> &'static str {
+ match self {
+ Self::Today => "the current local calendar day",
+ Self::Last24Hours => "the rolling 24 hours ending now",
+ Self::Last7Days => "the rolling 7 days ending now",
+ Self::Last30Days => "the rolling 30 days ending now",
+ }
+ }
+}
+
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
struct LegacyLiveViewBinding {
@@ -94,6 +127,10 @@ pub enum LiveViewBlockKind {
ListV1,
#[serde(rename = "bar-chart.v1")]
BarChartV1,
+ #[serde(rename = "line-chart.v1")]
+ LineChartV1,
+ #[serde(rename = "table.v1")]
+ TableV1,
#[serde(rename = "timeline.v1")]
TimelineV1,
#[serde(rename = "markdown.v1")]
@@ -106,6 +143,8 @@ impl LiveViewBlockKind {
Self::MetricV1 => "metric.v1",
Self::ListV1 => "list.v1",
Self::BarChartV1 => "bar-chart.v1",
+ Self::LineChartV1 => "line-chart.v1",
+ Self::TableV1 => "table.v1",
Self::TimelineV1 => "timeline.v1",
Self::MarkdownV1 => "markdown.v1",
}
@@ -139,6 +178,25 @@ impl LiveViewBlockKind {
}),
&["label", "value"],
),
+ Self::LineChartV1 => collection_schema(
+ json!({
+ "timestamp": {"type": "string", "maxLength": 128},
+ "value": {"type": "number"},
+ "label": {"type": "string", "maxLength": 200}
+ }),
+ &["timestamp", "value"],
+ 60,
+ ),
+ Self::TableV1 => collection_schema(
+ json!({
+ "label": {"type": "string", "maxLength": 200},
+ "value": {"type": ["string", "number"], "maxLength": 500},
+ "detail": {"type": "string", "maxLength": 500},
+ "status": {"type": "string", "maxLength": 80}
+ }),
+ &["label", "value"],
+ 50,
+ ),
Self::TimelineV1 => item_collection_schema(
json!({
"title": {"type": "string", "maxLength": 200},
@@ -160,6 +218,10 @@ impl LiveViewBlockKind {
}
fn item_collection_schema(properties: Value, required: &[&str]) -> Value {
+ collection_schema(properties, required, 20)
+}
+
+fn collection_schema(properties: Value, required: &[&str], max_items: usize) -> Value {
json!({
"type": "object",
"additionalProperties": false,
@@ -167,7 +229,7 @@ fn item_collection_schema(properties: Value, required: &[&str]) -> Value {
"properties": {
"items": {
"type": "array",
- "maxItems": 20,
+ "maxItems": max_items,
"items": {
"type": "object",
"additionalProperties": false,
@@ -203,6 +265,8 @@ pub struct LiveViewTemplate {
pub id: String,
pub title: String,
pub revision: u64,
+ #[serde(default)]
+ pub time_range: LiveViewTimeRange,
pub blocks: Vec<LiveViewTemplateBlock>,
pub created_at: String,
pub updated_at: String,
@@ -255,6 +319,7 @@ pub struct LiveView {
pub id: String,
pub title: String,
pub revision: u64,
+ pub time_range: LiveViewTimeRange,
pub blocks: Vec<LiveViewBlock>,
pub created_at: String,
pub updated_at: String,
@@ -266,6 +331,7 @@ pub struct SaveLiveViewRequest {
pub id: String,
pub title: String,
pub expected_revision: Option<u64>,
+ pub time_range: LiveViewTimeRange,
pub blocks: Vec<LiveViewTemplateBlock>,
}
@@ -561,6 +627,7 @@ fn read_legacy_store(path: &Path) -> Result<LiveViewStore, LiveViewError> {
id: view.id,
title: view.title,
revision: view.revision,
+ time_range: LiveViewTimeRange::Today,
blocks: view
.slots
.into_iter()
@@ -652,12 +719,22 @@ pub fn compile_live_view_targets(templates: &[LiveViewTemplate]) -> Vec<OutputTa
.flat_map(|template| {
template.blocks.iter().filter_map(move |block| {
let source = block.source.as_ref()?;
+ let mut schema = block.kind.output_schema();
+ if let Some(object) = schema.as_object_mut() {
+ object.insert(
+ "x-screenpipe-time-range".to_string(),
+ json!({
+ "preset": template.time_range.schema_name(),
+ "instruction": template.time_range.instruction(),
+ }),
+ );
+ }
Some(OutputTargetInput {
id: live_view_target_id(&template.id, &block.id),
title: block.title.clone(),
bound_pipe: source.pipe_name().to_string(),
schema_name: block.kind.schema_name().to_string(),
- schema: block.kind.output_schema(),
+ schema,
})
})
})
@@ -699,6 +776,7 @@ fn hydrate(
id: template.id.clone(),
title: template.title,
revision: template.revision,
+ time_range: template.time_range,
blocks: template
.blocks
.into_iter()
@@ -771,6 +849,7 @@ pub fn save_live_view(
id: existing.id.clone(),
title: request.title.trim().to_string(),
revision: existing.revision + 1,
+ time_range: request.time_range,
blocks: request.blocks,
created_at: existing.created_at.clone(),
updated_at: now,
@@ -791,6 +870,7 @@ pub fn save_live_view(
id: request.id,
title: request.title.trim().to_string(),
revision: 1,
+ time_range: request.time_range,
blocks: request.blocks,
created_at: now.clone(),
updated_at: now,
@@ -821,6 +901,7 @@ pub fn apply_live_view_template(
id: template.id,
title: template.title,
expected_revision,
+ time_range: template.time_range,
blocks: template.blocks,
},
)
@@ -875,6 +956,7 @@ mod tests {
id: "my-overview".to_string(),
title: "My overview".to_string(),
expected_revision: None,
+ time_range: LiveViewTimeRange::Last7Days,
blocks: vec![block(Some("daily-summary"))],
},
)
@@ -886,6 +968,7 @@ mod tests {
assert_eq!(targets[0].consumer, LIVE_VIEW_CONSUMER_ID);
assert_eq!(targets[0].bound_pipe, "daily-summary");
assert_eq!(targets[0].schema_name, "metric.v1");
+ assert_eq!(targets[0].schema["x-screenpipe-time-range"]["preset"], "7d");
save_live_view(
dir.path(),
@@ -893,6 +976,7 @@ mod tests {
id: "my-overview".to_string(),
title: "My overview".to_string(),
expected_revision: Some(1),
+ time_range: LiveViewTimeRange::Last7Days,
blocks: vec![block(None)],
},
)
@@ -909,6 +993,7 @@ mod tests {
id: "my-overview".to_string(),
title: "My overview".to_string(),
expected_revision: None,
+ time_range: LiveViewTimeRange::Today,
blocks: vec![],
},
)
@@ -919,6 +1004,7 @@ mod tests {
id: "my-overview".to_string(),
title: "Stale".to_string(),
expected_revision: Some(0),
+ time_range: LiveViewTimeRange::Today,
blocks: vec![],
},
)
@@ -938,6 +1024,22 @@ mod tests {
assert_eq!(fixture.blocks.len(), 2);
}
+ #[test]
+ fn templates_saved_before_time_ranges_default_to_today() {
+ let template: LiveViewTemplate = serde_json::from_value(json!({
+ "schema": LIVE_VIEW_TEMPLATE_SCHEMA,
+ "id": "legacy-view",
+ "title": "Legacy view",
+ "revision": 1,
+ "blocks": [],
+ "createdAt": "2026-07-24T00:00:00Z",
+ "updatedAt": "2026-07-24T00:00:00Z"
+ }))
+ .unwrap();
+
+ assert_eq!(template.time_range, LiveViewTimeRange::Today);
+ }
+
#[test]
fn bundled_kits_declare_every_pipe_used_by_their_templates() {
let kits = list_bundled_live_view_kits().unwrap();