Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions apps/dashboard/src/components/create-run-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export function CreateRunForm({ onCancel, onSuccess }: CreateRunFormProps) {
const [workflowName, setWorkflowName] = useState("");
const [version, setVersion] = useState("");
const [input, setInput] = useState("");
const [idempotencyKey, setIdempotencyKey] = useState("");
const [availableAt, setAvailableAt] = useState("");
const [deadlineAt, setDeadlineAt] = useState("");
const [inputError, setInputError] = useState<string | null>(null);
Expand Down Expand Up @@ -94,6 +95,7 @@ export function CreateRunForm({ onCancel, onSuccess }: CreateRunFormProps) {
workflowName: workflowName.trim(),
version: normalizeOptionalField(version),
input: normalizedInput,
idempotencyKey: idempotencyKey || null,
availableAt: availableAtIso,
deadlineAt: deadlineAtIso,
},
Expand Down Expand Up @@ -165,6 +167,29 @@ export function CreateRunForm({ onCancel, onSuccess }: CreateRunFormProps) {
<FieldError>{inputError}</FieldError>
</Field>

<Field>
<FieldLabel htmlFor="create-run-idempotency-key">
Idempotency Key
</FieldLabel>
<Input
id="create-run-idempotency-key"
name="idempotencyKey"
value={idempotencyKey}
onChange={(event) => {
setIdempotencyKey(event.currentTarget.value);
}}
placeholder="e.g. welcome-email:user_123"
aria-describedby="create-run-idempotency-key-description"
autoComplete="off"
disabled={isSubmitting}
/>
<FieldDescription id="create-run-idempotency-key-description">
Reusing a key for the same workflow name in this namespace opens
the existing run for 24 hours after creation, even with different
input or version. Leave empty to create a new run.
</FieldDescription>
</Field>

<div className="grid gap-5 sm:grid-cols-2">
<Field>
<FieldLabel htmlFor="create-run-available-at">
Expand Down
4 changes: 3 additions & 1 deletion apps/dashboard/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export const createWorkflowRunServerFn = createServerFn({ method: "POST" })
workflowName: z.string().trim().min(1),
version: z.string().nullable().optional(),
input: z.string().nullable().optional(),
idempotencyKey: z.string().nullable().optional(),
availableAt: z.string().nullable().optional(),
deadlineAt: z.string().nullable().optional(),
}),
Expand All @@ -166,7 +167,8 @@ export const createWorkflowRunServerFn = createServerFn({ method: "POST" })
return backend.createWorkflowRun({
workflowName: data.workflowName,
version,
idempotencyKey: null,
idempotencyKey:
data.idempotencyKey === "" ? null : (data.idempotencyKey ?? null),
config: {},
context: null,
input: parseWorkflowInput(data.input),
Expand Down
11 changes: 11 additions & 0 deletions apps/dashboard/src/routes/runs/$runId.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,17 @@ function RunOverviewPanel({
<span className="text-muted-foreground shrink-0 text-xs">Run ID</span>
<IdentifierValue value={run.id} />
</div>
{run.idempotencyKey !== null && (
<div className="flex min-w-0 flex-wrap items-center gap-2">
<span className="text-muted-foreground shrink-0 text-xs">
Idempotency Key
</span>
<IdentifierValue
value={run.idempotencyKey}
className="whitespace-pre-wrap"
/>
</div>
)}
<div className="flex min-w-0 flex-wrap items-center gap-2">
<span className="text-muted-foreground shrink-0 text-xs">Status</span>
<Tooltip>
Expand Down
Loading