Files
PaperClipAI/ui/src/components/routine-sections/editable-sections.tsx
T
DottaandPaperclip f589660ec0 feat(routines): add safe webhook setup and in-routine run management (#13637)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Routines turn scheduled work and external events into tasks for an
assigned agent.
> - Webhook setup was disabled, and actor authentication rejected valid
webhook bearer keys.
> - Operators need to connect and test a sending app before events can
start work.
> - This pull request adds a guided setup with durable connection tests
that cannot dispatch a task.
> - It keeps trigger management, execution tasks, and activity within
the routine.
> - The benefit is a webhook that can be configured, verified, and
operated from one place.

## Linked Issues or Issue Description

Fixes #11937.

Related: #13216 adds provider-specific Sentry support. This PR addresses
general routine setup and ingress. #6841 addresses legacy secret
bindings; this PR retains the existing secret service.

**Current behavior**

Webhook creation is disabled. Bearer deliveries can fail in agent
authentication before the routine checks its key. Setup has no safe
connection test. Runs and Activity send the operator away from the
routine.

**Proposed behavior**

Choose a schedule or a webhook. Follow the setup steps, copy credentials
or complete agent instructions, and test delivery without creating work.
Finish setup to allow future events to start tasks. Edit or remove
compact trigger cards, undo removal, and inspect tasks and activity
inside the routine.

**Reason and benefit**

An operator can verify credentials and delivery before enabling
automatic work. Durable setup state survives refreshes and restarts.
Retry receipts prevent an old test event from starting work after
activation.

## What Changed

- Add a production trigger wizard using reusable Slack setup navigation
and footer components.
- Add schedule and webhook choices, one-time credentials, agent
instructions, and live connection feedback.
- Persist pending setup, test delivery receipts, connection status, and
reversible trigger removal.
- Keep setup checks free of routine runs, tasks, and agent wakeups.
Preserve delivery idempotency after activation.
- Add compact trigger cards, inline editing, key rotation, pause
controls, removal, and Undo.
- Keep Runs and Activity in the routine. Use the shared task list and
compact activity rows.
- Permit only exact public delivery POSTs through actor authentication.
Retain webhook authentication, JSON-object validation, and log
redaction.
- Add production-backed Storybook states and focused server, database,
and UI coverage.
- Document signing modes, setup checks, retries, rotation, HTTPS
ingress, and navigation.

## Verification

- Full workspace typecheck, build, and token gates passed on the rebased
branch. Storybook also builds.
- Focused routine, middleware, logging, shared wizard, and UI coverage
passes on the rebased branch: 195 tests across 14 files. The migration
passed on a fresh PostgreSQL database and on two repeated applications.
- Browser testing used the real app, database, and a deterministic
process worker through Tailscale HTTPS and the current Cloud proxy code.
- Verified rejected keys, safe setup deliveries, persisted state after
restart, activation, retry deduplication, key rotation, schedule
editing, removal, and Undo.
- Fresh bearer and GitHub-signed deliveries created tasks that the
worker checked out and completed. Runs and Activity stayed within the
routine.
- Current Cloud ingress tests passed. Public delivery POSTs passed
through without a browser session; management routes remained gated.
- All 54 current-head PR checks pass, including general and serialized
tests, all eight browser E2E shards, typecheck, build, runner checks,
security checks, and the canary dry run. Two optional Storybook jobs are
skipped by workflow conditions.
- Greptile is 5/5 on commit `7ea63a61e`, with no unresolved review
threads. The stale connection-status finding is fixed and covered by a
regression test.
- No production deployment was performed.

## Risks

- Migration 0281 adds three trigger columns and a test-receipt table. It
is additive and safe to reapply. Apply it before running the new server.
Existing triggers remain live by default.
- Requests without delivery IDs are new events after activation. Senders
must reuse an event's delivery ID for retries.
- Completed webhooks keep normal dispatch behavior. Their management
connection check can start work; the UI states this.
- Removing a trigger archives it. Undo restores the URL and credentials.
Permanent deletion remains available through the existing API.
- Public ingress must remain restricted to the delivery POST route. The
tenant verifies credentials. Cloud sleeping-stack behavior is unchanged.
- Shared setup components also serve Slack. Existing setup contracts and
navigation tests cover that integration.
- Senders must use application/json with an object. Other media types
receive 415.

## Model Used

OpenAI Codex, based on GPT-6, with reasoning, repository tools, shell
execution, and browser testing. The exact deployment model ID and
context-window size are not exposed in this session.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-09-19 10:49:05 -05:00

643 lines
23 KiB
TypeScript

import { AgentAvatar } from "@/components/AgentAvatar";
import { useMemo, useState } from "react";
import {
ArrowRight,
Braces,
Clock3,
Edit3,
Play,
X,
} from "lucide-react";
import { Card, CardContent } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { RadioCardGroup } from "@/components/ui/radio-card";
import { cn } from "@/lib/utils";
import { nextCronFires, previewFirePolicies } from "../../lib/cron-fires";
import { timeAgo } from "../../lib/timeAgo";
import { EmptyState } from "../EmptyState";
import { InlineEntitySelector } from "../InlineEntitySelector";
import { DocumentAnnotationsCountChip, IssueDocumentAnnotations } from "../IssueDocumentAnnotations";
import { MarkdownEditor } from "../MarkdownEditor";
import { RoutineVariablesEditor, RoutineVariablesHint } from "../RoutineVariablesEditor";
import { EnvironmentVariablesEditor } from "../environment-variables-editor";
import { useRoutineDetail } from "./context";
import type { EnvBinding, RoutineDetail as RoutineDetailType } from "@paperclipai/shared";
const concurrencyPolicyOptions = [
{
value: "coalesce_if_active",
title: "Coalesce if active",
description: "Keep one follow-up run queued while an active run is still working.",
},
{
value: "always_enqueue",
title: "Always enqueue",
description: "Queue every trigger occurrence, even if several runs stack up.",
},
{
value: "skip_if_active",
title: "Skip if active",
description: "Drop overlapping trigger occurrences while the routine is already active.",
},
];
const catchUpPolicyOptions = [
{
value: "skip_missed",
title: "Skip missed",
description: "Ignore schedule windows that were missed while paused.",
},
{
value: "enqueue_missed_with_cap",
title: "Enqueue missed with cap",
description: "Catch up missed schedule windows after recovery; sub-hourly schedules are combined into one catch-up run, slower schedules replay each missed window up to a cap.",
},
];
const activityGatePolicyOptions = [
{
value: "always",
title: "Run on every scheduled tick",
description: "Fire on the schedule no matter what — the default behavior.",
},
{
value: "require_external_activity",
title: "Skip when there's been no activity since the last run",
description:
"On a scheduled tick, only run if something happened since the last run that finished. Lets a watcher-style routine stay asleep while the system is settled instead of burning tokens.",
},
];
const activityGateScopeOptions = [
{
value: "company",
title: "Organization-wide",
description: "Any activity across the organization counts as a reason to run.",
},
{
value: "project",
title: "This project",
description: "Only activity in the routine's project counts as a reason to run.",
},
];
export function OverviewSection({
defaultDescriptionAnnotationsOpen = false,
}: {
defaultDescriptionAnnotationsOpen?: boolean;
} = {}) {
const ctx = useRoutineDetail();
const {
routine,
editDraft,
setEditDraft,
assigneeOptions,
projectOptions,
recentAssigneeIds,
recentProjectIds,
agentById,
projectById,
currentAssignee,
currentProject,
mentionOptions,
assigneeSelectorRef,
projectSelectorRef,
descriptionEditorRef,
routineRuns,
activity,
saveRoutine,
saveConflict,
isSectionDirty,
navigateToSection,
} = ctx;
const [descriptionAnnotationsOpen, setDescriptionAnnotationsOpen] = useState(defaultDescriptionAnnotationsOpen);
const activeTriggers = routine.triggers.length;
const nextFire = useMemo(() => {
const upcoming = routine.triggers
.filter((trigger) => trigger.kind === "schedule" && trigger.nextRunAt)
.map((trigger) => new Date(trigger.nextRunAt as Date))
.sort((a, b) => a.getTime() - b.getTime())[0];
return upcoming ? upcoming.toLocaleString() : null;
}, [routine.triggers]);
const lastRun = (routineRuns ?? [])[0] ?? null;
const recentActivity = (activity ?? []).slice(0, 5);
return (
<div className="space-y-6">
{/* Assignment row */}
<div className="overflow-x-auto overscroll-x-contain">
<div className="inline-flex min-w-full flex-wrap items-center gap-2 text-sm text-muted-foreground sm:min-w-max sm:flex-nowrap">
<span>For</span>
<InlineEntitySelector
ref={assigneeSelectorRef}
value={editDraft.assigneeAgentId}
options={assigneeOptions}
recentOptionIds={recentAssigneeIds}
placeholder="Responsible"
noneLabel="No responsible"
searchPlaceholder="Search responsible..."
emptyMessage="No responsible found."
onChange={(assigneeAgentId) =>
setEditDraft((current) => ({ ...current, assigneeAgentId }))
}
onConfirm={() => {
if (editDraft.projectId) {
descriptionEditorRef.current?.focus();
} else {
projectSelectorRef.current?.focus();
}
}}
renderTriggerValue={(option) =>
option ? (
currentAssignee ? (
<>
<AgentAvatar agent={currentAssignee} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/>
<span className="truncate">{option.label}</span>
</>
) : (
<span className="truncate">{option.label}</span>
)
) : (
<span className="text-muted-foreground">Responsible</span>
)
}
renderOption={(option) => {
if (!option.id) return <span className="truncate">{option.label}</span>;
const assignee = agentById.get(option.id);
return (
<>
{assignee ? (
<AgentAvatar agent={assignee} size={16} className="h-3.5 w-3.5 shrink-0 text-muted-foreground"/>
) : null}
<span className="truncate">{option.label}</span>
</>
);
}}
/>
<span>in</span>
<InlineEntitySelector
ref={projectSelectorRef}
value={editDraft.projectId}
options={projectOptions}
recentOptionIds={recentProjectIds}
placeholder="Project"
noneLabel="No project"
searchPlaceholder="Search projects..."
emptyMessage="No projects found."
onChange={(projectId) => setEditDraft((current) => ({ ...current, projectId }))}
onConfirm={() => descriptionEditorRef.current?.focus()}
renderTriggerValue={(option) =>
option && currentProject ? (
<>
<span
className="h-3.5 w-3.5 shrink-0 rounded-sm"
style={{ backgroundColor: currentProject.color ?? "var(--project-none)" }}
/>
<span className="truncate">{option.label}</span>
</>
) : (
<span className="text-muted-foreground">Project</span>
)
}
renderOption={(option) => {
if (!option.id) return <span className="truncate">{option.label}</span>;
const project = projectById.get(option.id);
return (
<>
<span
className="h-3.5 w-3.5 shrink-0 rounded-sm"
style={{ backgroundColor: project?.color ?? "var(--project-none)" }}
/>
<span className="truncate">{option.label}</span>
</>
);
}}
/>
</div>
</div>
{!routine.assigneeAgentId ? (
<div className="rounded-lg border border-amber-500/30 bg-amber-500/5 p-4 text-sm text-amber-900 dark:text-amber-200">
Default agent required. This routine can stay as a draft and still run manually, but
automation stays paused until you assign a default agent.
</div>
) : null}
{/* Instructions */}
<div className="space-y-2">
<div className="flex items-center justify-end">
{routine.descriptionDocument ? (
<DocumentAnnotationsCountChip
issueId={routine.id}
docKey="description"
target={{ kind: "routine", routineId: routine.id, documentKey: "description" }}
panelOpen={descriptionAnnotationsOpen}
onToggle={() => setDescriptionAnnotationsOpen((open) => !open)}
/>
) : null}
</div>
{routine.descriptionDocument ? (
<IssueDocumentAnnotations
issueId={routine.id}
doc={routine.descriptionDocument}
target={{ kind: "routine", routineId: routine.id, documentKey: "description" }}
bodyMarkdown={editDraft.description}
draftDirty={isSectionDirty("overview") || saveRoutine.isPending}
draftConflicted={saveConflict}
historicalPreview={false}
locationHash={typeof window === "undefined" ? "" : window.location.hash}
panelOpen={descriptionAnnotationsOpen}
onPanelOpenChange={setDescriptionAnnotationsOpen}
>
<MarkdownEditor
ref={descriptionEditorRef}
value={editDraft.description}
onChange={(description) => setEditDraft((current) => ({ ...current, description }))}
placeholder="Add instructions..."
bordered={false}
contentClassName="min-h-(--sz-120px) text-sm leading-7"
mentions={mentionOptions}
onSubmit={() => {
if (!saveRoutine.isPending && editDraft.title.trim()) {
saveRoutine.mutate();
}
}}
/>
</IssueDocumentAnnotations>
) : (
<MarkdownEditor
ref={descriptionEditorRef}
value={editDraft.description}
onChange={(description) => setEditDraft((current) => ({ ...current, description }))}
placeholder="Add instructions..."
bordered={false}
contentClassName="min-h-(--sz-120px) text-sm leading-7"
mentions={mentionOptions}
onSubmit={() => {
if (!saveRoutine.isPending && editDraft.title.trim()) {
saveRoutine.mutate();
}
}}
/>
)}
</div>
{/* Variables peek */}
<div className="space-y-3">
<RoutineVariablesHint />
<RoutineVariablesEditor
title={editDraft.title}
description={editDraft.description}
value={editDraft.variables}
onChange={(variables) => setEditDraft((current) => ({ ...current, variables }))}
/>
</div>
{/* Summary cards */}
<div className="grid gap-3 sm:grid-cols-2">
<SummaryCard
icon={Clock3}
label="Triggers"
value={activeTriggers === 0 ? "None" : `${activeTriggers} active`}
hint={nextFire ? `Next fire ${nextFire}` : "No schedule"}
to={() => navigateToSection("triggers")}
ariaLabel={`${activeTriggers} triggers. Open triggers.`}
/>
<SummaryCard
icon={Play}
label="Last run"
value={lastRun ? lastRun.status.replaceAll("_", " ") : "No runs"}
hint={lastRun ? timeAgo(lastRun.triggeredAt) : "Trigger a run"}
to={() => navigateToSection("runs")}
ariaLabel={lastRun ? `Last run ${lastRun.status}. Open runs.` : "No runs. Open runs."}
/>
</div>
{/* Recent activity */}
<div className="space-y-2">
<p className="text-xs font-medium uppercase tracking-wide text-muted-foreground">
Recent activity
</p>
{recentActivity.length === 0 ? (
<p className="text-xs text-muted-foreground">No activity yet.</p>
) : (
<div className="divide-y divide-border/60">
{recentActivity.map((event) => (
<div key={event.id} className="flex items-center gap-2 py-1.5 text-xs">
<Badge variant="outline" className="shrink-0 font-mono">
{event.action}
</Badge>
<span className="min-w-0 flex-1 truncate text-muted-foreground">
{event.details && Object.keys(event.details).length > 0
? Object.keys(event.details).slice(0, 3).join(" · ")
: ""}
</span>
<span className="shrink-0 text-muted-foreground/60">{timeAgo(event.createdAt)}</span>
</div>
))}
<button
type="button"
onClick={() => navigateToSection("activity")}
className="flex items-center gap-1 pt-2 text-xs text-muted-foreground hover:text-foreground"
>
View all activity <ArrowRight className="h-3 w-3" />
</button>
</div>
)}
</div>
</div>
);
}
function SummaryCard({
icon: Icon,
label,
value,
hint,
to,
ariaLabel,
}: {
icon: typeof Clock3;
label: string;
value: string;
hint: string;
to: () => void;
ariaLabel: string;
}) {
return (
<button type="button" onClick={to} aria-label={ariaLabel} className="text-left">
<Card className="gap-2 p-4 transition-colors hover:border-border hover:bg-accent/30">
<CardContent className="space-y-1 p-0">
<div className="flex items-center gap-1.5 text-xs uppercase tracking-wide text-muted-foreground">
<Icon className="h-3.5 w-3.5" />
{label}
<ArrowRight className="ml-auto h-3.5 w-3.5 text-muted-foreground/60" />
</div>
<p className="text-lg font-semibold">{value}</p>
<p className="text-xs text-muted-foreground">{hint}</p>
</CardContent>
</Card>
</button>
);
}
export { RoutineTriggers as TriggersSection } from "../routine-triggers/RoutineTriggers";
export function VariablesSection() {
const ctx = useRoutineDetail();
const { editDraft, setEditDraft, navigateToSection } = ctx;
const hasVariables = editDraft.variables.length > 0;
return (
<div className="space-y-4">
<div className="flex items-center gap-3 rounded-md border border-border bg-muted/20 px-4 py-3 text-xs">
<span className="flex-1 text-muted-foreground">
Variables are auto-detected from <code className="font-mono">{"{{placeholders}}"}</code> in
the title &amp; instructions. The variable name is read-only — rename by editing the
placeholder.
</span>
<Button variant="secondary" size="sm" onClick={() => navigateToSection("overview")}>
<Edit3 className="mr-1.5 h-3.5 w-3.5" />
Edit instructions
</Button>
</div>
{hasVariables ? (
<RoutineVariablesEditor
title={editDraft.title}
description={editDraft.description}
value={editDraft.variables}
onChange={(variables) => setEditDraft((current) => ({ ...current, variables }))}
/>
) : (
<EmptyState
icon={Braces}
message="No variables yet. Add a {{placeholder}} in the title or instructions to create one."
action="Edit instructions"
onAction={() => navigateToSection("overview")}
/>
)}
</div>
);
}
export function SecretsSection() {
const ctx = useRoutineDetail();
const { editDraft, setEditDraft, availableSecrets, createSecret } = ctx;
// Project/company-scoped secrets that already see real usage, surfaced as
// quick-bind chips (§3.4). Ranked by reference count then recency.
const recentlyUsedSecrets = useMemo(
() =>
[...availableSecrets]
.filter((secret) => secret.status === "active")
.sort((a, b) => {
const refDelta = (b.referenceCount ?? 0) - (a.referenceCount ?? 0);
if (refDelta !== 0) return refDelta;
return new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime();
})
.slice(0, 8),
[availableSecrets],
);
return (
<div className="space-y-4">
<div className="rounded-md border border-border bg-muted/20 px-4 py-3 text-xs text-muted-foreground">
Routine secrets apply to every task this routine creates. They override matching keys in
project and agent env. <span className="font-mono">PAPERCLIP_*</span> names are reserved.
</div>
<EnvironmentVariablesEditor
value={(editDraft.env ?? {}) as Record<string, EnvBinding>}
secrets={availableSecrets}
recentlyUsedSecrets={recentlyUsedSecrets}
onCreateSecret={async (name, value) => createSecret.mutateAsync({ name, value })}
onChange={(env) => setEditDraft((current) => ({ ...current, env: env ?? null }))}
/>
</div>
);
}
export function DeliverySection() {
const ctx = useRoutineDetail();
const { editDraft, setEditDraft, routine } = ctx;
// The activity gate only affects schedule ticks (webhook/manual/API fires are
// themselves activity and always run), so the control is only meaningful for
// routines that have a schedule trigger. Disable — rather than hide — it
// elsewhere so the capability stays discoverable.
const hasScheduleTrigger = routine.triggers.some((trigger) => trigger.kind === "schedule");
const gateEnabled = editDraft.activityGatePolicy === "require_external_activity";
return (
<div className="space-y-6">
<div className="space-y-3">
<p className="text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground">
Concurrency
</p>
<RadioCardGroup
ariaLabel="Concurrency policy"
value={editDraft.concurrencyPolicy}
onValueChange={(concurrencyPolicy) =>
setEditDraft((current) => ({ ...current, concurrencyPolicy }))
}
options={concurrencyPolicyOptions}
/>
</div>
<div className="space-y-3">
<p className="text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground">
Catch-up
</p>
<RadioCardGroup
ariaLabel="Catch-up policy"
value={editDraft.catchUpPolicy}
onValueChange={(catchUpPolicy) =>
setEditDraft((current) => ({ ...current, catchUpPolicy }))
}
options={catchUpPolicyOptions}
/>
</div>
<div className="space-y-3">
<p className="text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground">
Advanced run policy
</p>
<RadioCardGroup
ariaLabel="Advanced run policy"
value={editDraft.activityGatePolicy}
onValueChange={(activityGatePolicy) =>
setEditDraft((current) => ({ ...current, activityGatePolicy }))
}
options={activityGatePolicyOptions}
disabled={!hasScheduleTrigger}
/>
{!hasScheduleTrigger ? (
<p className="text-xs text-muted-foreground">
Add a schedule trigger to gate runs on activity. Webhook, manual, and API fires always
run.
</p>
) : gateEnabled ? (
<div className="space-y-2 rounded-lg border border-border p-3">
<Label className="text-xs font-medium">Activity scope</Label>
<RadioCardGroup
ariaLabel="Activity gate scope"
value={editDraft.activityGateScope}
onValueChange={(activityGateScope) =>
setEditDraft((current) => ({ ...current, activityGateScope }))
}
options={activityGateScopeOptions}
/>
</div>
) : null}
</div>
<NextFiresPreview
triggers={routine.triggers}
concurrencyPolicy={editDraft.concurrencyPolicy}
/>
</div>
);
}
const dispositionToneClass: Record<string, string> = {
queued: "text-emerald-600 dark:text-emerald-400",
coalesced: "text-amber-600 dark:text-amber-400",
skipped: "text-muted-foreground",
};
/**
* "Next 5 fires" preview (§3.5) — the strongest "what does this policy mean?"
* surface. Picks the soonest-firing schedule trigger, computes its next fires
* client-side, and annotates each with how the chosen concurrency policy would
* treat it.
*/
function NextFiresPreview({
triggers,
concurrencyPolicy,
}: {
triggers: RoutineDetailType["triggers"];
concurrencyPolicy: string;
}) {
const preview = useMemo(() => {
const schedule = triggers
.filter((trigger) => trigger.kind === "schedule" && trigger.enabled && trigger.cronExpression)
.map((trigger) => {
const fires = nextCronFires(trigger.cronExpression, 5, {
timeZone: trigger.timezone ?? "UTC",
});
return { trigger, fires };
})
.filter((entry) => entry.fires.length > 0)
.sort((a, b) => a.fires[0]!.getTime() - b.fires[0]!.getTime())[0];
if (!schedule) return null;
return {
timeZone: schedule.trigger.timezone ?? "UTC",
entries: previewFirePolicies(schedule.fires, concurrencyPolicy),
};
}, [triggers, concurrencyPolicy]);
return (
<div className="space-y-3">
<p className="text-xs font-medium uppercase tracking-(--tracking-caps) text-muted-foreground">
Next 5 fires
</p>
{preview ? (
<>
<div className="space-y-1.5 rounded-lg border border-border p-3 font-mono text-xs">
{preview.entries.map((entry, index) => (
<div key={index} className="flex items-center gap-2">
<span className="text-muted-foreground/40">·</span>
<span className="tabular-nums">{formatFireTime(entry.at, preview.timeZone)}</span>
<ArrowRight className="h-3 w-3 shrink-0 text-muted-foreground/50" />
<span className={cn("font-medium", dispositionToneClass[entry.disposition])}>
{entry.label}
</span>
{entry.note ? (
<span className="truncate text-muted-foreground/60">({entry.note})</span>
) : null}
</div>
))}
</div>
<p className="text-(length:--text-micro) text-muted-foreground/60">
Preview assumes the previous run is still in flight when the next fires. Times shown in{" "}
{preview.timeZone}.
</p>
</>
) : (
<p className="rounded-lg border border-dashed border-border p-3 text-xs text-muted-foreground">
No enabled schedule trigger to preview. Add a schedule in Triggers to see how this policy
treats upcoming fires.
</p>
)}
</div>
);
}
function formatFireTime(date: Date, timeZone: string): string {
try {
return new Intl.DateTimeFormat(undefined, {
timeZone,
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
hourCycle: "h23",
})
.format(date)
.replace(",", "");
} catch {
return date.toISOString();
}
}