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
accept agent Live View edit schema
Louis Beaumontcfe29051d532
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.tsindex 17d66573e..530ca0bee 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@@ -105,6 +105,46 @@ describe("parseGeneratedLiveView", () => {);});+ it("accepts the native Live View shape returned by the agent tool", () => {+ const result = parseGeneratedLiveView(+ JSON.stringify({+ view: {+ title: "Work Patterns Dashboard 2",+ timeRange: "today",+ blocks: [+ {+ id: "time-by-app",+ title: "Time by application",+ kind: "bar-chart.v1",+ width: 6,+ intent: "Group captured active minutes by application.",+ source: {+ type: "pipe.v1",+ pipeName: "chronos-time-tracker",+ },+ },+ ],+ },+ }),+ ["chronos-time-tracker"],+ "dashboard",+ );++ expect(result).toEqual(+ expect.objectContaining({+ title: "Work Patterns Dashboard 2",+ timeRange: "today",+ blocks: [+ expect.objectContaining({+ title: "Time by application",+ component: "bar-chart.v1",+ pipeName: "chronos-time-tracker",+ }),+ ],+ }),+ );+ });+it("keeps only one section when generating an addition", () => {const result = parseGeneratedLiveView('{"blocks":[{"title":"First","component":"timeline.v1"},{"title":"Second","component":"markdown.v1"}]}',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.tsindex 38ed00929..8c2caa0c5 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@@ -115,6 +115,14 @@ function componentValue(value: unknown): BrainViewComponent | null {return COMPONENT_ALIASES[value.toLowerCase()] ?? null;}+function nestedPipeName(block: Record<string, unknown>): string | null {+ for (const value of [block.source, block.binding]) {+ const source = asRecord(value);+ if (typeof source?.pipeName === "string") return source.pipeName;+ }+ return null;+}+function widthValue(value: unknown): 3 | 6 | 12 {if (value === 3 || value === "3" || value === "quarter") return 3;if (value === 12 || value === "12" || value === "full") return 12;@@ -141,7 +149,10 @@ export function parseGeneratedLiveView(allowedPipeNames: string[],scope: LiveViewGenerationScope,): GeneratedLiveView {- const parsed = firstJsonObject(raw);+ const response = firstJsonObject(raw);+ const wrappedView = asRecord(response.view);+ const parsed =+ wrappedView && Array.isArray(wrappedView.blocks) ? wrappedView : response;const rawBlocks = Array.isArray(parsed.blocks)? parsed.blocks: parsed.block@@ -154,7 +165,9 @@ export function parseGeneratedLiveView(.map(asRecord).filter((block): block is Record<string, unknown> => Boolean(block)).map((block) => {- const component = componentValue(block.component ?? block.type);+ const component = componentValue(+ block.component ?? block.kind ?? block.type,+ );const title = typeof block.title === "string" ? block.title.trim() : "";if (!component || !title) return null;const intent =@@ -166,7 +179,7 @@ export function parseGeneratedLiveView(? block.pipeName: typeof block.pipe === "string"? block.pipe- : null;+ : nestedPipeName(block);return {title: title.slice(0, 120),intent,@@ -210,6 +223,7 @@ function generationSystemPrompt(): string {Return exactly one JSON object. Do not use markdown fences, prose outside JSON, HTML, JavaScript, or SQL.When the request names a current Live View reference, first call screenpipe_live_view with action "get" and that exact id. Use no other tools and never call action "save"; the app validates and previews your proposed edit before it persists anything.+The get tool returns native Blocks with kind and source.pipeName. In your final JSON, convert kind to component and source.pipeName to pipeName. Do not wrap the final dashboard in a view property.Allowed components:- metric.v1: one important number