fix automation run inputs, hitl routing, and detail UI polish

This commit is contained in:
CREDO23 2026-05-28 02:48:47 +02:00
parent ed8d56aa16
commit 91962ba879
8 changed files with 258 additions and 86 deletions

View file

@ -77,10 +77,8 @@ export function AutomationDetailContent({
<AutomationTriggersSection
triggers={automation.triggers}
automationId={automation.id}
searchSpaceId={searchSpaceId}
canUpdate={perms.canUpdate}
canDelete={perms.canDelete}
canCreate={perms.canCreate}
/>
<AutomationRunsSection automationId={automation.id} />

View file

@ -1,7 +1,5 @@
"use client";
import { CalendarClock, MessageSquarePlus } from "lucide-react";
import Link from "next/link";
import { Button } from "@/components/ui/button";
import { CalendarClock } from "lucide-react";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import type { Trigger } from "@/contracts/types/automation.types";
import { TriggerCard } from "./trigger-card";
@ -9,43 +7,28 @@ import { TriggerCard } from "./trigger-card";
interface AutomationTriggersSectionProps {
triggers: Trigger[];
automationId: number;
searchSpaceId: number;
canUpdate: boolean;
canDelete: boolean;
canCreate: boolean;
}
/**
* The Triggers card. Lists each attached trigger with its own enable
* toggle and remove button. Adding a new trigger is intent-driven (via
* chat) for v1 same philosophy as creating an automation, so the
* empty/add CTA links to a new chat rather than opening a form.
* toggle and remove button. v1 attaches triggers at automation-creation
* time only; there is no in-place "add trigger" affordance here.
*/
export function AutomationTriggersSection({
triggers,
automationId,
searchSpaceId,
canUpdate,
canDelete,
canCreate,
}: AutomationTriggersSectionProps) {
return (
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-4">
<div className="space-y-1">
<CardTitle className="text-base font-semibold">Triggers</CardTitle>
<p className="text-xs text-muted-foreground">
When this automation fires. v1 supports scheduled triggers only.
</p>
</div>
{canCreate && (
<Button asChild variant="outline" size="sm">
<Link href={`/dashboard/${searchSpaceId}/new-chat`}>
<MessageSquarePlus className="mr-2 h-4 w-4" />
Add via chat
</Link>
</Button>
)}
<CardHeader className="pb-4">
<CardTitle className="text-base font-semibold">Triggers</CardTitle>
<p className="text-xs text-muted-foreground">
When this automation fires. v1 supports scheduled triggers only.
</p>
</CardHeader>
<CardContent>
{triggers.length === 0 ? (

View file

@ -7,7 +7,7 @@ import { Button } from "@/components/ui/button";
import { Switch } from "@/components/ui/switch";
import type { Trigger } from "@/contracts/types/automation.types";
import { describeCron } from "@/lib/automations/describe-cron";
import { formatRelativeDate } from "@/lib/format-date";
import { formatRelativeDate, formatRelativeFutureDate } from "@/lib/format-date";
import { DeleteTriggerDialog } from "./delete-trigger-dialog";
interface TriggerCardProps {
@ -91,11 +91,18 @@ export function TriggerCard({ trigger, automationId, canUpdate, canDelete }: Tri
<div className="px-4 py-3 space-y-3 text-xs">
{(trigger.last_fired_at || trigger.next_fire_at) && (
<dl className="grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5">
<dl className="grid grid-cols-[auto_minmax(0,1fr)] items-baseline gap-x-3 gap-y-1">
{trigger.next_fire_at && (
<TimeRow label="Next fire" iso={trigger.next_fire_at} highlight={trigger.enabled} />
<TimeRow
label="Next fire"
iso={trigger.next_fire_at}
tense="future"
highlight={trigger.enabled}
/>
)}
{trigger.last_fired_at && (
<TimeRow label="Last fired" iso={trigger.last_fired_at} tense="past" />
)}
{trigger.last_fired_at && <TimeRow label="Last fired" iso={trigger.last_fired_at} />}
</dl>
)}
@ -126,17 +133,20 @@ export function TriggerCard({ trigger, automationId, canUpdate, canDelete }: Tri
function TimeRow({
label,
iso,
tense,
highlight = false,
}: {
label: string;
iso: string;
tense: "past" | "future";
highlight?: boolean;
}) {
const formatted = tense === "future" ? formatRelativeFutureDate(iso) : formatRelativeDate(iso);
return (
<div className="flex items-baseline gap-2 min-w-0">
<dt className="text-muted-foreground shrink-0 inline-flex items-center gap-1">
<>
<dt className="text-muted-foreground inline-flex items-center gap-1.5 whitespace-nowrap">
<Clock className="h-3 w-3" aria-hidden />
{label}:
{label}
</dt>
<dd
className={
@ -144,9 +154,10 @@ function TimeRow({
? "text-foreground font-medium min-w-0 truncate"
: "text-muted-foreground min-w-0 truncate"
}
title={new Date(iso).toLocaleString()}
>
{formatRelativeDate(iso)}
{formatted}
</dd>
</div>
</>
);
}