mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-12-03 08:10:27 +00:00
* feat: show who approved a flow run and the runs waiting for your approval Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: skip consumed approvals of a workflow as code and keep agent approval requests on the run page Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: confine waiting approvals to a token's tags, track a workflow's pending approval, show continued rejections Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: mark a recent run suspended only while it waits on an approval Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: regenerate the files derived from the OpenFlow schema Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: list a step's approvers without keying on their truncated resume id Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: drop the doubled lines in the run page's approvals card Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: show the approvals section on home by default, like recently run Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: list a waiting approval on home only when its step opts in Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: show waiting runs in recently run in violet with how long they have waited Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: show a waiting run's age in recently run like every other row's Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor: open every waiting approval on its approval page Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: open approval pages and the recent run link in a new tab Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: word approval rows like the approval page and align them with sibling UI Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: list a subflow, branch or loop approval in the run's approvals card Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: show nested approvals on the run page, with the steps leading to them Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf: read only the nested runs that can hold an approval, and chain their step ids Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: select a nested approval's own node, refetch only when its waits change Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: keep nested approvals within the token's tag scope, test which steps are followed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: link each waiting approval row to its approval page Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: order finished approvals by decision time, count approvals instead of steps Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: show a nested wait in the progress bar, drop the graph's suspended line Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: follow nested loops of deployed flows, show continued timeouts, violet waiting bar Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: show the flow progress bar on the public run page Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: list approvals that timed out with no response, refresh the count after approving Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor: read approvers with a checked query Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: name who approved a waiting step so far Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: show each approval's time on hover Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf: list Home approvals from the waiting step's status, not flow definitions Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: show the Approvals card in the runs page's detail panel Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: show approval times in a popover, not a native tooltip Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: put an approval step's resume form above its buttons Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: show the approval count and times on the approval page Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: leave skipped nested approval steps out of the history Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: count only the current step's approvals on the approval page Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
142 lines
4.4 KiB
Svelte
142 lines
4.4 KiB
Svelte
<script lang="ts">
|
|
import { mergeSchema } from '$lib/common'
|
|
import { type Job, JobService } from '$lib/gen'
|
|
import { ExternalLink } from 'lucide-svelte'
|
|
import DisplayResult from './DisplayResult.svelte'
|
|
import Tooltip from './Tooltip.svelte'
|
|
import ApprovalActions from './approvals/ApprovalActions.svelte'
|
|
import SchemaForm from './SchemaForm.svelte'
|
|
import { twMerge } from 'tailwind-merge'
|
|
import { untrack } from 'svelte'
|
|
import { isReplaying } from './recording/offlineReplay.svelte'
|
|
|
|
interface Props {
|
|
isOwner: boolean
|
|
/** The workspace the job ran in — pass `job.workspace_id`, never the navigation
|
|
* workspace, which differs whenever the editor is embedded. */
|
|
workspaceId: string | undefined
|
|
job: Job
|
|
light?: boolean
|
|
/** Fired after a successful resume/reject, before the next poll observes it —
|
|
* lets a host (e.g. the AI chat jobs tray) close its modal optimistically. */
|
|
onAction?: (approved: boolean) => void
|
|
}
|
|
|
|
let { isOwner: _isOwner, workspaceId, job, light = false, onAction }: Props = $props()
|
|
|
|
let default_payload: object = $state({})
|
|
let description: any = $state(undefined)
|
|
let hide_cancel = $state(false)
|
|
let approvalPageUrl: string | undefined = $state(undefined)
|
|
|
|
let defaultValues = $state({})
|
|
|
|
let schema = $state({})
|
|
let lastJobId: string | undefined = undefined
|
|
async function getDefaultArgs() {
|
|
let jobId = job?.flow_status?.modules?.[approvalStep]?.job
|
|
|
|
if (jobId === lastJobId) {
|
|
return
|
|
}
|
|
if (!jobId || !workspaceId) {
|
|
return {}
|
|
}
|
|
lastJobId = jobId
|
|
let job_result = (await JobService.getCompletedJobResult({
|
|
workspace: workspaceId,
|
|
id: jobId
|
|
})) as any
|
|
const args = job_result?.default_args ?? {}
|
|
description = job_result?.description
|
|
defaultValues = JSON.parse(JSON.stringify(args))
|
|
default_payload = args
|
|
|
|
approvalPageUrl = job_result?.['approvalPage']
|
|
hide_cancel = job?.raw_flow?.modules?.[approvalStep]?.suspend?.hide_cancel ?? false
|
|
schema = mergeSchema(
|
|
job?.raw_flow?.modules?.[approvalStep]?.suspend?.resume_form?.schema ?? {},
|
|
job_result?.enums ?? {}
|
|
)
|
|
}
|
|
|
|
async function continu(approve: boolean, reason?: string) {
|
|
if (!workspaceId) {
|
|
throw new Error('Cannot resume: the job has no workspace')
|
|
}
|
|
await JobService.resumeSuspended({
|
|
workspace: workspaceId,
|
|
jobId: job?.id ?? '',
|
|
requestBody: {
|
|
payload: approve ? (default_payload as any) : reason ? { reason } : undefined,
|
|
approved: approve
|
|
}
|
|
})
|
|
onAction?.(approve)
|
|
}
|
|
|
|
let approvalStep = $derived((job?.flow_status?.step ?? 1) - 1)
|
|
// Everything this panel shows (description, resume form enums, approval page) is
|
|
// fetched from the suspended job — a recording carries none of it — and Resume /
|
|
// Cancel act on a job that only exists in the recording. So a replay states the
|
|
// recorded fact and offers nothing to click.
|
|
let replaying = $derived(isReplaying())
|
|
$effect(() => {
|
|
if (!replaying) {
|
|
job && untrack(() => getDefaultArgs())
|
|
}
|
|
})
|
|
</script>
|
|
|
|
{#if replaying}
|
|
<div class="w-full text-xs text-secondary">This step was waiting for approval.</div>
|
|
{:else}
|
|
<div class="w-full h-full text-xs text-primary">
|
|
{#if description != undefined}
|
|
<DisplayResult {workspaceId} noControls result={description} language={job?.language} />
|
|
<div class="mt-2"></div>
|
|
{/if}
|
|
<!-- The form first, then its buttons below it, as any form is submitted. -->
|
|
{#if job?.raw_flow?.modules?.[approvalStep]?.suspend?.resume_form?.schema}
|
|
<div class="flex items-start gap-1 mb-2">
|
|
<div
|
|
class={twMerge(
|
|
'w-full border rounded-lg p-2',
|
|
light ? 'min-w-96 max-h-svh overflow-y-auto' : ''
|
|
)}
|
|
>
|
|
<SchemaForm onlyMaskPassword bind:args={default_payload} {defaultValues} {schema} />
|
|
</div>
|
|
<Tooltip>
|
|
The payload is optional, it is passed to the following step through the `resume`
|
|
variable
|
|
</Tooltip>
|
|
</div>
|
|
{/if}
|
|
<!-- A new approval step gets usable buttons again. -->
|
|
{#key job?.flow_status?.modules?.[approvalStep]?.job}
|
|
<ApprovalActions
|
|
approveLabel="Resume"
|
|
approveTooltip="Resume or approve this suspended step"
|
|
rejectTitle="Cancel step"
|
|
hideReject={hide_cancel}
|
|
askRejectReason
|
|
{light}
|
|
onAnswer={continu}
|
|
>
|
|
{#if approvalPageUrl}
|
|
<a
|
|
href={approvalPageUrl}
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
class="text-accent flex items-center gap-1 whitespace-nowrap"
|
|
>
|
|
Approval page <ExternalLink size={12} />
|
|
</a>
|
|
{/if}
|
|
|
|
</ApprovalActions>
|
|
{/key}
|
|
</div>
|
|
{/if}
|