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 refresh button and animations to AI suggestion chips

Louis Beaumontf9b5acc82400
diff --git a/apps/screenpipe-app-tauri/components/chat/summary-cards.tsx b/apps/screenpipe-app-tauri/components/chat/summary-cards.tsx
index 83f391e0a..f8480f477 100644
--- a/apps/screenpipe-app-tauri/components/chat/summary-cards.tsx
+++ b/apps/screenpipe-app-tauri/components/chat/summary-cards.tsx
@@ -4,8 +4,8 @@
"use client";
import { useState } from "react";
-import { motion } from "framer-motion";
-import { ChevronDown, ChevronUp, Plus } from "lucide-react";
+import { motion, AnimatePresence } from "framer-motion";
+import { ChevronDown, ChevronUp, Plus, RefreshCw } from "lucide-react";
import { PipeAIIconLarge } from "@/components/pipe-ai-icon";
import { type TemplatePipe } from "@/lib/hooks/use-pipes";
import { FALLBACK_TEMPLATES, type CustomTemplate } from "@/lib/summary-templates";
@@ -15,6 +15,8 @@ import { CustomSummaryBuilder } from "./custom-summary-builder";
interface SummaryCardsProps {
onSendMessage: (message: string, displayLabel?: string) => void;
autoSuggestions: Suggestion[];
+ suggestionsRefreshing?: boolean;
+ onRefreshSuggestions?: () => void;
customTemplates: CustomTemplate[];
onSaveCustomTemplate: (template: CustomTemplate) => void;
onDeleteCustomTemplate: (id: string) => void;
@@ -23,9 +25,40 @@ interface SummaryCardsProps {
pipesLoading?: boolean;
}
+// ─── Shimmer skeleton for loading state ──────────────────────────────────────
+
+function SuggestionSkeleton() {
+ return (
+ <div className="flex flex-wrap gap-1.5">
+ {[1, 2, 3].map((i) => (
+ <div
+ key={i}
+ className="relative overflow-hidden h-[26px] border border-border/20 bg-muted/10"
+ style={{ width: `${80 + i * 30}px` }}
+ >
+ <motion.div
+ className="absolute inset-0 bg-gradient-to-r from-transparent via-foreground/[0.04] to-transparent"
+ animate={{ x: ["-100%", "200%"] }}
+ transition={{
+ duration: 1.2,
+ repeat: Infinity,
+ ease: "linear",
+ delay: i * 0.15,
+ }}
+ />
+ </div>
+ ))}
+ </div>
+ );
+}
+
+// ─── Main component ──────────────────────────────────────────────────────────
+
export function SummaryCards({
onSendMessage,
autoSuggestions,
+ suggestionsRefreshing = false,
+ onRefreshSuggestions,
customTemplates,
onSaveCustomTemplate,
onDeleteCustomTemplate,
@@ -52,8 +85,8 @@ export function SummaryCards({
<div className="relative flex flex-col items-center py-4 px-4">
{/* Header */}
<div className="relative mx-auto mb-3 w-fit">
- <div className="absolute -inset-4 border border-dashed border-border/50 rounded-xl" />
- <div className="absolute -inset-2 border border-border/30 rounded-lg" />
+ <div className="absolute -inset-4 border border-dashed border-border/50" />
+ <div className="absolute -inset-2 border border-border/30" />
<PipeAIIconLarge size={40} thinking={false} className="relative text-foreground/80" />
</div>
<h3 className="text-sm font-medium mb-0.5 text-foreground">
@@ -69,13 +102,13 @@ export function SummaryCards({
<button
key={pipe.name}
onClick={() => handleCardClick(pipe)}
- className="group text-left p-2 rounded-lg border border-border/40 bg-muted/20 hover:bg-muted/50 hover:border-border/70 transition-all duration-150 cursor-pointer"
+ className="group text-left p-2 border border-border/40 bg-muted/20 hover:bg-foreground hover:text-background hover:border-foreground transition-all duration-150 cursor-pointer"
>
<div className="text-sm mb-0.5">{pipe.icon}</div>
- <div className="text-[11px] font-medium text-foreground group-hover:text-foreground mb-0.5 leading-tight">
+ <div className="text-[11px] font-medium group-hover:text-background mb-0.5 leading-tight">
{pipe.title}
</div>
- <div className="text-[10px] text-muted-foreground leading-tight line-clamp-1">
+ <div className="text-[10px] text-muted-foreground group-hover:text-background/60 leading-tight line-clamp-1">
{pipe.description}
</div>
</button>
@@ -83,13 +116,13 @@ export function SummaryCards({
{/* Custom Summary card */}
<button
onClick={() => setShowBuilder(true)}
- className="group text-left p-2 rounded-lg border border-dashed border-primary/30 bg-primary/5 hover:bg-primary/10 hover:border-primary/50 transition-all duration-150 cursor-pointer"
+ className="group text-left p-2 border border-dashed border-border/40 bg-muted/5 hover:bg-foreground hover:text-background hover:border-foreground transition-all duration-150 cursor-pointer"
>
<div className="text-sm mb-0.5">{"\u2728"}</div>
- <div className="text-[11px] font-medium text-foreground group-hover:text-foreground mb-0.5 leading-tight">
+ <div className="text-[11px] font-medium group-hover:text-background mb-0.5 leading-tight">
Custom Summary
</div>
- <div className="text-[10px] text-muted-foreground leading-tight line-clamp-1">
+ <div className="text-[10px] text-muted-foreground group-hover:text-background/60 leading-tight line-clamp-1">
Build your own
</div>
</button>
@@ -97,13 +130,13 @@ export function SummaryCards({
{discover.length > 0 && (
<button
onClick={() => setShowAll(!showAll)}
- className="group text-left p-2 rounded-lg border border-border/40 bg-muted/10 hover:bg-muted/30 hover:border-border/60 transition-all duration-150 cursor-pointer"
+ className="group text-left p-2 border border-border/40 bg-muted/10 hover:bg-foreground hover:text-background hover:border-foreground transition-all duration-150 cursor-pointer"
>
<div className="text-sm mb-0.5">{"\u{1F50D}"}</div>
- <div className="text-[11px] font-medium text-foreground group-hover:text-foreground mb-0.5 leading-tight">
+ <div className="text-[11px] font-medium group-hover:text-background mb-0.5 leading-tight">
{showAll ? "Show Less" : "Discover"}
</div>
- <div className="text-[10px] text-muted-foreground leading-tight line-clamp-1 flex items-center gap-1">
+ <div className="text-[10px] text-muted-foreground group-hover:text-background/60 leading-tight line-clamp-1 flex items-center gap-1">
{showAll ? (
<>Collapse <ChevronUp className="w-3 h-3 inline" /></>
) : (
@@ -126,13 +159,13 @@ export function SummaryCards({
<button
key={pipe.name}
onClick={() => handleCardClick(pipe)}
- className="group text-left p-2 rounded-lg border border-border/30 bg-muted/10 hover:bg-muted/40 hover:border-border/60 transition-all duration-150 cursor-pointer"
+ className="group text-left p-2 border border-border/30 bg-muted/10 hover:bg-foreground hover:text-background hover:border-foreground transition-all duration-150 cursor-pointer"
>
<div className="text-sm mb-0.5">{pipe.icon}</div>
- <div className="text-[11px] font-medium text-foreground group-hover:text-foreground mb-0.5 leading-tight">
+ <div className="text-[11px] font-medium group-hover:text-background mb-0.5 leading-tight">
{pipe.title}
</div>
- <div className="text-[10px] text-muted-foreground leading-tight line-clamp-1">
+ <div className="text-[10px] text-muted-foreground group-hover:text-background/60 leading-tight line-clamp-1">
{pipe.description}
</div>
</button>
@@ -154,13 +187,13 @@ export function SummaryCards({
tabIndex={0}
onClick={() => handleCustomTemplateClick(ct)}
onKeyDown={(e) => e.key === "Enter" && handleCustomTemplateClick(ct)}
- className="group text-left p-2 rounded-lg border border-border/30 bg-muted/10 hover:bg-muted/40 hover:border-border/60 transition-all duration-150 cursor-pointer relative"
+ className="group text-left p-2 border border-border/30 bg-muted/10 hover:bg-foreground hover:text-background hover:border-foreground transition-all duration-150 cursor-pointer relative"
>
<div className="text-sm mb-0.5">{"\u{1F4CC}"}</div>
- <div className="text-[11px] font-medium text-foreground group-hover:text-foreground mb-0.5 leading-tight">
+ <div className="text-[11px] font-medium group-hover:text-background mb-0.5 leading-tight">
{ct.title}
</div>
- <div className="text-[10px] text-muted-foreground leading-tight line-clamp-1">
+ <div className="text-[10px] text-muted-foreground group-hover:text-background/60 leading-tight line-clamp-1">
{ct.description || ct.timeRange}
</div>
<button
@@ -168,7 +201,7 @@ export function SummaryCards({
e.stopPropagation();
onDeleteCustomTemplate(ct.id);
}}
- className="absolute top-1.5 right-1.5 opacity-0 group-hover:opacity-100 p-1 rounded-md hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-all"
+ className="absolute top-1.5 right-1.5 opacity-0 group-hover:opacity-100 p-1 hover:bg-background/20 text-background transition-all"
title="Delete template"
>
<Plus className="w-3 h-3 rotate-45" />
@@ -179,26 +212,57 @@ export function SummaryCards({
</div>
)}
- {/* Dynamic AI suggestions */}
- {autoSuggestions.length > 0 && (
- <div className="w-full max-w-lg">
- <div className="text-[10px] text-muted-foreground/60 uppercase tracking-wider font-medium mb-1.5 px-1">
+ {/* ─── Dynamic AI suggestions ─────────────────────────────────────────── */}
+ <div className="w-full max-w-lg">
+ <div className="flex items-center justify-between mb-1.5 px-1">
+ <span className="text-[10px] text-muted-foreground/60 uppercase tracking-wider font-medium font-mono">
based on your activity
- </div>
+ </span>
+ {onRefreshSuggestions && (
+ <button
+ onClick={onRefreshSuggestions}
+ disabled={suggestionsRefreshing}
+ className="group flex items-center gap-1 text-[10px] text-muted-foreground/40 hover:text-foreground font-mono uppercase tracking-wider transition-colors duration-150 disabled:opacity-30"
+ title="refresh suggestions"
+ >
+ <RefreshCw
+ className={`w-3 h-3 transition-transform duration-150 ${
+ suggestionsRefreshing ? "animate-spin" : "group-hover:rotate-45"
+ }`}
+ strokeWidth={1.5}
+ />
+ <span className="hidden sm:inline">
+ {suggestionsRefreshing ? "generating" : "refresh"}
+ </span>
+ </button>
+ )}
+ </div>
+
+ {/* Skeleton while refreshing */}
+ {suggestionsRefreshing ? (
+ <SuggestionSkeleton />
+ ) : (
<div className="flex flex-wrap gap-1.5">
- {autoSuggestions.slice(0, 4).map((s, i) => (
- <button
- key={i}
- type="button"
- onClick={() => onSendMessage(s.text)}
- className="px-2.5 py-1 text-[11px] bg-muted/20 hover:bg-muted/50 rounded-full border border-border/20 hover:border-border/50 text-muted-foreground hover:text-foreground transition-colors cursor-pointer"
- >
- {s.text}
- </button>
- ))}
+ <AnimatePresence mode="popLayout">
+ {autoSuggestions.slice(0, 4).map((s, i) => (
+ <motion.button
+ key={s.text}
+ layout
+ initial={{ opacity: 0, y: 4 }}
+ animate={{ opacity: 1, y: 0 }}
+ exit={{ opacity: 0, y: -4 }}
+ transition={{ duration: 0.15, delay: i * 0.04 }}
+ type="button"
+ onClick={() => onSendMessage(s.text)}
+ className="px-2.5 py-1 font-mono text-[11px] bg-muted/20 hover:bg-foreground hover:text-background border border-border/20 hover:border-foreground text-muted-foreground transition-all duration-150 cursor-pointer"
+ >
+ {s.text}
+ </motion.button>
+ ))}
+ </AnimatePresence>
</div>
- </div>
- )}
+ )}
+ </div>
{/* Custom Summary Builder modal */}
{showBuilder && (
diff --git a/apps/screenpipe-app-tauri/components/standalone-chat.tsx b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
index e2a8182d9..54d8f067e 100644
--- a/apps/screenpipe-app-tauri/components/standalone-chat.tsx
+++ b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
@@ -663,7 +663,11 @@ export function StandaloneChat({ className }: { className?: string } = {}) {
const { settings, updateSettings, isSettingsLoaded, reloadStore } = useSettings();
const { isMac } = usePlatform();
const { items: appItems } = useSqlAutocomplete("app");
- const { suggestions: autoSuggestions } = useAutoSuggestions();
+ const {
+ suggestions: autoSuggestions,
+ refreshing: suggestionsRefreshing,
+ forceRefresh: refreshSuggestions,
+ } = useAutoSuggestions();
const { templatePipes, loading: pipesLoading } = usePipes();
// Custom summary templates (persisted in settings)
@@ -2969,6 +2973,8 @@ export function StandaloneChat({ className }: { className?: string } = {}) {
<SummaryCards
onSendMessage={sendMessage}
autoSuggestions={autoSuggestions}
+ suggestionsRefreshing={suggestionsRefreshing}
+ onRefreshSuggestions={refreshSuggestions}
customTemplates={customTemplates}
onSaveCustomTemplate={saveCustomTemplate}
onDeleteCustomTemplate={deleteCustomTemplate}
@@ -3266,18 +3272,25 @@ export function StandaloneChat({ className }: { className?: string } = {}) {
</AnimatePresence>
{/* Auto-suggestions above input */}
- {messages.length > 0 && !isLoading && autoSuggestions.length > 0 && (
+ {!isLoading && autoSuggestions.length > 0 && (
<div className="px-3 pt-2 flex flex-wrap gap-1.5">
- {autoSuggestions.slice(0, 3).map((s, i) => (
- <button
- key={i}
- type="button"
- onClick={() => sendMessage(s.text)}
- className="px-2.5 py-1 text-[11px] bg-muted/20 hover:bg-muted/50 rounded-full border border-border/20 hover:border-border/50 text-muted-foreground hover:text-foreground transition-colors cursor-pointer"
- >
- {s.text}
- </button>
- ))}
+ <AnimatePresence mode="popLayout">
+ {autoSuggestions.slice(0, 3).map((s, i) => (
+ <motion.button
+ key={s.text}
+ layout
+ initial={{ opacity: 0, scale: 0.95 }}
+ animate={{ opacity: 1, scale: 1 }}
+ exit={{ opacity: 0, scale: 0.95 }}
+ transition={{ duration: 0.15, delay: i * 0.03 }}
+ type="button"
+ onClick={() => sendMessage(s.text)}
+ className="px-2.5 py-1 font-mono text-[11px] bg-muted/20 hover:bg-foreground hover:text-background border border-border/20 hover:border-foreground text-muted-foreground transition-all duration-150 cursor-pointer"
+ >
+ {s.text}
+ </motion.button>
+ ))}
+ </AnimatePresence>
</div>
)}
diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-auto-suggestions.ts b/apps/screenpipe-app-tauri/lib/hooks/use-auto-suggestions.ts
index 5e6c48717..7abeedfee 100644
--- a/apps/screenpipe-app-tauri/lib/hooks/use-auto-suggestions.ts
+++ b/apps/screenpipe-app-tauri/lib/hooks/use-auto-suggestions.ts
@@ -11,7 +11,7 @@ export interface Suggestion {
text: string;
}
-type ActivityMode =
+export type ActivityMode =
| "coding"
| "browsing"
| "meeting"
@@ -27,31 +27,61 @@ export function useAutoSuggestions() {
const [mode, setMode] = useState<ActivityMode>("idle");
const [tags, setTags] = useState<string[]>([]);
const [loading, setLoading] = useState(true);
+ const [refreshing, setRefreshing] = useState(false);
const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);
+ const prevTextsRef = useRef<string>("");
+ const applySuggestions = useCallback(
+ (data: { suggestions: Suggestion[]; mode: string; tags?: string[] }) => {
+ const newTexts = data.suggestions.map((s) => s.text).join("|");
+ // Only update state if suggestions actually changed (avoids re-render flicker)
+ if (newTexts !== prevTextsRef.current) {
+ prevTextsRef.current = newTexts;
+ setSuggestions(data.suggestions);
+ }
+ setMode(data.mode as ActivityMode);
+ setTags(data.tags || []);
+ },
+ []
+ );
+
+ // Read from cache (lightweight)
const refresh = useCallback(async () => {
try {
const result = await commands.getCachedSuggestions();
if (result.status === "ok") {
- setSuggestions(result.data.suggestions);
- setMode(result.data.mode as ActivityMode);
- setTags(result.data.tags || []);
+ applySuggestions(result.data);
} else {
throw new Error("failed");
}
} catch {
// Fallback if Tauri command not available yet
setSuggestions([
- { text: "What did I do in the last hour?" },
- { text: "Summarize my day so far" },
- { text: "Which apps did I use most today?" },
+ { text: "what did I do in the last hour?" },
+ { text: "summarize my day so far" },
+ { text: "which apps did I use most today?" },
]);
setMode("idle");
setTags([]);
} finally {
setLoading(false);
}
- }, []);
+ }, [applySuggestions]);
+
+ // Force regenerate (calls AI, bypasses scheduler guards)
+ const forceRefresh = useCallback(async () => {
+ setRefreshing(true);
+ try {
+ const result = await commands.forceRegenerateSuggestions();
+ if (result.status === "ok") {
+ applySuggestions(result.data);
+ }
+ } catch (err) {
+ console.error("force refresh failed:", err);
+ } finally {
+ setRefreshing(false);
+ }
+ }, [applySuggestions]);
useEffect(() => {
refresh();
@@ -61,5 +91,5 @@ export function useAutoSuggestions() {
};
}, [refresh]);
- return { suggestions, mode, tags, loading, refresh };
+ return { suggestions, mode, tags, loading, refreshing, refresh, forceRefresh };
}
diff --git a/apps/screenpipe-app-tauri/lib/utils/tauri.ts b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
index dd436addc..43630400f 100644
--- a/apps/screenpipe-app-tauri/lib/utils/tauri.ts
+++ b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
@@ -883,6 +883,18 @@ async getCachedSuggestions() : Promise<Result<CachedSuggestions, string>> {
else return { status: "error", error: e as any };
}
},
+/**
+ * Force-regenerate suggestions immediately, bypassing the scheduler's
+ * CPU/power guards. Returns the fresh suggestions and updates the cache.
+ */
+async forceRegenerateSuggestions() : Promise<Result<CachedSuggestions, string>> {
+ try {
+ return { status: "ok", data: await TAURI_INVOKE("force_regenerate_suggestions") };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
/**
* Tauri command: validate that a path is usable as a data directory.
* Called from the frontend before saving the setting.
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/apps/screenpipe-app-tauri/src-tauri/src/main.rs
index a2dd4459e..ef3828d25 100755
--- a/apps/screenpipe-app-tauri/src-tauri/src/main.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/main.rs
@@ -1299,6 +1299,7 @@ async fn main() {
voice_training::train_voice,
// Suggestions
suggestions::get_cached_suggestions,
+ suggestions::force_regenerate_suggestions,
// Config commands
config::validate_data_dir,
// Hardware detection
@@ -1536,6 +1537,7 @@ async fn main() {
voice_training::train_voice,
// Suggestions
suggestions::get_cached_suggestions,
+ suggestions::force_regenerate_suggestions,
// Config commands
config::validate_data_dir,
// Hardware detection
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/suggestions.rs b/apps/screenpipe-app-tauri/src-tauri/src/suggestions.rs
index 8855edba3..918151845 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/suggestions.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/suggestions.rs
@@ -64,6 +64,19 @@ pub async fn get_cached_suggestions(
}))
}
+/// Force-regenerate suggestions immediately, bypassing the scheduler's
+/// CPU/power guards. Returns the fresh suggestions and updates the cache.
+#[tauri::command]
+#[specta::specta]
+pub async fn force_regenerate_suggestions(
+ state: tauri::State<'_, SuggestionsState>,
+) -> Result<CachedSuggestions, String> {
+ let cached = generate_suggestions().await?;
+ let mut guard = state.cache.lock().await;
+ *guard = Some(cached.clone());
+ Ok(cached)
+}
+
// ─── Auto-start ─────────────────────────────────────────────────────────────
/// Auto-start the suggestions scheduler on app launch.