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(pipes): use the real schedule builder in the trigger modal (#4514)

Louis Beaumont6b22e6250b8c
diff --git a/apps/screenpipe-app-tauri/components/settings/pipe-trigger-picker.tsx b/apps/screenpipe-app-tauri/components/settings/pipe-trigger-picker.tsx
index 0a5612663..cc6967036 100644
--- a/apps/screenpipe-app-tauri/components/settings/pipe-trigger-picker.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/pipe-trigger-picker.tsx
@@ -6,10 +6,11 @@
import React, { useEffect, useMemo, useState } from "react";
import { Dialog, DialogContent } from "@/components/ui/dialog";
import { localFetch } from "@/lib/api";
-import { commands } from "@/lib/utils/tauri";
import { open as openDialog } from "@tauri-apps/plugin-dialog";
import { notifyConnectionsUpdated } from "@/lib/connections-events";
import { IntegrationIcon } from "@/components/settings/connections-section";
+import { PipeScheduleBuilder } from "./pipe-schedule-builder";
+import type { ScheduleConfig } from "@/lib/utils/schedule-builder";
import type { AvailableConnection } from "@/lib/pipe-connections";
import { Plus, Search, Clock, CalendarClock, Workflow, Loader2, Check } from "lucide-react";
@@ -29,13 +30,15 @@ export interface Trigger {
interface PickerProps {
pipeName: string;
trigger?: Trigger;
- schedule?: string;
+ apiBase: string;
+ scheduleConfig: ScheduleConfig | null;
+ scheduleString: string;
otherPipes: { name: string }[];
availableConnections: AvailableConnection[];
refreshConnections: () => Promise<AvailableConnection[]>;
fetchPipes: () => void;
applyOptimistic: (trigger: Trigger | undefined) => void;
- applySchedule: (schedule: string) => void;
+ onSaveSchedule: (cfg: ScheduleConfig | null) => void;
}
// ── shared brand-aligned classes (DESIGN.md: sharp corners, grayscale only) ───
@@ -124,9 +127,9 @@ export function PipeTriggerPicker(props: PickerProps) {
return (
<div>
- <div className="flex items-center gap-1.5 mb-2">
- <span className="text-xs font-medium">triggers</span>
- <span className="text-[10px] text-muted-foreground">run this pipe when something happens</span>
+ <div className="mb-2.5">
+ <div className="text-sm font-medium lowercase">when to run</div>
+ <div className="text-[11px] text-muted-foreground">on a schedule, after a meeting, on a new message…</div>
</div>
<div className="space-y-1.5">
{events.map((e, i) => (
@@ -178,11 +181,13 @@ export function PipeTriggerPicker(props: PickerProps) {
// ── modal (two panes) ────────────────────────────────────────────────────────
function TriggerModal({
- schedule,
+ apiBase,
+ scheduleConfig,
+ scheduleString,
otherPipes,
availableConnections,
refreshConnections,
- applySchedule,
+ onSaveSchedule,
onClose,
onAddSource,
onAddEvent,
@@ -256,14 +261,16 @@ function TriggerModal({
<Detail
key={active.id}
option={active}
- schedule={schedule}
+ apiBase={apiBase}
+ scheduleConfig={scheduleConfig}
+ scheduleString={scheduleString}
otherPipes={otherPipes}
availableConnections={availableConnections}
refreshConnections={refreshConnections}
onClose={onClose}
onAddSource={onAddSource}
onAddEvent={onAddEvent}
- applySchedule={applySchedule}
+ onSaveSchedule={onSaveSchedule}
/>
</div>
</div>
@@ -274,24 +281,28 @@ function TriggerModal({
function Detail({
option,
- schedule,
+ apiBase,
+ scheduleConfig,
+ scheduleString,
otherPipes,
availableConnections,
refreshConnections,
onClose,
onAddSource,
onAddEvent,
- applySchedule,
+ onSaveSchedule,
}: {
option: Option;
- schedule?: string;
+ apiBase: string;
+ scheduleConfig: ScheduleConfig | null;
+ scheduleString: string;
otherPipes: { name: string }[];
availableConnections: AvailableConnection[];
refreshConnections: () => Promise<AvailableConnection[]>;
onClose: () => void;
onAddSource: (s: TriggerSource) => void;
onAddEvent: (e: string) => void;
- applySchedule: (s: string) => void;
+ onSaveSchedule: (cfg: ScheduleConfig | null) => void;
}) {
return (
<div className="h-full flex flex-col">
@@ -300,7 +311,15 @@ function Detail({
<span className="text-sm font-medium">{detailTitle(option.id)}</span>
</div>
<div className="flex-1 overflow-y-auto px-5 py-4">
- {option.id === "schedule" && <ScheduleDetail schedule={schedule} onSave={(s) => { applySchedule(s); onClose(); }} />}
+ {option.id === "schedule" && (
+ <PipeScheduleBuilder
+ current={scheduleConfig}
+ currentScheduleString={scheduleString}
+ apiBase={apiBase}
+ onSave={(cfg) => { onSaveSchedule(cfg); onClose(); }}
+ onCancel={onClose}
+ />
+ )}
{(option.id === "meeting_started" || option.id === "meeting_ended") && (
<SimpleDetail
text={option.id === "meeting_started" ? "Runs whenever screenpipe detects a call starting." : "Runs whenever a call wraps up — great for summaries."}
@@ -314,6 +333,7 @@ function Detail({
availableConnections={availableConnections}
refreshConnections={refreshConnections}
onAdd={onAddSource}
+ onClose={onClose}
/>
)}
</div>
@@ -350,35 +370,6 @@ function SimpleDetail({ text, onAdd }: { text: string; onAdd: () => void }) {
);
}
-function ScheduleDetail({ schedule, onSave }: { schedule?: string; onSave: (s: string) => void }) {
- const presets = [
- { v: "every 30m", l: "every 30 minutes" },
- { v: "every 1h", l: "hourly" },
- { v: "every day at 9am", l: "daily at 9am" },
- { v: "every monday at 9am", l: "weekly (mon 9am)" },
- ];
- const [val, setVal] = useState(schedule && schedule !== "manual" ? schedule : "every 1h");
- return (
- <div>
- <p className="text-xs text-muted-foreground mb-3">Run this pipe on a clock — independent of any app.</p>
- <div className="grid grid-cols-2 gap-2 mb-3">
- {presets.map((p) => (
- <button
- key={p.v}
- onClick={() => setVal(p.v)}
- className={`text-xs border rounded-none px-3 py-2 text-left transition-colors ${val === p.v ? "border-foreground bg-accent" : "hover:bg-accent/60"}`}
- >
- {p.l}
- </button>
- ))}
- </div>
- <label className={LABEL}>custom (interval or cron)</label>
- <input value={val} onChange={(e) => setVal(e.target.value)} placeholder="every 15m · 0 9 * * 1-5" className={`${INPUT} mt-1`} />
- <PrimaryAdd disabled={!val.trim()} onClick={() => onSave(val.trim())} label="set schedule" />
- </div>
- );
-}
-
function PipeDetail({ pipes, onAdd }: { pipes: { name: string }[]; onAdd: (name: string) => void }) {
const [name, setName] = useState("");
if (!pipes.length) return <p className="text-xs text-muted-foreground">No other enabled pipes yet — create one first.</p>;
@@ -414,11 +405,13 @@ function SourceDetail({
availableConnections,
refreshConnections,
onAdd,
+ onClose,
}: {
app: "slack" | "notion" | "obsidian";
availableConnections: AvailableConnection[];
refreshConnections: () => Promise<AvailableConnection[]>;
onAdd: (s: TriggerSource) => void;
+ onClose: () => void;
}) {
const [conns, setConns] = useState(availableConnections);
const connected = !!conns.find((c) => c.id === app)?.connected;
@@ -429,9 +422,10 @@ function SourceDetail({
useEffect(() => setConns(availableConnections), [availableConnections]);
async function doConnect() {
- setConnecting(true);
- try {
- if (app === "obsidian") {
+ // Obsidian is local — pick a vault folder inline.
+ if (app === "obsidian") {
+ setConnecting(true);
+ try {
const picked = await openDialog({ directory: true, multiple: false, title: "Select Obsidian vault folder" });
if (typeof picked !== "string") return;
await localFetch("/connections/obsidian", {
@@ -439,17 +433,20 @@ function SourceDetail({
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ credentials: { vault_path: picked } }),
});
- } else {
- const res = await commands.oauthConnect(app, null, null);
- if (res.status !== "ok" || !res.data.connected) return;
+ notifyConnectionsUpdated();
+ setConns(await refreshConnections());
+ } catch (e) {
+ console.error("connect failed", e);
+ } finally {
+ setConnecting(false);
}
- notifyConnectionsUpdated();
- setConns(await refreshConnections());
- } catch (e) {
- console.error("connect failed", e);
- } finally {
- setConnecting(false);
+ return;
}
+ // Slack/Notion OAuth needs scope-variant + account selection (read access,
+ // not the send-only default) — hand off to the full Connections flow rather
+ // than reimplement it here. Reopen this picker once connected.
+ onClose();
+ window.dispatchEvent(new CustomEvent("open-settings", { detail: { section: "connections" } }));
}
if (!connected) return <ConnectCard app={app} connecting={connecting} onConnect={doConnect} />;
diff --git a/apps/screenpipe-app-tauri/components/settings/pipes-section.tsx b/apps/screenpipe-app-tauri/components/settings/pipes-section.tsx
index fc265c668..1728cc8c1 100644
--- a/apps/screenpipe-app-tauri/components/settings/pipes-section.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/pipes-section.tsx
@@ -64,7 +64,6 @@ import { ChatPrefillData } from "@/lib/chat-utils";
import { commands } from "@/lib/utils/tauri";
import { cn } from "@/lib/utils";
import { describeSchedule, type ScheduleConfig } from "@/lib/utils/schedule-builder";
-import { PipeScheduleBuilder } from "./pipe-schedule-builder";
import {
PipeActivityIndicator,
formatPipeElapsed,
@@ -949,79 +948,6 @@ function pipeScheduleLabel(config: PipeConfig): string {
return describeSchedule(config.schedule_config ?? null, config.schedule);
}
-/** Schedule control: a popover trigger showing the current cadence that opens
- * the Notion-style {@link PipeScheduleBuilder}. Saves the structured
- * `schedule_config` (the engine runs it; the legacy `schedule` is parked at
- * "manual"). */
-function PipeScheduleControls({
- pipe,
- setPipes,
- fetchPipes,
- pendingConfigSaves,
- apiBase,
-}: {
- pipe: { config: PipeConfig };
- setPipes: React.Dispatch<React.SetStateAction<any[]>>;
- fetchPipes: () => void;
- pendingConfigSaves: React.MutableRefObject<Record<string, Promise<void>>>;
- apiBase: string;
-}) {
- const [open, setOpen] = useState(false);
-
- const saveScheduleConfig = (cfg: ScheduleConfig | null) => {
- const pipeName = pipe.config.name;
- setPipes((prev: any[]) =>
- prev.map((p: any) =>
- p.config.name === pipeName
- ? { ...p, config: { ...p.config, schedule_config: cfg, schedule: "manual" } }
- : p
- )
- );
- const savePromise = fetch(`${apiBase}/pipes/${pipeName}/config`, {
- method: "POST",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ schedule_config: cfg }),
- })
- .then(async () => {
- await new Promise((r) => setTimeout(r, 500));
- delete pendingConfigSaves.current[pipeName];
- fetchPipes();
- })
- .catch(() => {
- delete pendingConfigSaves.current[pipeName];
- });
- // Register guard so a background fetchPipes never overwrites with stale data.
- pendingConfigSaves.current[pipeName] = savePromise;
- };
-
- const label = pipeHasSchedule(pipe.config) ? pipeScheduleLabel(pipe.config) : "don't run";
-
- return (
- <Popover open={open} onOpenChange={setOpen}>
- <PopoverTrigger asChild>
- <button
- type="button"
- className="mt-1 flex h-8 w-full items-center justify-between gap-2 rounded border border-input bg-background px-2.5 text-xs hover:bg-accent/40"
- >
- <span className="truncate text-left">{label}</span>
- <ChevronDown className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
- </button>
- </PopoverTrigger>
- <PopoverContent align="start" className="w-auto p-2">
- <PipeScheduleBuilder
- current={(pipe.config.schedule_config as ScheduleConfig | null) ?? null}
- currentScheduleString={pipe.config.schedule || "manual"}
- apiBase={apiBase}
- onSave={(cfg) => {
- saveScheduleConfig(cfg);
- setOpen(false);
- }}
- onCancel={() => setOpen(false)}
- />
- </PopoverContent>
- </Popover>
- );
-}
export function PipesSection() {
// Device selector: null = local machine, string = remote address
@@ -2636,33 +2562,48 @@ export function PipesSection() {
{/* ═══ CONFIG TAB ═══ */}
<TabsContent value="config" className="mt-4 space-y-6">
- {/* Model */}
- <PipePresetSelector
- pipe={pipe}
- setPipes={setPipes}
- fetchPipes={fetchPipes}
- pendingConfigSaves={pendingConfigSaves}
+ {/* Triggers — Notion-style picker (schedule, events + per-app connection sources) */}
+ <PipeTriggerPicker
+ pipeName={pipe.config.name}
+ trigger={pipe.config.trigger}
apiBase={apiBase}
+ scheduleConfig={pipe.config.schedule_config ?? null}
+ scheduleString={pipe.config.schedule || "manual"}
+ otherPipes={pipes
+ .filter((p) => p.config.name !== pipe.config.name && p.config.enabled)
+ .map((p) => ({ name: p.config.name }))}
+ availableConnections={availableConnections}
+ refreshConnections={async () => {
+ const next = await fetchAvailablePipeConnections(apiBase, availableConnections);
+ setAvailableConnections(next);
+ return next;
+ }}
+ fetchPipes={fetchPipes}
+ applyOptimistic={(t) =>
+ setPipes((prev) =>
+ prev.map((p) =>
+ p.config.name === pipe.config.name
+ ? { ...p, config: { ...p.config, trigger: t } }
+ : p
+ )
+ )
+ }
+ onSaveSchedule={(cfg) => {
+ setPipes((prev) =>
+ prev.map((p) =>
+ p.config.name === pipe.config.name
+ ? { ...p, config: { ...p.config, schedule_config: cfg, schedule: "manual" } }
+ : p
+ )
+ );
+ localFetch(`/pipes/${pipe.config.name}/config`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ schedule_config: cfg }),
+ }).then(() => fetchPipes());
+ }}
/>
- {/* Schedule */}
- <div>
- <Label className="text-xs flex items-center gap-1.5 mb-1 cursor-help" title={((pipe.config.trigger?.events?.length || 0) + (pipe.config.trigger?.custom?.length || 0)) > 0 ? "runs on this schedule in addition to triggers" : "how often to run this pipe"}>
- schedule
- {((pipe.config.trigger?.events?.length || 0) + (pipe.config.trigger?.custom?.length || 0)) > 0 && pipeHasSchedule(pipe.config) && (
- <span className="text-muted-foreground font-normal">+ triggers</span>
- )}
- </Label>
- <PipeScheduleControls
- pipe={pipe}
- setPipes={setPipes}
- fetchPipes={fetchPipes}
- pendingConfigSaves={pendingConfigSaves}
- apiBase={apiBase}
- />
-
- </div>
-
{/* Connections */}
<div>
<Label className="text-xs mb-2 block cursor-help" title="give the agent access to your apps (Slack, Obsidian, CRM, etc.) — credentials are fetched at runtime">connections</Label>
@@ -2731,55 +2672,16 @@ export function PipesSection() {
</div>
</div>
- {/* Triggers — Notion-style picker (events + per-app connection sources) */}
- <PipeTriggerPicker
- pipeName={pipe.config.name}
- trigger={pipe.config.trigger}
- schedule={pipe.config.schedule}
- otherPipes={pipes
- .filter((p) => p.config.name !== pipe.config.name && p.config.enabled)
- .map((p) => ({ name: p.config.name }))}
- availableConnections={availableConnections}
- refreshConnections={async () => {
- const next = await fetchAvailablePipeConnections(apiBase, availableConnections);
- setAvailableConnections(next);
- return next;
- }}
+
+ {/* Model — secondary; most pipes run fine on the default */}
+ <PipePresetSelector
+ pipe={pipe}
+ setPipes={setPipes}
fetchPipes={fetchPipes}
- applyOptimistic={(t) =>
- setPipes((prev) =>
- prev.map((p) =>
- p.config.name === pipe.config.name
- ? { ...p, config: { ...p.config, trigger: t } }
- : p
- )
- )
- }
- applySchedule={(s) => {
- setPipes((prev) =>
- prev.map((p) =>
- p.config.name === pipe.config.name
- ? { ...p, config: { ...p.config, schedule: s } }
- : p
- )
- );
- localFetch(`/pipes/${pipe.config.name}/config`, {
- method: "POST",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ schedule: s }),
- }).then(() => fetchPipes());
- }}
+ pendingConfigSaves={pendingConfigSaves}
+ apiBase={apiBase}
/>
- {/* Notifications toggle */}
- <div className="flex items-center justify-between border px-3 py-2.5">
- <span className="text-xs font-medium cursor-help" title="allow this pipe to send notifications">notifications</span>
- <Switch
- checked={!isNotificationsDenied(promptDrafts[pipe.config.name] ?? pipe.raw_content)}
- onCheckedChange={(checked) => toggleNotifications(pipe.config.name, checked)}
- />
- </div>
-
</TabsContent>
{/* ═══ RUNS TAB ═══ */}
@@ -2895,6 +2797,15 @@ export function PipesSection() {
{/* ═══ ADVANCED TAB ═══ */}
<TabsContent value="advanced" className="mt-3 space-y-3">
+ {/* Notifications toggle */}
+ <div className="flex items-center justify-between border px-3 py-2.5">
+ <span className="text-xs font-medium cursor-help" title="allow this pipe to send notifications">notifications</span>
+ <Switch
+ checked={!isNotificationsDenied(promptDrafts[pipe.config.name] ?? pipe.raw_content)}
+ onCheckedChange={(checked) => toggleNotifications(pipe.config.name, checked)}
+ />
+ </div>
+
{/* Timeout */}
<div>
<Label className="text-xs mb-2 block cursor-help" title="max execution time before the pipe is killed — increase for slow LLMs or complex pipes">timeout</Label>