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: improve local pipe dev (#1406)

shaik-zeeshan8ca68b6acb8e
diff --git a/screenpipe-app-tauri/components/pipe-store.tsx b/screenpipe-app-tauri/components/pipe-store.tsx
index cf4644a62..506c3d6ac 100644
--- a/screenpipe-app-tauri/components/pipe-store.tsx
+++ b/screenpipe-app-tauri/components/pipe-store.tsx
@@ -42,15 +42,15 @@ export const PipeStore: React.FC = () => {
const [searchQuery, setSearchQuery] = useState("");
const [showInstalledOnly, setShowInstalledOnly] = useState(false);
const [purchaseHistory, setPurchaseHistory] = useState<PurchaseHistoryItem[]>(
- []
+ [],
);
const { showLoginDialog, setShowLoginDialog, checkLogin } = useLoginCheck();
const { open: openStatusDialog } = useStatusDialog();
const [loadingPurchases, setLoadingPurchases] = useState<Set<string>>(
- new Set()
+ new Set(),
);
const [loadingInstalls, setLoadingInstalls] = useState<Set<string>>(
- new Set()
+ new Set(),
);
const filteredPipes = pipes
@@ -58,7 +58,7 @@ export const PipeStore: React.FC = () => {
(pipe) =>
pipe.id.toLowerCase().includes(searchQuery.toLowerCase()) &&
(!showInstalledOnly || pipe.is_installed) &&
- !pipe.is_installing
+ !pipe.is_installing,
)
.sort((a, b) => Number(b.is_paid) - Number(a.is_paid));
@@ -104,7 +104,7 @@ export const PipeStore: React.FC = () => {
const storePluginsWithStatus = await Promise.all(
plugins.map(async (plugin) => {
const installedPipe = installedPipes.find(
- (p) => p.config?.id === plugin.id
+ (p) => p.config?.id === plugin.id,
);
const currentVersion = installedPipe?.config?.version;
@@ -113,7 +113,7 @@ export const PipeStore: React.FC = () => {
try {
const updateCheck = await pipeApi.checkUpdate(
plugin.id,
- currentVersion
+ currentVersion,
);
has_update = updateCheck.has_update;
} catch (error) {
@@ -126,25 +126,24 @@ export const PipeStore: React.FC = () => {
is_installed: !!installedPipe,
installed_config: installedPipe?.config,
has_purchased: purchaseHistory.some(
- (p) => p.plugin_id === plugin.id
+ (p) => p.plugin_id === plugin.id,
),
is_core_pipe: corePipes.includes(plugin.name),
is_enabled: installedPipe?.config?.enabled ?? false,
has_update,
};
- })
+ }),
);
const customPipes = installedPipes
.filter((p) => !plugins.some((plugin) => plugin.id === p.config?.id))
.map((p) => {
- console.log(p.config);
-
const pluginName = p.config?.source?.split("/").pop();
+ const is_local = p.id.endsWith("_local");
return {
- id: p.config?.id || "",
+ id: p.id || "",
name: pluginName || "",
- description: "",
+ description: p.desc,
version: p.config?.version || "0.0.0",
is_paid: false,
price: 0,
@@ -158,6 +157,7 @@ export const PipeStore: React.FC = () => {
is_core_pipe: false,
is_enabled: p.config?.enabled || false,
source_code: p.config?.source || "",
+ is_local,
};
});
@@ -176,7 +176,7 @@ export const PipeStore: React.FC = () => {
const handlePurchasePipe = async (
pipe: PipeWithStatus,
- onComplete?: () => void
+ onComplete?: () => void,
) => {
try {
if (!checkLogin(settings.user)) return;
@@ -289,6 +289,7 @@ export const PipeStore: React.FC = () => {
});
await fetchInstalledPipes();
+
t.dismiss();
} catch (error) {
console.error("failed to add custom pipe:", error);
@@ -302,7 +303,7 @@ export const PipeStore: React.FC = () => {
const handleInstallPipe = async (
pipe: PipeWithStatus,
- onComplete?: () => void
+ onComplete?: () => void,
) => {
try {
if (!checkLogin(settings.user)) return;
@@ -310,8 +311,8 @@ export const PipeStore: React.FC = () => {
// Keep the pipe in its current position by updating its status
setPipes((prevPipes) =>
prevPipes.map((p) =>
- p.id === pipe.id ? { ...p, is_installing: true } : p
- )
+ p.id === pipe.id ? { ...p, is_installing: true } : p,
+ ),
);
setLoadingInstalls((prev) => new Set(prev).add(pipe.id));
@@ -354,7 +355,7 @@ export const PipeStore: React.FC = () => {
pipe_id: pipe.id,
url: response.download_url,
}),
- }
+ },
);
const data = await downloadResponse.json();
@@ -381,8 +382,8 @@ export const PipeStore: React.FC = () => {
prevPipes.map((p) =>
p.id === pipe.id
? { ...p, is_installed: true, is_installing: false }
- : p
- )
+ : p,
+ ),
);
onComplete?.();
@@ -391,8 +392,8 @@ export const PipeStore: React.FC = () => {
// Reset the pipe's status on error
setPipes((prevPipes) =>
prevPipes.map((p) =>
- p.id === pipe.id ? { ...p, is_installing: false } : p
- )
+ p.id === pipe.id ? { ...p, is_installing: false } : p,
+ ),
);
if ((error as Error).cause === PipeDownloadError.PURCHASE_REQUIRED) {
return toast({
@@ -455,14 +456,13 @@ export const PipeStore: React.FC = () => {
const response = await fetch(`http://localhost:3030/pipes/purge`, {
method: "POST",
headers: { "Content-Type": "application/json" },
- body: JSON.stringify({
- }),
+ body: JSON.stringify({}),
});
- if(!response.ok){
+ if (!response.ok) {
toast({
title: "failed to purge pipes",
description: "failed to purge pipes, please try again",
- variant: "destructive"
+ variant: "destructive",
});
return;
}
@@ -509,7 +509,7 @@ export const PipeStore: React.FC = () => {
// Filter installed pipes that have updates available
const pipesToUpdate = pipes.filter(
- (pipe) => pipe.is_installed && pipe.has_update
+ (pipe) => pipe.is_installed && pipe.has_update,
);
if (pipesToUpdate.length === 0) {
@@ -593,7 +593,7 @@ export const PipeStore: React.FC = () => {
const handleTogglePipe = async (
pipe: PipeWithStatus,
- onComplete: () => void
+ onComplete: () => void,
) => {
try {
const t = toast({
@@ -608,13 +608,15 @@ export const PipeStore: React.FC = () => {
});
const endpoint = pipe.installed_config?.enabled ? "disable" : "enable";
+ console.log("toggel", pipe, endpoint);
+ const id = pipe.is_local ? pipe.id : pipe.name;
const response = await fetch(`http://localhost:3030/pipes/${endpoint}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
- body: JSON.stringify({ pipe_id: pipe.name }),
+ body: JSON.stringify({ pipe_id: id }),
});
const data = await response.json();
@@ -626,7 +628,7 @@ export const PipeStore: React.FC = () => {
title: `pipe ${endpoint}d`,
});
const installedPipes = await fetchInstalledPipes();
-
+ console.log("installed Pipes", installedPipes);
const pp = installedPipes?.find((p) => p.config.id === pipe.id);
const port = pp?.config.port;
@@ -638,6 +640,7 @@ export const PipeStore: React.FC = () => {
port,
...prev.installed_config!,
enabled: !pipe.installed_config?.enabled,
+ buildStatus: "in_progress",
},
};
});
@@ -647,7 +650,7 @@ export const PipeStore: React.FC = () => {
`Failed to ${
pipe.installed_config?.enabled ? "disable" : "enable"
} pipe:`,
- error
+ error,
);
toast({
title: "error toggling pipe",
@@ -658,7 +661,7 @@ export const PipeStore: React.FC = () => {
};
const handleLoadFromLocalFolder = async (
- setNewRepoUrl: (url: string) => void
+ setNewRepoUrl: (url: string) => void,
) => {
try {
const selectedFolder = await open({
@@ -684,13 +687,14 @@ export const PipeStore: React.FC = () => {
const handleConfigSave = async (config: Record<string, any>) => {
if (selectedPipe) {
try {
+ const id = selectedPipe.is_local ? selectedPipe.id : selectedPipe.name;
const response = await fetch("http://localhost:3030/pipes/update", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
- pipe_id: selectedPipe.name,
+ pipe_id: id,
config: config,
}),
});
@@ -731,12 +735,13 @@ export const PipeStore: React.FC = () => {
});
setSelectedPipe(null);
+ const id = pipe.is_local ? pipe.id : pipe.name;
const response = await fetch("http://localhost:3030/pipes/delete", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
- body: JSON.stringify({ pipe_id: pipe.name }),
+ body: JSON.stringify({ pipe_id: id }),
});
const data = await response.json();
@@ -859,7 +864,7 @@ export const PipeStore: React.FC = () => {
pipe_id: pipe.name,
source: responseDownload.download_url,
}),
- }
+ },
);
const data = await response.json();
@@ -881,6 +886,7 @@ export const PipeStore: React.FC = () => {
});
await fetchInstalledPipes();
+
t.dismiss();
} catch (error) {
console.error("failed to update pipe:", error);
@@ -1046,7 +1052,7 @@ export const PipeStore: React.FC = () => {
className="flex items-center gap-2"
disabled={
!pipes.some(
- (pipe) => pipe.is_installed && pipe.has_update
+ (pipe) => pipe.is_installed && pipe.has_update,
)
}
>
@@ -1068,6 +1074,13 @@ export const PipeStore: React.FC = () => {
<PipeCard
key={pipe.id}
pipe={pipe}
+ setPipe={(updatedPipe) => {
+ setPipes((prevPipes) => {
+ return prevPipes.map((p) =>
+ p.id === updatedPipe.id ? updatedPipe : p,
+ );
+ });
+ }}
onInstall={handleInstallPipe}
onClick={setSelectedPipe}
onPurchase={handlePurchasePipe}
diff --git a/screenpipe-app-tauri/components/pipe-store/pipe-card.tsx b/screenpipe-app-tauri/components/pipe-store/pipe-card.tsx
index 605e10365..83afb6d6a 100644
--- a/screenpipe-app-tauri/components/pipe-store/pipe-card.tsx
+++ b/screenpipe-app-tauri/components/pipe-store/pipe-card.tsx
@@ -1,7 +1,6 @@
-import React, { useState } from "react";
+import React, { useEffect, useRef, useState } from "react";
import { Button } from "@/components/ui/button";
import {
- CheckCircle,
Download,
Puzzle,
UserIcon,
@@ -10,7 +9,7 @@ import {
ArrowUpCircle,
} from "lucide-react";
import { PipeStoreMarkdown } from "@/components/pipe-store-markdown";
-import { PipeWithStatus } from "./types";
+import { BuildStatus, PipeWithStatus } from "./types";
import { invoke } from "@tauri-apps/api/core";
import { toast } from "@/components/ui/use-toast";
import { motion } from "framer-motion";
@@ -25,6 +24,7 @@ interface PipeCardProps {
isLoadingPurchase?: boolean;
isLoadingInstall?: boolean;
onToggle: (pipe: PipeWithStatus, onComplete: () => void) => Promise<any>;
+ setPipe: (pipe: PipeWithStatus) => void;
}
export const PipeCard: React.FC<PipeCardProps> = ({
@@ -32,6 +32,7 @@ export const PipeCard: React.FC<PipeCardProps> = ({
onInstall,
onClick,
onPurchase,
+ setPipe,
isLoadingPurchase,
isLoadingInstall,
onToggle,
@@ -57,6 +58,63 @@ export const PipeCard: React.FC<PipeCardProps> = ({
}
};
+ useEffect(() => {
+ const pollBuildStatus = async () => {
+ const id = pipe.is_local ? pipe.id : pipe.name;
+ try {
+ const response = await fetch(`http://localhost:3030/pipes/info/${id}`);
+
+ if (!response.ok) {
+ throw new Error(`HTTP error! status: ${response.status}`);
+ }
+
+ const data = await response.json();
+
+ if (
+ data.success &&
+ data.data.config.buildStatus !== pipe.installed_config?.buildStatus
+ ) {
+ // Update pipe with new build status
+ setPipe({
+ ...pipe,
+ installed_config: {
+ ...pipe.installed_config,
+ is_nextjs: pipe.installed_config?.is_nextjs ?? false,
+ source: pipe.installed_config?.source ?? "",
+ buildStatus: data.data.config.buildStatus as BuildStatus,
+ },
+ });
+ }
+ } catch (error) {
+ console.error("Error polling build status:", error);
+ setPipe({
+ ...pipe,
+ installed_config: {
+ ...pipe.installed_config,
+ is_nextjs: pipe.installed_config?.is_nextjs ?? false,
+ source: pipe.installed_config?.source ?? "",
+ buildStatus: "error",
+ },
+ });
+ }
+ };
+
+ let buildStatusInterval: NodeJS.Timeout | null = null;
+ if (pipe.installed_config?.buildStatus === "in_progress") {
+ buildStatusInterval = setInterval(pollBuildStatus, 3000);
+ } else {
+ if (!buildStatusInterval) return;
+ clearInterval(buildStatusInterval);
+ }
+
+ console.log("buildStatus", pipe.installed_config?.buildStatus);
+
+ return () => {
+ if (!buildStatusInterval) return;
+ clearInterval(buildStatusInterval);
+ };
+ }, [pipe.installed_config?.buildStatus]);
+
return (
<motion.div
className="group border rounded-xl p-5 hover:bg-muted/40 has-[.no-card-hover:hover]:hover:bg-transparent transition-all duration-200 cursor-pointer backdrop-blur-sm"
@@ -76,18 +134,43 @@ export const PipeCard: React.FC<PipeCardProps> = ({
<h3 className="font-semibold text-lg tracking-tight">
{pipe.name}
</h3>
- <p className="text-sm text-muted-foreground">
+ <div className="text-sm text-muted-foreground">
<PipeStoreMarkdown
content={pipe.description?.substring(0, 90) || "" + "..."}
variant="compact"
/>
- </p>
+ </div>
</div>
</div>
<div className="flex items-center gap-2 isolate">
{pipe.is_installed ? (
<>
- {!pipe.is_enabled ? (
+ {pipe.installed_config?.buildStatus === "in_progress" ? (
+ <Button
+ size="sm"
+ variant="outline"
+ disabled
+ className="hover:bg-muted font-medium relative hover:!bg-muted no-card-hover"
+ >
+ <Loader2 className="h-3.5 w-3.5 mr-2 animate-spin" />
+ building...
+ </Button>
+ ) : pipe.installed_config?.buildStatus === "error" ? (
+ <Button
+ size="sm"
+ variant="destructive"
+ onClick={(e) => {
+ e.stopPropagation();
+ setIsLoading(true);
+ onToggle(pipe, () => setIsLoading(false));
+ }}
+ className="font-medium no-card-hover"
+ disabled={isLoading}
+ >
+ <ArrowUpCircle className="h-3.5 w-3.5 mr-2" />
+ retry build
+ </Button>
+ ) : !pipe.is_enabled ? (
<Button
size="sm"
variant="outline"
@@ -108,9 +191,19 @@ export const PipeCard: React.FC<PipeCardProps> = ({
variant="outline"
onClick={handleOpenWindow}
className="hover:bg-muted font-medium relative no-card-hover"
+ disabled={
+ pipe.installed_config?.buildStatus &&
+ pipe.installed_config?.buildStatus === "not_started"
+ }
>
- <Puzzle className="h-3.5 w-3.5 mr-2" />
- open
+ {pipe.installed_config?.buildStatus === "not_started" ? (
+ <>wait for app to start building</>
+ ) : (
+ <>
+ <Puzzle className="h-3.5 w-3.5 mr-2" />
+ open
+ </>
+ )}
</Button>
)}
</>
@@ -201,6 +294,11 @@ export const PipeCard: React.FC<PipeCardProps> = ({
<span className="relative z-10 font-mono">source</span>
</motion.a>
)}
+ {pipe.is_local && (
+ <span className="inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-muted font-mono text-xs">
+ local
+ </span>
+ )}
<span className="inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-white/5 font-mono text-xs">
{pipe.installed_config?.version && "v"}
{pipe.installed_config?.version}
diff --git a/screenpipe-app-tauri/components/pipe-store/pipe-details.tsx b/screenpipe-app-tauri/components/pipe-store/pipe-details.tsx
index a146c7237..fd3694023 100644
--- a/screenpipe-app-tauri/components/pipe-store/pipe-details.tsx
+++ b/screenpipe-app-tauri/components/pipe-store/pipe-details.tsx
@@ -33,6 +33,8 @@ interface PipeDetailsProps {
onRefreshFromDisk: (pipe: PipeWithStatus, onComplete: () => void) => void;
}
+const buildStatusNotAllows = ["in_progress", "not_started"];
+
const isValidSource = (source?: string): boolean => {
if (!source) return false;
@@ -134,7 +136,7 @@ export const PipeDetails: React.FC<PipeDetailsProps> = ({
<Button
onClick={() =>
onRefreshFromDisk(pipe, () =>
- setIsLoading(false)
+ setIsLoading(false),
)
}
variant="outline"
@@ -219,48 +221,52 @@ export const PipeDetails: React.FC<PipeDetailsProps> = ({
<main className="flex-1 overflow-y-auto">
<div className="max-w-3xl mx-auto p-8 ">
- {pipe.installed_config?.enabled && pipe.installed_config?.port && (
- <div>
- <div className="flex justify-between items-center mb-4">
- <div className="flex gap-2">
- <Button
- variant="outline"
- onClick={() =>
- openUrl(
- `http://localhost:${pipe.installed_config?.port}`
- )
- }
- disabled={!pipe.installed_config?.enabled}
- >
- <ExternalLink className="mr-2 h-3.5 w-3.5" />
- open in browser
- </Button>
- <Button
- variant="default"
- onClick={async () => {
- try {
- await invoke("open_pipe_window", {
- port: pipe.installed_config!.port,
- title: pipe.name,
- });
- } catch (err) {
- console.error("failed to open pipe window:", err);
- toast({
- title: "error opening pipe window",
- description: "please try again or check the logs",
- variant: "destructive",
- });
+ {pipe.installed_config?.enabled &&
+ !buildStatusNotAllows.includes(
+ pipe.installed_config.buildStatus ?? "",
+ ) &&
+ pipe.installed_config?.port && (
+ <div>
+ <div className="flex justify-between items-center mb-4">
+ <div className="flex gap-2">
+ <Button
+ variant="outline"
+ onClick={() =>
+ openUrl(
+ `http://localhost:${pipe.installed_config?.port}`,
+ )
}
- }}
- disabled={!pipe.installed_config.enabled}
- >
- <Puzzle className="mr-2 h-3.5 w-3.5" />
- open as app
- </Button>
+ disabled={!pipe.installed_config?.enabled}
+ >
+ <ExternalLink className="mr-2 h-3.5 w-3.5" />
+ open in browser
+ </Button>
+ <Button
+ variant="default"
+ onClick={async () => {
+ try {
+ await invoke("open_pipe_window", {
+ port: pipe.installed_config!.port,
+ title: pipe.name,
+ });
+ } catch (err) {
+ console.error("failed to open pipe window:", err);
+ toast({
+ title: "error opening pipe window",
+ description: "please try again or check the logs",
+ variant: "destructive",
+ });
+ }
+ }}
+ disabled={!pipe.installed_config.enabled}
+ >
+ <Puzzle className="mr-2 h-3.5 w-3.5" />
+ open as app
+ </Button>
+ </div>
</div>
</div>
- </div>
- )}
+ )}
{pipe.description && (
<div>
diff --git a/screenpipe-app-tauri/components/pipe-store/types.ts b/screenpipe-app-tauri/components/pipe-store/types.ts
index d5a066df4..2d9a5ac92 100644
--- a/screenpipe-app-tauri/components/pipe-store/types.ts
+++ b/screenpipe-app-tauri/components/pipe-store/types.ts
@@ -1,5 +1,7 @@
import { PipeStorePlugin } from "@/lib/api/store";
+export type BuildStatus = "not_started" | "in_progress" | "success" | "error";
+
export interface InstalledPipe {
config: {
id?: string;
@@ -13,20 +15,24 @@ export interface InstalledPipe {
}[];
fields?: Record<string, any>;
version?: string;
+ buildStatus?: BuildStatus;
};
+ desc: string;
+ id: string;
}
export interface PipeWithStatus extends PipeStorePlugin {
is_installed: boolean;
is_enabled: boolean;
- installed_config?: InstalledPipe['config'];
+ installed_config?: InstalledPipe["config"];
has_purchased: boolean;
is_core_pipe: boolean;
is_installing?: boolean;
has_update?: boolean;
+ is_local?: boolean;
}
export interface BrokenPipe {
id: string;
lastAttempt: number;
-}
+}
diff --git a/screenpipe-core/src/pipes.rs b/screenpipe-core/src/pipes.rs
index d6de2010e..0c4d3974a 100644
--- a/screenpipe-core/src/pipes.rs
+++ b/screenpipe-core/src/pipes.rs
@@ -53,6 +53,14 @@ mod pipes {
shutdown: watch::Sender<bool>,
}
+ #[derive(Debug, Clone)]
+ pub enum BuildStatus {
+ NotStarted,
+ InProgress,
+ Success,
+ Failed(String),
+ }
+
impl CronHandle {
pub fn stop(&self) {
let _ = self.shutdown.send(true);
@@ -279,7 +287,26 @@ mod pipes {
}
// Try to build the Next.js project
- let build_success = try_build_nextjs(&pipe_dir, &bun_path).await?;
+ let build_status = try_build_nextjs(&pipe_dir, &bun_path).await?;
+ let build_success = matches!(build_status, BuildStatus::Success);
+
+ if pipe_json_path.exists() {
+ let pipe_json = tokio::fs::read_to_string(&pipe_json_path).await?;
+ let mut pipe_config: Value = serde_json::from_str(&pipe_json)?;
+
+ pipe_config["buildStatus"] = match &build_status {
+ BuildStatus::Success => json!("success"),
+ BuildStatus::Failed(error) => json!({
+ "status": "failed",
+ "error": error
+ }),
+ BuildStatus::InProgress => json!("in_progress"),
+ BuildStatus::NotStarted => json!("not_started"),
+ };
+
+ let updated_pipe_json = serde_json::to_string_pretty(&pipe_config)?;
+ tokio::fs::write(&pipe_json_path, updated_pipe_json).await?;
+ }
let port = env_vars
.iter()
@@ -501,8 +528,16 @@ mod pipes {
pub async fn download_pipe(source: &str, screenpipe_dir: PathBuf) -> anyhow::Result<PathBuf> {
info!("Processing pipe from source: {}", source);
- let pipe_name =
+ let is_local = Url::parse(source).is_err();
+
+ let mut pipe_name =
sanitize_pipe_name(Path::new(source).file_name().unwrap().to_str().unwrap());
+
+ // Add _local suffix for local pipes
+ if is_local {
+ pipe_name.push_str("_local");
+ }
+
let dest_dir = screenpipe_dir.join("pipes").join(&pipe_name);
debug!("Destination directory: {:?}", dest_dir);
@@ -630,6 +665,7 @@ mod pipes {
};
pipe_config["is_nextjs"] = json!(true);
+ pipe_config["buildStatus"] = json!("not_started");
let updated_pipe_json = serde_json::to_string_pretty(&pipe_config)?;
let mut file = File::create(&pipe_json_path).await?;
file.write_all(updated_pipe_json.as_bytes()).await?;
@@ -1139,7 +1175,7 @@ mod pipes {
Ok(())
}
- async fn try_build_nextjs(pipe_dir: &Path, bun_path: &Path) -> Result<bool> {
+ async fn try_build_nextjs(pipe_dir: &Path, bun_path: &Path) -> Result<BuildStatus> {
info!(
"checking if i need to build the next.js project in: {:?}",
pipe_dir
@@ -1151,13 +1187,23 @@ mod pipes {
let build_manifest = build_dir.join("build-manifest.json");
if build_manifest.exists() {
info!("found existing next.js build, skipping rebuild");
- return Ok(true);
+ return Ok(BuildStatus::Success);
}
// Invalid/incomplete build directory - remove it
debug!("removing invalid next.js build directory");
tokio::fs::remove_dir_all(&build_dir).await?;
}
+ // Update build status to InProgress in pipe.json
+ let pipe_json_path = pipe_dir.join("pipe.json");
+ if pipe_json_path.exists() {
+ let pipe_json = tokio::fs::read_to_string(&pipe_json_path).await?;
+ let mut pipe_config: Value = serde_json::from_str(&pipe_json)?;
+ pipe_config["buildStatus"] = json!("in_progress");
+ let updated_pipe_json = serde_json::to_string_pretty(&pipe_config)?;
+ tokio::fs::write(&pipe_json_path, updated_pipe_json).await?;
+ }
+
info!("running next.js build");
let build_output = Command::new(bun_path)
.arg("run")
@@ -1169,13 +1215,11 @@ mod pipes {
if build_output.status.success() {
info!("next.js build completed successfully");
- Ok(true)
+ Ok(BuildStatus::Success)
} else {
- error!(
- "next.js build failed: {}",
- String::from_utf8_lossy(&build_output.stderr)
- );
- Ok(false)
+ let error_message = String::from_utf8_lossy(&build_output.stderr).to_string();
+ error!("next.js build failed: {}", error_message);
+ Ok(BuildStatus::Failed(error_message))
}
}
diff --git a/screenpipe-server/src/pipe_manager.rs b/screenpipe-server/src/pipe_manager.rs
index bdd46bf60..53e13ce8e 100644
--- a/screenpipe-server/src/pipe_manager.rs
+++ b/screenpipe-server/src/pipe_manager.rs
@@ -20,6 +20,8 @@ pub struct PipeInfo {
pub source: String,
pub port: Option<u16>,
pub is_nextjs: bool,
+ pub desc: String,
+ pub build_status: Option<Value>,
}
struct PipeHandle {
@@ -139,12 +141,18 @@ impl PipeManager {
pipes.iter().find(|pipe| pipe.id == id).cloned()
}
- async fn load_pipe_info(pipe_id: String, config_path: PathBuf) -> PipeInfo {
+ async fn load_pipe_info(pipe_id: String, pipe_path: PathBuf) -> PipeInfo {
+ let config_path = pipe_path.join("pipe.json");
let config = tokio::fs::read_to_string(&config_path)
.await
.and_then(|s| serde_json::from_str::<Value>(&s).map_err(Into::into))
.unwrap_or(Value::Null);
+ let desc_file = pipe_path.join("README.md");
+ let desc_pipe = tokio::fs::read_to_string(desc_file)
+ .await
+ .unwrap_or_default();
+
PipeInfo {
id: pipe_id,
enabled: config
@@ -166,6 +174,8 @@ impl PipeManager {
.get("is_nextjs")
.and_then(Value::as_bool)
.unwrap_or(false),
+ desc: desc_pipe,
+ build_status: config.get("buildStatus").cloned(),
}
}
@@ -186,8 +196,7 @@ impl PipeManager {
.map(|ft| ft.is_dir())
.unwrap_or(false)
{
- let config_path = entry.path().join("pipe.json");
- pipe_infos.push(Self::load_pipe_info(pipe_id.into_owned(), config_path).await);
+ pipe_infos.push(Self::load_pipe_info(pipe_id.into_owned(), entry.path()).await);
}
}
}
@@ -201,11 +210,15 @@ impl PipeManager {
let pipe_dir = download_pipe(&normalized_url, self.screenpipe_dir.clone()).await?;
+ // Check if the URL is a local path
+ let is_local = normalized_url.starts_with('/') || normalized_url.starts_with('.');
+
// update the config with the source url
self.update_config(
&pipe_dir.file_name().unwrap().to_string_lossy(),
serde_json::json!({
"source": normalized_url,
+ "enabled": is_local,
}),
)
.await?;