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

fix: pipe store null guards, sharp corners, unpublish, data unwrap fix

Louis Beaumont603c84f7be16
diff --git a/apps/screenpipe-app-tauri/components/pipe-store.tsx b/apps/screenpipe-app-tauri/components/pipe-store.tsx
index d0e1f5dbb..3d680121e 100644
--- a/apps/screenpipe-app-tauri/components/pipe-store.tsx
+++ b/apps/screenpipe-app-tauri/components/pipe-store.tsx
@@ -67,6 +67,7 @@ interface StorePipe {
description: string;
icon: string;
author: string;
+ author_id?: string;
author_verified: boolean;
category: string;
version: string;
@@ -211,8 +212,11 @@ function formatCount(n: number): string {
return String(n);
}
-function relativeDate(dateStr: string): string {
- const diff = Date.now() - new Date(dateStr).getTime();
+function relativeDate(dateStr: string | null | undefined): string {
+ if (!dateStr) return "unknown";
+ const time = new Date(dateStr).getTime();
+ if (isNaN(time)) return "unknown";
+ const diff = Date.now() - time;
const days = Math.floor(diff / 86400000);
if (days < 1) return "today";
if (days === 1) return "yesterday";
@@ -221,6 +225,30 @@ function relativeDate(dateStr: string): string {
return `${Math.floor(days / 365)}y ago`;
}
+/**
+ * Normalize pipe data from the API response.
+ * The backend returns `avg_rating` (not `rating`), `author_id` (not `author`),
+ * `source_md` (not `source`), and values can be null.
+ */
+function normalizePipe(raw: any): any {
+ if (!raw) return raw;
+ return {
+ ...raw,
+ title: raw.title || raw.slug || "untitled pipe",
+ author: raw.author || raw.author_name || "",
+ author_id: raw.author_id || null,
+ rating: raw.rating ?? raw.avg_rating ?? 0,
+ review_count: raw.review_count ?? 0,
+ install_count: raw.install_count ?? 0,
+ version: raw.version ?? "0",
+ updated_at: raw.updated_at || raw.created_at || null,
+ category: raw.category || "other",
+ source: raw.source || raw.source_md || null,
+ description: raw.description || "",
+ icon: raw.icon || "🔧",
+ };
+}
+
// --- Main Unified Component ---
export function PipeStoreView() {
@@ -292,6 +320,9 @@ function DiscoverView() {
// Source section
const [sourceExpanded, setSourceExpanded] = useState(false);
+ // Unpublish state
+ const [unpublishing, setUnpublishing] = useState(false);
+
// Publish dialog
const [publishOpen, setPublishOpen] = useState(false);
@@ -328,7 +359,7 @@ function DiscoverView() {
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
const list = data.data || data.pipes || (Array.isArray(data) ? data : []);
- setPipes(list);
+ setPipes(list.map(normalizePipe));
} catch (err) {
console.error("failed to fetch pipe store:", err);
setPipes([]);
@@ -351,10 +382,13 @@ function DiscoverView() {
setReviewRating(0);
setReviewComment("");
try {
- const res = await fetch(`http://localhost:3030/pipes/store/${slug}`);
+ const res = await fetch(`http://localhost:3030/pipes/store/${slug}`, {
+ headers: token ? { Authorization: `Bearer ${token}` } : {},
+ });
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
- setSelectedPipe(data);
+ const pipeData = data.data || data;
+ setSelectedPipe(normalizePipe(pipeData));
} catch (err) {
console.error("failed to fetch pipe detail:", err);
toast({
@@ -431,6 +465,34 @@ function DiscoverView() {
}
};
+ // Unpublish pipe
+ const handleUnpublish = async (slug: string) => {
+ setUnpublishing(true);
+ try {
+ const headers: Record<string, string> = { "Content-Type": "application/json" };
+ if (token) headers["Authorization"] = `Bearer ${token}`;
+ const res = await fetch(`http://localhost:3030/pipes/store/${slug}`, {
+ method: "DELETE",
+ headers,
+ });
+ const data = await res.json().catch(() => ({}));
+ if (!res.ok || data.error) throw new Error(data.error || `HTTP ${res.status}`);
+ posthog.capture("pipe_unpublished_from_store", { slug });
+ toast({ title: `"${slug}" unpublished from store` });
+ setShowDetail(false);
+ setSelectedPipe(null);
+ fetchPipes();
+ } catch (err: any) {
+ toast({
+ title: "failed to unpublish pipe",
+ description: err.message,
+ variant: "destructive",
+ });
+ } finally {
+ setUnpublishing(false);
+ }
+ };
+
// If showing detail view, render full-width detail panel
if (showDetail) {
return (
@@ -469,6 +531,9 @@ function DiscoverView() {
sourceExpanded={sourceExpanded}
onToggleSource={() => setSourceExpanded(!sourceExpanded)}
token={token}
+ currentUserId={settings.user?.id}
+ onUnpublish={handleUnpublish}
+ unpublishing={unpublishing}
/>
) : null}
</div>
@@ -692,7 +757,7 @@ function FeaturedCard({
</span>
<span className="flex items-center gap-1">
<Download className="h-3 w-3" />
- {formatCount(pipe.install_count)}
+ {formatCount(pipe.install_count ?? 0)}
</span>
</div>
</div>
@@ -795,7 +860,7 @@ function PipeCard({
</span>
<span className="flex items-center gap-1">
<Download className="h-3 w-3" />
- {formatCount(pipe.install_count)}
+ {formatCount(pipe.install_count ?? 0)}
</span>
</div>
</div>
@@ -822,6 +887,9 @@ function PipeDetailPanel({
sourceExpanded,
onToggleSource,
token,
+ currentUserId,
+ onUnpublish,
+ unpublishing,
}: {
pipe: PipeDetail;
installing: string | null;
@@ -840,9 +908,13 @@ function PipeDetailPanel({
sourceExpanded: boolean;
onToggleSource: () => void;
token?: string | null;
+ currentUserId?: string | null;
+ onUnpublish?: (slug: string) => void;
+ unpublishing?: boolean;
}) {
const unrestricted = isUnrestricted(pipe.permissions);
const needsReview = unrestricted && !pipe.author_verified;
+ const isOwner = !!(currentUserId && pipe.author_id && currentUserId === pipe.author_id);
const readmeContent = pipe.readme_md
? pipe.readme_md
@@ -854,38 +926,48 @@ function PipeDetailPanel({
<div className="space-y-8">
{/* Hero header */}
<div className="flex items-start gap-4">
- <div className="text-4xl bg-muted rounded-2xl h-16 w-16 flex items-center justify-center flex-shrink-0">
+ <div className="text-4xl bg-muted rounded-none h-16 w-16 flex items-center justify-center flex-shrink-0">
{pipe.icon || "🔧"}
</div>
<div className="min-w-0 flex-1">
<div className="flex items-start justify-between gap-3">
<div>
- <h2 className="text-xl font-semibold tracking-tight">{pipe.title}</h2>
+ <h2 className="text-xl font-semibold tracking-tight">{pipe.title || pipe.slug || "untitled pipe"}</h2>
<div className="flex items-center gap-2 mt-1 flex-wrap">
- <div className="flex items-center gap-1 text-sm text-muted-foreground">
- <span>{pipe.author}</span>
- {pipe.author_verified && (
- <BadgeCheck className="h-3.5 w-3.5 text-blue-500" />
- )}
- </div>
- <span className="text-xs text-muted-foreground/50">·</span>
- <span className="text-xs text-muted-foreground">v{pipe.version}</span>
- <span className="text-xs text-muted-foreground/50">·</span>
- <Badge variant="secondary" className="text-[10px] px-2 py-0.5 font-normal rounded-full">
- {pipe.category}
- </Badge>
+ {pipe.author ? (
+ <div className="flex items-center gap-1 text-sm text-muted-foreground">
+ <span>{pipe.author}</span>
+ {pipe.author_verified && (
+ <BadgeCheck className="h-3.5 w-3.5 text-blue-500" />
+ )}
+ </div>
+ ) : null}
+ {pipe.version ? (
+ <>
+ {pipe.author && <span className="text-xs text-muted-foreground/50">·</span>}
+ <span className="text-xs text-muted-foreground">v{pipe.version}</span>
+ </>
+ ) : null}
+ {pipe.category ? (
+ <>
+ <span className="text-xs text-muted-foreground/50">·</span>
+ <Badge variant="secondary" className="text-[10px] px-2 py-0.5 font-normal rounded-none">
+ {pipe.category}
+ </Badge>
+ </>
+ ) : null}
</div>
<div className="flex items-center gap-4 mt-2 text-sm text-muted-foreground">
<span className="flex items-center gap-1.5">
<StarRating rating={pipe.rating ?? 0} size="md" />
<span>
- {(pipe.rating ?? 0).toFixed(1)} ({pipe.review_count}{" "}
- {pipe.review_count === 1 ? "review" : "reviews"})
+ {(pipe.rating ?? 0).toFixed(1)} ({pipe.review_count ?? 0}{" "}
+ {(pipe.review_count ?? 0) === 1 ? "review" : "reviews"})
</span>
</span>
<span className="flex items-center gap-1">
<Download className="h-3.5 w-3.5" />
- {formatCount(pipe.install_count)} installs
+ {formatCount(pipe.install_count ?? 0)} installs
</span>
<span className="text-xs">
updated {relativeDate(pipe.updated_at)}
@@ -893,32 +975,52 @@ function PipeDetailPanel({
</div>
</div>
- <Button
- size="sm"
- variant={isInstalled ? "outline" : "default"}
- className={cn(
- "h-9 px-5 text-sm font-semibold rounded-full flex-shrink-0",
- isInstalled && "pointer-events-none"
- )}
- disabled={
- installing === pipe.slug || isInstalled || (needsReview && !sourceReviewed)
- }
- onClick={() => onInstall(pipe.slug)}
- >
- {installing === pipe.slug ? (
- <>
- <Loader2 className="h-4 w-4 animate-spin mr-1.5" />
- installing...
- </>
- ) : isInstalled ? (
- "Installed"
- ) : (
- <>
- <Download className="h-4 w-4 mr-1.5" />
- Get
- </>
+ <div className="flex items-center gap-2 flex-shrink-0">
+ {isOwner && onUnpublish && (
+ <Button
+ size="sm"
+ variant="destructive"
+ className="h-9 px-4 text-sm font-semibold rounded-none"
+ disabled={unpublishing}
+ onClick={() => onUnpublish(pipe.slug)}
+ >
+ {unpublishing ? (
+ <>
+ <Loader2 className="h-4 w-4 animate-spin mr-1.5" />
+ unpublishing...
+ </>
+ ) : (
+ "unpublish"
+ )}
+ </Button>
)}
- </Button>
+ <Button
+ size="sm"
+ variant={isInstalled ? "outline" : "default"}
+ className={cn(
+ "h-9 px-5 text-sm font-semibold rounded-none flex-shrink-0",
+ isInstalled && "pointer-events-none"
+ )}
+ disabled={
+ installing === pipe.slug || isInstalled || (needsReview && !sourceReviewed)
+ }
+ onClick={() => onInstall(pipe.slug)}
+ >
+ {installing === pipe.slug ? (
+ <>
+ <Loader2 className="h-4 w-4 animate-spin mr-1.5" />
+ installing...
+ </>
+ ) : isInstalled ? (
+ "Installed"
+ ) : (
+ <>
+ <Download className="h-4 w-4 mr-1.5" />
+ Get
+ </>
+ )}
+ </Button>
+ </div>
</div>
</div>
</div>
@@ -928,7 +1030,7 @@ function PipeDetailPanel({
<h4 className="text-xs font-medium text-muted-foreground uppercase tracking-widest">
README
</h4>
- <div className="border border-border rounded-xl p-6">
+ <div className="border border-border rounded-none p-6">
{readmeContent ? (
<MemoizedReactMarkdown
remarkPlugins={[remarkGfm]}
@@ -973,7 +1075,7 @@ function PipeDetailPanel({
<h4 className="text-xs font-medium text-muted-foreground uppercase tracking-widest">
Permissions
</h4>
- <div className="border border-border rounded-xl p-5 space-y-3">
+ <div className="border border-border rounded-none p-5 space-y-3">
<div className="grid grid-cols-2 md:grid-cols-3 gap-2">
{PERMISSION_LABELS.map((perm) => {
const status = getPermissionStatus(pipe.permissions, perm.key);
@@ -1014,7 +1116,7 @@ function PipeDetailPanel({
{/* Unrestricted warning */}
{unrestricted && (
- <div className="border border-orange-500/50 bg-orange-500/5 rounded-xl p-4 space-y-2">
+ <div className="border border-orange-500/50 bg-orange-500/5 rounded-none p-4 space-y-2">
<div className="flex items-center gap-2 text-sm font-medium text-orange-600 dark:text-orange-400">
<AlertTriangle className="h-4 w-4" />
unrestricted data access
@@ -1042,14 +1144,14 @@ function PipeDetailPanel({
{/* Reviews */}
<div className="space-y-3">
<h4 className="text-xs font-medium text-muted-foreground uppercase tracking-widest">
- Reviews ({pipe.review_count})
+ Reviews ({pipe.review_count ?? 0})
</h4>
<div className="space-y-3">
{pipe.reviews && pipe.reviews.length > 0 ? (
pipe.reviews.map((review) => (
<div
key={review.id}
- className="border border-border rounded-xl p-4 space-y-1.5"
+ className="border border-border rounded-none p-4 space-y-1.5"
>
<div className="flex items-center gap-2">
<StarRating rating={review.rating} />
@@ -1079,7 +1181,7 @@ function PipeDetailPanel({
{reviewExpanded ? "cancel review" : "write a review"}
</button>
{reviewExpanded && (
- <div className="mt-3 space-y-3 border border-border rounded-xl p-4">
+ <div className="mt-3 space-y-3 border border-border rounded-none p-4">
<div>
<Label className="text-xs">rating</Label>
<div className="mt-1">
@@ -1139,7 +1241,7 @@ function PipeDetailPanel({
Source (pipe.md)
</button>
{sourceExpanded && pipe.source && (
- <div className="border border-border rounded-xl overflow-hidden">
+ <div className="border border-border rounded-none overflow-hidden">
<pre className="p-4 text-xs leading-relaxed whitespace-pre-wrap font-mono max-h-80 overflow-y-auto bg-muted/50">
{pipe.source}
</pre>
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
index 11f2e4c08..16a772525 100644
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
@@ -9329,7 +9329,7 @@ dependencies = [
[[package]]
name = "screenpipe-app"
-version = "2.2.152"
+version = "2.2.153"
dependencies = [
"anyhow",
"arboard",
diff --git a/crates/screenpipe-engine/src/routes/pipe_store.rs b/crates/screenpipe-engine/src/routes/pipe_store.rs
index f2238939c..6bb445464 100644
--- a/crates/screenpipe-engine/src/routes/pipe_store.rs
+++ b/crates/screenpipe-engine/src/routes/pipe_store.rs
@@ -105,12 +105,16 @@ pub async fn pipe_store_search(Query(query): Query<StoreSearchQuery>) -> Json<Va
/// GET /pipes/store/:slug
///
/// Get a single pipe's detail from the registry.
-pub async fn pipe_store_detail(Path(slug): Path<String>) -> Json<Value> {
+pub async fn pipe_store_detail(headers: HeaderMap, Path(slug): Path<String>) -> Json<Value> {
let base = api_base_url();
let client = reqwest::Client::new();
let url = format!("{}/api/pipes/store/{}", base, slug);
- match client.get(&url).send().await {
+ let mut req = client.get(&url);
+ if let Some(token) = extract_auth_token(&headers) {
+ req = req.bearer_auth(&token);
+ }
+ match req.send().await {
Ok(resp) => match resp.json::<Value>().await {
Ok(body) => Json(body),
Err(e) => Json(json!({ "error": format!("failed to parse registry response: {}", e) })),
@@ -119,6 +123,37 @@ pub async fn pipe_store_detail(Path(slug): Path<String>) -> Json<Value> {
}
}
+/// DELETE /pipes/store/:slug
+///
+/// Unpublish a pipe from the registry. Requires auth (Bearer token).
+/// Only the pipe's author can unpublish it.
+pub async fn pipe_store_unpublish(
+ headers: HeaderMap,
+ Path(slug): Path<String>,
+) -> Json<Value> {
+ let token = match extract_auth_token(&headers) {
+ Some(t) => t,
+ None => return Json(json!({ "error": "authorization required" })),
+ };
+
+ let base = api_base_url();
+ let client = reqwest::Client::new();
+
+ let url = format!("{}/api/pipes/store/{}", base, slug);
+ match client
+ .delete(&url)
+ .bearer_auth(&token)
+ .send()
+ .await
+ {
+ Ok(resp) => match resp.json::<Value>().await {
+ Ok(resp_body) => Json(resp_body),
+ Err(e) => Json(json!({ "error": format!("failed to parse registry response: {}", e) })),
+ },
+ Err(e) => Json(json!({ "error": format!("failed to reach registry: {}", e) })),
+ }
+}
+
/// POST /pipes/store/publish
///
/// Publish a pipe to the registry. Requires auth (Bearer token).
diff --git a/crates/screenpipe-engine/src/server.rs b/crates/screenpipe-engine/src/server.rs
index 164e9b7c6..ec02f8137 100644
--- a/crates/screenpipe-engine/src/server.rs
+++ b/crates/screenpipe-engine/src/server.rs
@@ -641,7 +641,8 @@ impl SCServer {
)
.route(
"/store/:slug",
- axum::routing::get(crate::routes::pipe_store::pipe_store_detail),
+ axum::routing::get(crate::routes::pipe_store::pipe_store_detail)
+ .delete(crate::routes::pipe_store::pipe_store_unpublish),
)
.route(
"/store/:slug/review",