Skip to content

Commit 0e48ff2

Browse files
tellahoRizzCarlMongo
authored
feat(workflows): clarify workflow setup and activation (#6470)
**Category:** new-feature **User Impact:** Workflow authors can build filtered, runtime-aware automations, understand them at a glance, and get a clear warning before turning on workflows likely to run often. **Problem:** Workflow setup exposed raw configuration without enough help composing message templates, filtering triggers, or understanding saved behavior; activation could also make a broadly triggered workflow live without explaining its likely frequency. **Solution:** Batch 3 adds local, deterministic template variables, trigger filters, and semantic summaries, then refines cards and activation around configured behavior and a risk-aware warning boundary. Scheduling remains the already-shipped implementation, advanced expressions remain lossless, and network-backed identity/message enrichment stays in Batch 4. | Message inputs | Trigger filters | | --- | --- | | Caret-aware, keyboard-accessible suggestions expose trigger-local values and safe prior-step outputs in `send_message.text`. | Structured conditions and validated manual IDs block invalid submission while preserving advanced expressions. | | ![Message variable autocomplete](https://d24qwcpro867f5.cloudfront.net/repos/buzz/prs/6470/message-variables.png) | ![Structured trigger filters](https://d24qwcpro867f5.cloudfront.net/repos/buzz/prs/6470/trigger-filters.png) | | Workflow cards | Risk-aware activation | | --- | --- | | Semantic labels, channel-first hierarchy, configured reaction/action visuals, real step stacks, and compact status controls make behavior scannable. | Broad message and frequent schedule triggers explain the risk before **Turn on**; narrowly scoped triggers proceed without unnecessary ceremony. | | ![Semantic workflow card](https://d24qwcpro867f5.cloudfront.net/repos/buzz/prs/6470/workflow-card.png) | ![Activation confirmation](https://d24qwcpro867f5.cloudfront.net/repos/buzz/prs/6470/activation-choice-v2.png) | ## Changes <details> <summary>File changes</summary> **desktop/src/features/workflows/ui/WorkflowActionsMenu.tsx** Separates direct card status controls from secondary actions while retaining modal status actions. **desktop/src/features/workflows/ui/WorkflowCard.tsx** Adds semantic behavior, channel-first hierarchy, configured reaction/action visuals, real subsequent-step stacks, status controls, and reduced-motion-aware trigger feedback. **desktop/src/features/workflows/ui/WorkflowDialog.tsx** Warns before activating broadly triggered workflows while allowing narrowly scoped workflows to proceed directly. **desktop/src/features/workflows/ui/WorkflowFormBuilder.tsx** Connects structured trigger filters and template-aware step inputs while preserving schedules, trigger transitions, and selected YAML authority. **desktop/src/features/workflows/ui/WorkflowStepCard.tsx** Replaces generic labels with deterministic configured-step descriptions. **desktop/src/features/workflows/ui/WorkflowTemplateTextarea.tsx** Adds caret-aware variable suggestions with keyboard navigation and focus restoration. **desktop/src/features/workflows/ui/WorkflowTriggerConditions.tsx** Adds structured local filters, validated author/message IDs, and a lossless advanced-expression fallback. **desktop/src/features/workflows/ui/workflowActivationWarning.ts** and **workflowActivationWarning.test.mjs** Classify broad message and frequent schedule triggers for contextual activation warnings. **desktop/src/features/workflows/ui/workflowConditionExpression.ts** and **workflowConditionExpression.test.mjs** Model and cover parsing, serialization, validation, and advanced-expression preservation. **desktop/src/features/workflows/ui/workflowDefinition.ts** and **workflowDefinition.test.mjs** Preserve trigger/step configuration and derive deterministic card metadata across YAML round trips. **desktop/src/features/workflows/ui/workflowStepDescription.ts** and **workflowStepDescription.test.mjs** Generate and cover local step summaries. **desktop/src/features/workflows/ui/workflowTemplateVariables.ts** and **workflowTemplateVariables.test.mjs** Define and cover trigger-specific, order-bounded variables and caret insertion. **desktop/src/features/workflows/ui/workflowTriggerDescription.ts** and **workflowTriggerDescription.test.mjs** Generate and cover semantic trigger summaries without network lookups. **desktop/tests/e2e/workflow-local-controls.spec.ts** and snapshot Cover filters, IDs, advanced expressions, autocomplete, activation choices, summaries, and YAML authority. **desktop/tests/e2e/workflow-reaction-picker.spec.ts** Covers configured reaction emoji in workflow nodes and summaries. **desktop/tests/e2e/workflows.spec.ts** Covers risk-aware activation warnings, direct safe creation, duplication, and card status controls. </details> ## Reproduction steps 1. Create a message-posted workflow in **Workflows**, add a Send message step, and type `{{trig`; verify keyboard-selectable variables insert at the caret. 2. Configure message-text and manual ID filters; verify malformed IDs block submission and advanced expressions survive Form/YAML transitions. 3. Create a broad message workflow; verify **Back** persists nothing, **Keep off** saves it disabled, and **Turn on** enables it. Confirm a narrowly triggered webhook skips the warning. 4. Inspect the saved card; verify its channel, semantic behavior, configured actions/reaction, real step stack, and status are understandable without opening YAML. ## Validation Validated at exact clean head `f99503819889b95ee3c61657c5c3850aae35481e` on base `24ec6a468ec9d0d425ee58fbfc4d416412c446ad`. - Focused workflow regressions passed 59/60 locally; the only local miss was a 438-pixel macOS snapshot drift, while the checked-in Linux baseline comes from the failing CI artifact. Repository pre-push gates and E2E build/typecheck passed. - A broader 36-test smoke invocation had 31 passes and five unrelated pre-existing expectation/snapshot failures, so it is not claimed as fully green. Adversarial fixes are recorded in [round one](#6470 (comment)) and [round two](#6470 (comment)). --------- Signed-off-by: Taylor Ho <[email protected]> Signed-off-by: Rizz <302abe414ca6e3134763d2539bfcf145aea2a63fe5f8455204ed602fd40cf381@buzz.block.builderlab.xyz> Co-authored-by: Rizz <302abe414ca6e3134763d2539bfcf145aea2a63fe5f8455204ed602fd40cf381@buzz.block.builderlab.xyz> Co-authored-by: Carl <acda9e433d19dcd0e6b6840f7f4b98f3a56f1fab98049d444c087019e6d36560@buzz.block.builderlab.xyz> Co-authored-by: Mongo <5398c5fd039b963ce132b3e078e7c4af097dd997517bb5e14c2682fe68c25197@buzz.block.builderlab.xyz>
1 parent b85d680 commit 0e48ff2

29 files changed

Lines changed: 3811 additions & 271 deletions

‎desktop/src/features/workflows/ui/WorkflowActionsMenu.tsx‎

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type WorkflowActionsMenuProps = {
2626
onEdit: () => void;
2727
onToggleEnabled: () => void;
2828
onTrigger: () => void;
29+
showEnabledToggle?: boolean;
2930
};
3031

3132
export function WorkflowActionsMenu({
@@ -36,6 +37,7 @@ export function WorkflowActionsMenu({
3637
onEdit,
3738
onToggleEnabled,
3839
onTrigger,
40+
showEnabledToggle = true,
3941
}: WorkflowActionsMenuProps) {
4042
return (
4143
<DropdownMenu>
@@ -63,37 +65,39 @@ export function WorkflowActionsMenu({
6365
<Copy className="mr-2 h-4 w-4" />
6466
Duplicate
6567
</DropdownMenuItem>
66-
<DropdownMenuCheckboxItem
67-
checked={isEnabled}
68-
className="gap-2 pl-2 [&>span:first-child]:hidden"
69-
disabled={isTogglingEnabled}
70-
onCheckedChange={(checked) => {
71-
if (checked !== isEnabled) onToggleEnabled();
72-
}}
73-
onSelect={(event) => event.preventDefault()}
74-
>
75-
{isEnabled ? (
76-
<Power className="mr-2 h-4 w-4 shrink-0" />
77-
) : (
78-
<PowerOff className="mr-2 h-4 w-4 shrink-0" />
79-
)}
80-
<span>Enable</span>
81-
<span
82-
aria-hidden="true"
83-
className={
84-
"ml-auto inline-flex h-5 w-9 shrink-0 items-center rounded-full border-2 border-transparent transition-colors " +
85-
(isEnabled ? "bg-primary" : "bg-input")
86-
}
87-
data-testid="workflow-enabled-switch-visual"
68+
{showEnabledToggle ? (
69+
<DropdownMenuCheckboxItem
70+
checked={isEnabled}
71+
className="gap-2 pl-2 [&>span:first-child]:hidden"
72+
disabled={isTogglingEnabled}
73+
onCheckedChange={(checked) => {
74+
if (checked !== isEnabled) onToggleEnabled();
75+
}}
76+
onSelect={(event) => event.preventDefault()}
8877
>
78+
{isEnabled ? (
79+
<Power className="mr-2 h-4 w-4 shrink-0" />
80+
) : (
81+
<PowerOff className="mr-2 h-4 w-4 shrink-0" />
82+
)}
83+
<span>Enable</span>
8984
<span
85+
aria-hidden="true"
9086
className={
91-
"block h-4 w-4 rounded-full bg-background transition-transform " +
92-
(isEnabled ? "translate-x-4" : "translate-x-0")
87+
"ml-auto inline-flex h-5 w-9 shrink-0 items-center rounded-full border-2 border-transparent transition-colors " +
88+
(isEnabled ? "bg-primary" : "bg-input")
9389
}
94-
/>
95-
</span>
96-
</DropdownMenuCheckboxItem>
90+
data-testid="workflow-enabled-switch-visual"
91+
>
92+
<span
93+
className={
94+
"block h-4 w-4 rounded-full bg-background transition-transform " +
95+
(isEnabled ? "translate-x-4" : "translate-x-0")
96+
}
97+
/>
98+
</span>
99+
</DropdownMenuCheckboxItem>
100+
) : null}
97101
<DropdownMenuSeparator />
98102
<DropdownMenuItem className="text-destructive" onClick={onDelete}>
99103
<Trash2 className="mr-2 h-4 w-4" />

‎desktop/src/features/workflows/ui/WorkflowCard.tsx‎

Lines changed: 171 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,27 @@ import {
66
Hash,
77
MessageCircle,
88
MessageSquare,
9-
Send,
109
SmilePlus,
1110
Timer,
1211
Webhook,
1312
Zap,
1413
} from "lucide-react";
1514
import type { LucideIcon } from "lucide-react";
15+
import { motion, useReducedMotion } from "motion/react";
16+
import * as React from "react";
1617

1718
import type { Workflow } from "@/shared/api/types";
1819
import { cn } from "@/shared/lib/cn";
20+
import { Switch } from "@/shared/ui/switch";
1921
import { WorkflowActionsMenu } from "./WorkflowActionsMenu";
2022
import {
21-
getWorkflowDescription,
22-
getWorkflowDisplayStatus,
2323
getWorkflowEnabled,
24-
getWorkflowPrimaryAction,
25-
getWorkflowTriggerSummary,
24+
getWorkflowActionTiles,
25+
getWorkflowCardLabel,
26+
getWorkflowTriggerEmoji,
2627
getWorkflowTriggerType,
2728
} from "./workflowDefinition";
29+
import { StatusEmoji } from "@/features/user-status/ui/StatusEmoji";
2830

2931
type WorkflowCardProps = {
3032
workflow: Workflow;
@@ -52,7 +54,7 @@ const ACTION_ICONS: Record<string, LucideIcon> = {
5254
delay: Timer,
5355
request_approval: CircleCheckBig,
5456
send_dm: MessageCircle,
55-
send_message: Send,
57+
send_message: MessageSquare,
5658
set_channel_topic: Hash,
5759
};
5860

@@ -64,15 +66,123 @@ const TRIGGER_ACCENTS: Record<string, string> = {
6466
webhook: "border-orange-300/30 bg-orange-500 text-white",
6567
};
6668

67-
function StatusBadge({ status }: { status: Workflow["status"] }) {
69+
const ACTION_ACCENTS: Record<string, string> = {
70+
add_reaction: "border-pink-400/30 bg-pink-600 text-white",
71+
call_webhook: "border-orange-300/30 bg-orange-500 text-white",
72+
delay: "border-sky-300/30 bg-sky-500 text-white",
73+
request_approval: "border-emerald-300/30 bg-emerald-600 text-white",
74+
send_dm: "border-indigo-300/30 bg-indigo-600 text-white",
75+
send_message: "border-blue-300/30 bg-blue-600 text-white",
76+
set_channel_topic: "border-violet-300/30 bg-violet-600 text-white",
77+
};
78+
79+
function StatusToggle({
80+
disabled,
81+
enabled,
82+
onToggle,
83+
}: {
84+
disabled: boolean;
85+
enabled: boolean;
86+
onToggle: () => void;
87+
}) {
88+
return (
89+
<Switch
90+
aria-label={enabled ? "Disable workflow" : "Enable workflow"}
91+
checked={enabled}
92+
disabled={disabled}
93+
onCheckedChange={(checked) => {
94+
if (checked !== enabled) onToggle();
95+
}}
96+
/>
97+
);
98+
}
99+
100+
function ActionTile({
101+
action,
102+
animationSequence,
103+
className,
104+
emoji,
105+
index,
106+
}: {
107+
action: string;
108+
animationSequence: number;
109+
className?: string;
110+
emoji: string | null;
111+
index: number;
112+
}) {
113+
const ActionIcon = ACTION_ICONS[action];
114+
const accent = ACTION_ACCENTS[action];
115+
const reduceMotion = useReducedMotion();
116+
117+
return (
118+
<span
119+
aria-hidden="true"
120+
className={cn(
121+
"absolute inset-y-0 flex w-9 items-center justify-center rounded-xl border shadow-xs",
122+
accent ?? "border-border/65 bg-background/80 text-muted-foreground",
123+
className,
124+
)}
125+
>
126+
<motion.span
127+
animate={
128+
animationSequence > 0 && !reduceMotion
129+
? { scale: [1, 1.18, 0.94, 1], y: [0, -5, 1, 0] }
130+
: undefined
131+
}
132+
className="flex items-center justify-center"
133+
transition={{
134+
delay: index * 0.11,
135+
duration: 0.48,
136+
ease: "easeOut",
137+
}}
138+
>
139+
{emoji ? (
140+
<StatusEmoji className="h-6 w-6 text-xl" value={emoji} />
141+
) : ActionIcon ? (
142+
<ActionIcon className="h-5 w-5" />
143+
) : (
144+
<Zap className="h-5 w-5" />
145+
)}
146+
</motion.span>
147+
</span>
148+
);
149+
}
150+
151+
function ActionTileStack({
152+
actions,
153+
animationSequence = 0,
154+
}: {
155+
actions: Array<{ action: string; emoji: string | null; key: string }>;
156+
animationSequence?: number;
157+
}) {
158+
const visibleActions = actions.slice(0, 3);
159+
68160
return (
69161
<span
70162
className={cn(
71-
"rounded-full border border-border/65 bg-background/80 px-2 py-1 text-2xs font-semibold uppercase tracking-wider shadow-xs",
72-
status === "active" ? "text-foreground" : "text-muted-foreground",
163+
"relative h-9",
164+
visibleActions.length === 1 && "w-9",
165+
visibleActions.length === 2 && "w-[2.625rem]",
166+
visibleActions.length > 2 && "w-12",
73167
)}
168+
data-testid="workflow-card-action-stack"
74169
>
75-
{status}
170+
{visibleActions
171+
.map((action, index) => (
172+
<ActionTile
173+
action={action.action}
174+
animationSequence={animationSequence}
175+
className={cn(
176+
index === 0 && "left-0 z-10",
177+
index === 1 && "left-1.5 z-[5] scale-90 opacity-60",
178+
index === 2 && "left-3 scale-75 opacity-35",
179+
)}
180+
emoji={action.emoji}
181+
index={index}
182+
key={`${action.key}-${animationSequence}`}
183+
/>
184+
))
185+
.reverse()}
76186
</span>
77187
);
78188
}
@@ -88,19 +198,20 @@ export function WorkflowCard({
88198
onDuplicate,
89199
onDelete,
90200
}: WorkflowCardProps) {
91-
const displayStatus = getWorkflowDisplayStatus(workflow);
92-
const triggerSummary = getWorkflowTriggerSummary(workflow.definition);
93-
const description = getWorkflowDescription(workflow.definition);
201+
const [triggerAnimationSequence, setTriggerAnimationSequence] =
202+
React.useState(0);
203+
const isEnabled = getWorkflowEnabled(workflow.definition);
204+
const cardLabel = getWorkflowCardLabel(workflow.definition);
94205
const triggerType = getWorkflowTriggerType(workflow.definition);
95-
const actionType = getWorkflowPrimaryAction(workflow.definition);
206+
const actionTiles = getWorkflowActionTiles(workflow.definition);
207+
const triggerEmoji = getWorkflowTriggerEmoji(workflow.definition);
96208
const TriggerIcon = triggerType ? TRIGGER_ICONS[triggerType] : undefined;
97-
const ActionIcon = actionType ? ACTION_ICONS[actionType] : undefined;
98209
const triggerAccent = triggerType ? TRIGGER_ACCENTS[triggerType] : undefined;
99210

100211
return (
101212
<div
102213
className={cn(
103-
"group relative min-h-60 w-full overflow-hidden rounded-2xl bg-muted/50 p-5 text-left text-foreground shadow-xs transition-colors hover:bg-muted/65",
214+
"group relative flex min-h-60 w-full flex-col overflow-hidden rounded-2xl bg-muted/50 p-5 text-left text-foreground shadow-xs transition-colors hover:bg-muted/65",
104215
)}
105216
data-testid={`workflow-card-${workflow.id}`}
106217
>
@@ -112,7 +223,7 @@ export function WorkflowCard({
112223
<span className="sr-only">View {workflow.name}</span>
113224
</button>
114225

115-
<div className="pointer-events-none relative z-10 flex h-full min-h-48 flex-col">
226+
<div className="pointer-events-none relative z-10 flex min-h-48 flex-1 flex-col">
116227
<div className="flex items-start justify-between gap-3">
117228
<div className="flex items-center gap-2" aria-hidden="true">
118229
<span
@@ -121,54 +232,74 @@ export function WorkflowCard({
121232
triggerAccent ?? "border-slate-400/30 bg-slate-600 text-white",
122233
)}
123234
>
124-
{TriggerIcon ? (
235+
{triggerEmoji ? (
236+
<StatusEmoji className="h-6 w-6 text-xl" value={triggerEmoji} />
237+
) : TriggerIcon ? (
125238
<TriggerIcon className="h-5 w-5" />
126239
) : (
127240
<Zap className="h-5 w-5" />
128241
)}
129242
</span>
130-
{ActionIcon ? (
243+
{actionTiles.length > 0 ? (
131244
<>
132245
<ArrowRight className="h-4 w-4 text-muted-foreground/60" />
133-
<span className="flex h-9 w-9 items-center justify-center rounded-xl border border-border/65 bg-background/80 text-muted-foreground shadow-xs">
134-
<ActionIcon className="h-5 w-5" />
135-
</span>
246+
<ActionTileStack
247+
actions={actionTiles}
248+
animationSequence={triggerAnimationSequence}
249+
/>
136250
</>
137251
) : null}
138252
</div>
139253

140254
<div className="pointer-events-auto flex items-center gap-1.5">
141-
<StatusBadge status={displayStatus} />
255+
<StatusToggle
256+
disabled={isTogglingEnabled}
257+
enabled={isEnabled}
258+
onToggle={() => onToggleEnabled(workflow)}
259+
/>
142260
<WorkflowActionsMenu
143-
isEnabled={getWorkflowEnabled(workflow.definition)}
261+
isEnabled={isEnabled}
144262
isTogglingEnabled={isTogglingEnabled}
145263
onDelete={() => onDelete(workflow)}
146264
onDuplicate={() => onDuplicate(workflow)}
147265
onEdit={() => onEdit(workflow)}
148266
onToggleEnabled={() => onToggleEnabled(workflow)}
149-
onTrigger={() => onTrigger(workflow.id)}
267+
onTrigger={() => {
268+
setTriggerAnimationSequence((sequence) => sequence + 1);
269+
onTrigger(workflow.id);
270+
}}
271+
showEnabledToggle={false}
150272
/>
151273
</div>
152274
</div>
153275

154-
{triggerSummary ? (
155-
<p className="mt-4 line-clamp-1 text-xs font-semibold text-muted-foreground">
156-
{triggerSummary}
157-
</p>
158-
) : null}
159-
<h3 className="mt-1 line-clamp-4 text-xl font-bold leading-tight tracking-tight">
160-
{workflow.name}
276+
<h3
277+
className="mt-4 line-clamp-4 text-xl font-bold leading-tight tracking-tight"
278+
data-testid="workflow-card-semantic-label"
279+
>
280+
{cardLabel}
161281
</h3>
162-
{description ? (
163-
<p className="mt-2 line-clamp-2 text-sm leading-relaxed text-muted-foreground">
164-
{description}
165-
</p>
166-
) : null}
167282

168283
<div className="mt-auto flex min-w-0 items-end justify-between gap-3 pt-5 text-muted-foreground">
169-
<p className="min-w-0 truncate text-2xs">
170-
{channelName ? `#${channelName}` : "Channel workflow"}
171-
</p>
284+
<div className="min-w-0">
285+
{channelName ? (
286+
<p
287+
className="truncate text-xs font-semibold text-foreground"
288+
data-testid="workflow-card-channel"
289+
>
290+
#{channelName}
291+
</p>
292+
) : null}
293+
<p
294+
className={cn(
295+
"truncate text-2xs text-muted-foreground",
296+
channelName && "mt-0.5",
297+
)}
298+
data-testid="workflow-card-name"
299+
>
300+
{workflow.name}
301+
</p>
302+
</div>
172303
<span className="shrink-0 text-2xs">
173304
{new Date(workflow.updatedAt * 1000).toLocaleDateString()}
174305
</span>

0 commit comments

Comments
 (0)