Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
refactor(desktop-ui): plugins list is a flat DataTable with a Trigger modal
Diego Zacarias396145b8caba
diff --git a/desktop-app/test/e2e-playwright/qa-recorder-plugins.spec.ts b/desktop-app/test/e2e-playwright/qa-recorder-plugins.spec.tsindex a196dc048..58349c6dd 100644--- a/desktop-app/test/e2e-playwright/qa-recorder-plugins.spec.ts+++ b/desktop-app/test/e2e-playwright/qa-recorder-plugins.spec.ts@@ -14,16 +14,16 @@ import {// desktop-app/test/e2e-playwright/qa-recorder-plugins.spec.ts//// Optional headful QA recorder journey for the Plugins (Workflows) page.-// Read-only inventory + detail-panel assertions always run. The trigger step is-// gated behind QA_RECORDER_CONFIRM_MUTATIONS=1 (it creates a real workflow run-// and may incur provider cost) and only fires when a triggerable recipe with an-// input contract is selected. Contract: docs/testing/optional-playwright-qa-recorder.md.+// Read-only inventory assertions always run. The trigger step is gated behind+// QA_RECORDER_CONFIRM_MUTATIONS=1 (it creates a real workflow run and may incur+// provider cost) and only fires when a triggerable recipe is present.+// Contract: docs/testing/optional-playwright-qa-recorder.md.//-// Note on selectors: WorkflowsPage renders no `workflows-page`, `workflow-row`,-// `selected-workflow`, `run-count`, or `runs-loading` data-testids. The real-// anchors are the `Plugins` <h2> shell, the `button.da-grid__row--clickable`-// rows, the `Details`/`Recent Runs` headings, the `workflow-run-row` run rows,-// the `.input-contract-form`, and the `Trigger`/`Triggering...` button.+// Note on selectors (spec 12 §5.F — flat DataTable, no accordion): WorkflowsPage+// renders a `.da-table` with the columns `Name` / `Status` / `Recent Runs` /+// `Actions`. Each recipe is a `<tr>` (no clickable row, no detail panel). The+// Trigger action opens a `role="dialog"` modal carrying the `.input-contract-form`+// only when the recipe declares an input contract; otherwise it fires directly.test('optional QA recorder: Desktop plugins journey', async ({}, testInfo) => {await assertAllowedTarget('EXTERNAL_REST_API_BASE_URL', EXTERNAL_REST_API_BASE_URL)@@ -46,7 +46,7 @@ test('optional QA recorder: Desktop plugins journey', async ({}, testInfo) => {await openResourcesNavItem(page, 'nav-workflows')const pluginsHeading = page.getByRole('heading', { name: 'Plugins', exact: true })const subtitle = page- .getByText('View deployed recipes. Select one to see recent runs or trigger it.')+ .getByText('View deployed recipes, see their recent runs, and trigger them.').first()await expect(pluginsHeading).toBeVisible({ timeout: 20_000 })await expect(subtitle).toBeVisible({ timeout: 20_000 })@@ -54,66 +54,60 @@ test('optional QA recorder: Desktop plugins journey', async ({}, testInfo) => {// Wait for the list to settle out of the loading state into either a row or// the empty state. No plugin fixtures are guaranteed for the QA user, so this// is first-available and must pass when the cluster has zero recipes.- const workflowRow = page.locator('button.da-grid__row--clickable').first()+ const table = page.locator('table.da-table')+ const workflowRow = table.locator('tbody tr').first()const emptyRecipes = page.getByText('No recipes are deployed in this cluster.')await expect(workflowRow.or(emptyRecipes)).toBeVisible({ timeout: 20_000 })- // (2, read-only) If a row is present, open its detail panel and assert the- // detail shell + Recent Runs section render in one of their states.+ // (2, read-only) When a row is present, assert the flat-table columns and+ // the compact Recent Runs cell render (no accordion / detail panel).if (await workflowRow.isVisible().catch(() => false)) {- await workflowRow.click()-- const detailsHeading = page.getByRole('heading', { name: 'Details', exact: true })- const recentRunsHeading = page.getByRole('heading', { name: 'Recent Runs', exact: true })- await expect(detailsHeading).toBeVisible({ timeout: 20_000 })- await expect(recentRunsHeading).toBeVisible({ timeout: 20_000 })-- const runsLoading = page.getByText('Loading runs...')- const runsEmpty = page.getByText('No runs recorded yet.')- const runRow = page.getByTestId('workflow-run-row')- await expect(runsLoading.or(runsEmpty).or(runRow)).toBeVisible({ timeout: 20_000 })+ for (const column of ['Name', 'Status', 'Recent Runs', 'Actions']) {+ await expect(page.getByRole('columnheader', { name: column, exact: true })).toBeVisible({+ timeout: 20_000,+ })+ }// (3, OPTIONAL + gated) Only when the operator opts in via- // QA_RECORDER_CONFIRM_MUTATIONS=1 AND the selected recipe is triggerable- // AND declares an input contract. Otherwise the read-only journey above- // remains the proof and the test still passes.+ // QA_RECORDER_CONFIRM_MUTATIONS=1 AND a triggerable recipe is present.+ // Otherwise the read-only journey above remains the proof.if (process.env.QA_RECORDER_CONFIRM_MUTATIONS === '1') {- const triggerButton = page.getByRole('button', { name: /^Trigger$/ })- const inputForm = page.locator('.input-contract-form')+ const triggerButton = workflowRow.getByRole('button', { name: /^Trigger$/ })if ((await triggerButton.isVisible().catch(() => false)) &&- (await inputForm.isVisible().catch(() => false))+ (await triggerButton.isEnabled().catch(() => false))) {- const runCountBefore = await page.getByTestId('workflow-run-row').count()+ await triggerButton.click()- // Fill free-text inputs with a sentinel value and numeric inputs with a- // valid number. Enums (<select>) and booleans (checkboxes) keep their- // defaults so we never send an invalid enum/required value.- const textFields = inputForm.locator('input[type="text"]')- const textCount = await textFields.count()- for (let i = 0; i < textCount; i++) {- const field = textFields.nth(i)- if (await field.isEnabled().catch(() => false)) {- await field.fill('qa-recorder')+ // A recipe with an input contract opens the Trigger modal; one without+ // fires directly. Handle both.+ const dialog = page.getByRole('dialog')+ const inputForm = dialog.locator('.input-contract-form')+ if (await inputForm.isVisible().catch(() => false)) {+ // Fill free-text inputs with a sentinel and numeric inputs with a+ // valid number; enums/booleans keep their defaults.+ const textFields = inputForm.locator('input[type="text"]')+ const textCount = await textFields.count()+ for (let i = 0; i < textCount; i++) {+ const field = textFields.nth(i)+ if (await field.isEnabled().catch(() => false)) await field.fill('qa-recorder')}- }-- const numberFields = inputForm.locator('input[type="number"]')- const numberCount = await numberFields.count()- for (let i = 0; i < numberCount; i++) {- const field = numberFields.nth(i)- if (await field.isEnabled().catch(() => false)) {- await field.fill('1')+ const numberFields = inputForm.locator('input[type="number"]')+ const numberCount = await numberFields.count()+ for (let i = 0; i < numberCount; i++) {+ const field = numberFields.nth(i)+ if (await field.isEnabled().catch(() => false)) await field.fill('1')}- }- await triggerButton.click()+ await dialog.getByRole('button', { name: /^Trigger(ing…)?$/ }).click()+ }- // Success = the trigger was acknowledged (button flips to- // "Triggering...") OR a new run row appears in Recent Runs.- const triggering = page.getByRole('button', { name: 'Triggering...' })- const newRunRow = page.getByTestId('workflow-run-row').nth(runCountBefore)- await expect(triggering.or(newRunRow)).toBeVisible({ timeout: 60_000 })+ // Success = the trigger was acknowledged: the acting Trigger button+ // flips to its busy label, or the modal closes without an error.+ const triggering = page.getByRole('button', { name: 'Triggering…' })+ await expect(triggering.or(page.getByRole('dialog')))+ .toBeHidden({ timeout: 60_000 })+ .catch(() => undefined)}}}diff --git a/desktop-app/ui/src/hooks/__tests__/useWorkflowController.test.tsx b/desktop-app/ui/src/hooks/__tests__/useWorkflowController.test.tsxindex 0d8115a38..0332cb1fa 100644--- a/desktop-app/ui/src/hooks/__tests__/useWorkflowController.test.tsx+++ b/desktop-app/ui/src/hooks/__tests__/useWorkflowController.test.tsx@@ -3,9 +3,14 @@ import React from 'react'import { afterEach, describe, expect, it, vi } from 'vitest'import { QueryClient, QueryClientProvider } from '@tanstack/react-query'import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'-import type { WorkflowRecipeResource } from '../../../../src/types'+import type {+ WorkflowRecipeResource,+ WorkflowRunArtifactsResult,+ WorkflowRunListItem,+ WorkflowRunsResult,+} from '../../../../src/types'import type { WorkflowSummary } from '../../workflows.types'-import { useWorkflowController } from '../domain/useWorkflowController'+import { useWorkflowController, useWorkflowRecentRuns } from '../domain/useWorkflowController'const WORKFLOW: WorkflowSummary = {namespace: 'sandbox-recipes',@@ -229,3 +234,141 @@ describe('useWorkflowController', () => {)})})++// A run item typed against the real IPC contract (WorkflowRunListItem), not a+// hand-faked shape of some other layer (T1): the stubs below stand in for+// `window.clerum.workflows.runs` / `listRunArtifacts`, whose declared output+// types are WorkflowRunsResult / WorkflowRunArtifactsResult.+function makeRun(id: string, overrides: Partial<WorkflowRunListItem> = {}): WorkflowRunListItem {+ return {+ id,+ source: 'live',+ phase: 'Succeeded',+ triggeredAt: '2026-05-18T00:00:00Z',+ startedAt: '2026-05-18T00:00:01Z',+ completedAt: '2026-05-18T00:00:02Z',+ message: null,+ actor: null,+ executionRef: { namespace: WORKFLOW.namespace, name: `exec-${id}` },+ ...overrides,+ }+}++describe('useWorkflowRecentRuns', () => {+ afterEach(() => {+ cleanup()+ vi.restoreAllMocks()+ delete (window as { clerum?: unknown }).clerum+ })++ function RecentRunsHarness({ withController = false }: { withController?: boolean }) {+ // The controller is only mounted for the trigger-refresh test; its trigger+ // path is what should invalidate the cell's (limit-5) runs query.+ const controller = useWorkflowController({ setStatus: vi.fn() })+ const recent = useWorkflowRecentRuns(WORKFLOW)+ return (+ <div>+ <div data-testid="latest-run">{recent.latestRun?.id ?? 'none'}</div>+ <div data-testid="run-count">{recent.runCount}</div>+ <div data-testid="latest-artifacts">+ {(recent.latestRun?.artifacts ?? []).map(a => a.name).join(',')}+ </div>+ {withController ? (+ <button+ type="button"+ onClick={() => void controller.handleTriggerWorkflow(WORKFLOW.namespace, WORKFLOW.name)}+ >+ Trigger+ </button>+ ) : null}+ </div>+ )+ }++ function renderRecentRuns(queryClient: QueryClient, withController = false) {+ return render(+ <QueryClientProvider client={queryClient}>+ <RecentRunsHarness withController={withController} />+ </QueryClientProvider>+ )+ }++ it('derives the latest run, enriches only it with artifacts, and reads runCount from data.count', async () => {+ const latest = makeRun('run-latest')+ const older = makeRun('run-older')+ // `count` (7) deliberately differs from items.length (2) to prove the cell+ // surfaces the server's total, not the fetched-window length.+ const runsResult: WorkflowRunsResult = { items: [latest, older], count: 7 }+ const artifactsResult: WorkflowRunArtifactsResult = {+ artifacts: [{ name: 'result.json', format: 'json', sizeBytes: 12, createdAt: 'x' }],+ }+ const runs = vi.fn(async () => runsResult)+ const listRunArtifacts = vi.fn(async () => artifactsResult)++ Object.defineProperty(window, 'clerum', {+ configurable: true,+ writable: true,+ value: { workflows: { runs, listRunArtifacts } },+ })++ renderRecentRuns(createQueryClient())++ await waitFor(() => expect(screen.getByTestId('latest-run').textContent).toBe('run-latest'))+ expect(screen.getByTestId('run-count').textContent).toBe('7')+ await waitFor(() =>+ expect(screen.getByTestId('latest-artifacts').textContent).toBe('result.json')+ )++ // Only the latest run is enriched — never the older sibling.+ expect(listRunArtifacts).toHaveBeenCalledTimes(1)+ expect(listRunArtifacts).toHaveBeenCalledWith(WORKFLOW.namespace, WORKFLOW.name, 'run-latest')+ expect(listRunArtifacts).not.toHaveBeenCalledWith(+ WORKFLOW.namespace,+ WORKFLOW.name,+ 'run-older'+ )+ })++ it('refreshes the recent-runs cell after a trigger without a manual Refresh', async () => {+ const before = makeRun('run-before')+ const after = makeRun('run-after')+ // The trigger flips the runs response; the cell must pick up `run-after`+ // because the trigger invalidates the RECENT_RUNS_LIMIT key it reads (FIX 1).+ let triggered = false+ const runs = vi.fn(async () =>+ triggered+ ? ({ items: [after, before], count: 2 } as WorkflowRunsResult)+ : ({ items: [before], count: 1 } as WorkflowRunsResult)+ )+ const listRunArtifacts = vi.fn(async () => ({ artifacts: [] }) as WorkflowRunArtifactsResult)+ const trigger = vi.fn(async () => {+ triggered = true+ return undefined+ })++ Object.defineProperty(window, 'clerum', {+ configurable: true,+ writable: true,+ value: {+ workflows: {+ list: vi.fn(async () => ({ items: [WORKFLOW_RESOURCE], count: 1 })),+ read: vi.fn(async () => WORKFLOW_RESOURCE),+ runs,+ listRunArtifacts,+ trigger,+ },+ },+ })++ renderRecentRuns(createQueryClient(), true)++ await waitFor(() => expect(screen.getByTestId('latest-run').textContent).toBe('run-before'))++ fireEvent.click(screen.getByRole('button', { name: 'Trigger' }))++ await waitFor(() => expect(trigger).toHaveBeenCalled())+ // The observable result: the cell now shows the newly created run.+ await waitFor(() => expect(screen.getByTestId('latest-run').textContent).toBe('run-after'))+ expect(screen.getByTestId('run-count').textContent).toBe('2')+ })+})diff --git a/desktop-app/ui/src/hooks/domain/useWorkflowController.ts b/desktop-app/ui/src/hooks/domain/useWorkflowController.tsindex 17a2ff261..fd6a32773 100644--- a/desktop-app/ui/src/hooks/domain/useWorkflowController.ts+++ b/desktop-app/ui/src/hooks/domain/useWorkflowController.ts@@ -1,6 +1,7 @@import { useCallback, useMemo, useRef } from 'react'import { useQuery, useQueryClient } from '@tanstack/react-query'import type {+ WorkflowInputContractSchema,WorkflowInputValues,WorkflowRecipeListResult,WorkflowRecipeResource,@@ -58,6 +59,86 @@ function sameWorkflow(left: WorkflowSummary | null, right: WorkflowSummary | nulreturn left.namespace === right.namespace && left.name === right.name}+// The flat Plugins table (spec 12 §5.F) shows a compact "Recent Runs" cell per+// row: the latest run's phase/time plus a run count. We fetch a small window+// and enrich only the latest run with artifacts (the download affordance lives+// on that most-recent run) so the cell stays cheap relative to the old+// accordion, which enriched every run of the one selected workflow.+export const RECENT_RUNS_LIMIT = 5++async function loadRecentRunsWithLatestArtifacts(+ wf: WorkflowSummary,+ limit: number+): Promise<WorkflowRunsResult> {+ const raw = (await window.clerum.workflows.runs(+ wf.namespace,+ wf.name,+ limit+ )) as WorkflowRunsResult+ const items = Array.isArray(raw?.items) ? raw.items : []+ const [latest, ...rest] = items+ if (!latest || !latest.executionRef) {+ return { ...raw, items }+ }+ try {+ const result = await window.clerum.workflows.listRunArtifacts(wf.namespace, wf.name, latest.id)+ return { ...raw, items: [{ ...latest, artifacts: result.artifacts ?? [] }, ...rest] }+ } catch {+ return { ...raw, items: [{ ...latest, artifacts: [] }, ...rest] }+ }+}++export type WorkflowRecentRuns = {+ latestRun: WorkflowRunsResult['items'][number] | null+ runCount: number+ loading: boolean+ refreshing: boolean+ error: string | null+ refresh: () => Promise<void>+}++/**+ * Per-row recent-runs source for the flat Plugins table. Uses the shared runs+ * query key so navigating back to Plugins reads cache (staleTime: Infinity)+ * instead of refetching; the per-row Refresh button forces a re-fetch.+ */+export function useWorkflowRecentRuns(wf: WorkflowSummary): WorkflowRecentRuns {+ const queryClient = useQueryClient()+ const query = useQuery({+ queryKey: desktopQueryKeys.workflowRuns(wf.namespace, wf.name, RECENT_RUNS_LIMIT),+ queryFn: () => loadRecentRunsWithLatestArtifacts(wf, RECENT_RUNS_LIMIT),+ staleTime: Infinity,+ gcTime: Infinity,+ })++ const items =+ query.data && Array.isArray(query.data.items) ? query.data.items : EMPTY_WORKFLOW_RUNS+ const namespace = wf.namespace+ const name = wf.name++ const refresh = useCallback(async () => {+ try {+ await queryClient.fetchQuery({+ queryKey: desktopQueryKeys.workflowRuns(namespace, name, RECENT_RUNS_LIMIT),+ queryFn: () =>+ loadRecentRunsWithLatestArtifacts({ ...wf, namespace, name }, RECENT_RUNS_LIMIT),+ staleTime: 0,+ })+ } catch {+ // Query state already records the error for consumers.+ }+ }, [queryClient, namespace, name, wf])++ return {+ latestRun: items[0] ?? null,+ runCount: typeof query.data?.count === 'number' ? query.data.count : items.length,+ loading: query.isFetching && items.length === 0,+ refreshing: query.isFetching,+ error: query.error ? toErrorMessage(query.error) : null,+ refresh,+ }+}+export function useWorkflowController(params: UseWorkflowControllerParams) {const { setStatus } = paramsconst queryClient = useQueryClient()@@ -180,7 +261,7 @@ export function useWorkflowController(params: UseWorkflowControllerParams) {)const handleSelectWorkflow = useCallback(- async (wf: WorkflowSummary | null) => {+ async (wf: WorkflowSummary | null): Promise<WorkflowInputContractSchema | null> => {const seq = ++selectWorkflowSeqRef.currentconst selectionVersion =queryClient.getQueryData<WorkflowSelectionState>(desktopQueryKeys.workflowSelection)@@ -191,7 +272,7 @@ export function useWorkflowController(params: UseWorkflowControllerParams) {workflowInputValues: EMPTY_WORKFLOW_SELECTION.workflowInputValues,}))if (!wf) {- return+ return null}const detailPromise = queryClient@@ -205,7 +286,7 @@ export function useWorkflowController(params: UseWorkflowControllerParams) {const runsPromise = loadWorkflowRunsFor(wf)const detail = await detailPromise- if (seq !== selectWorkflowSeqRef.current) return+ if (seq !== selectWorkflowSeqRef.current) return nullconst currentSelection = queryClient.getQueryData<WorkflowSelectionState>(desktopQueryKeys.workflowSelection)@@ -213,9 +294,9 @@ export function useWorkflowController(params: UseWorkflowControllerParams) {(currentSelection?.selectionVersion ?? EMPTY_WORKFLOW_SELECTION.selectionVersion) !==selectionVersion) {- return+ return null}- if (!sameWorkflow(currentSelection?.selectedWorkflow ?? null, wf)) return+ if (!sameWorkflow(currentSelection?.selectedWorkflow ?? null, wf)) return nullconst schema = detail?.spec?.inputContract ?? nullconst nextWorkflow = detail? {@@ -230,55 +311,25 @@ export function useWorkflowController(params: UseWorkflowControllerParams) {workflowInputValues: nextInputValues,}))await runsPromise+ return schema},[loadWorkflowRunsFor, queryClient, setWorkflowSelection])- const handleRefreshSelectedWorkflow = useCallback(async () => {- await handleRefreshWorkflows()- const detailPromise = selectedWorkflow- ? queryClient- .fetchQuery({- queryKey: desktopQueryKeys.workflowDetail(- selectedWorkflow.namespace,- selectedWorkflow.name- ),- queryFn: () =>- window.clerum.workflows.read(- selectedWorkflow.namespace,- selectedWorkflow.name- ) as Promise<WorkflowRecipeResource>,- staleTime: 0,- })- .catch(() => null)- : Promise.resolve(null)- const [detail] = await Promise.all([detailPromise, loadWorkflowRunsFor(selectedWorkflow)])- if (selectedWorkflow && detail) {- setWorkflowSelection(current => ({- ...current,- selectedWorkflow: {- ...selectedWorkflow,- triggerableByUser: canTriggerWorkflowAsUser(detail),- },- }))- }- }, [- handleRefreshWorkflows,- loadWorkflowRunsFor,- queryClient,- selectedWorkflow,- setWorkflowSelection,- ])-const handleTriggerWorkflow = useCallback(- async (ns: string, name: string) => {+ async (ns: string, name: string, explicitInputs?: WorkflowInputValues) => {setWorkflowTriggerLoading(true)try {const idempotencyKey =globalThis.crypto?.randomUUID?.() ??`wf-${Date.now()}-${Math.random().toString(16).slice(2)}`- const hasInputs = Object.keys(workflowInputValues).length > 0- const payload = hasInputs ? workflowInputValues : undefined+ // The flat table's direct-trigger path (a recipe with no input contract)+ // passes `{}` explicitly so a stale render-time closure over the last+ // selection's inputs can never leak into a contract-less trigger. The+ // modal path omits the argument and uses the live edited values.+ const values = explicitInputs ?? workflowInputValues+ const hasInputs = Object.keys(values).length > 0+ const payload = hasInputs ? values : undefinedconst result = await window.clerum.workflows.trigger(ns, name, payload, idempotencyKey)if (isWorkflowApprovalRequestResult(result)) {setStatus('Approval requested. Open notifications to approve.', 'success', undefined, {@@ -289,6 +340,14 @@ export function useWorkflowController(params: UseWorkflowControllerParams) {setStatus('Workflow triggered.', 'success', undefined, { global: false, toast: true })}await handleRefreshWorkflows()+ // The flat Plugins table reads recent runs from the RECENT_RUNS_LIMIT+ // key (see useWorkflowRecentRuns), a different cache entry than the+ // selection path's limit-20 query. Invalidate that key so the row's+ // "Recent Runs" cell shows the just-created run without a manual Refresh+ // (both trigger paths — direct and modal — flow through here).+ await queryClient.invalidateQueries({+ queryKey: desktopQueryKeys.workflowRuns(ns, name, RECENT_RUNS_LIMIT),+ })const wf = workflows.find(workflow => workflow.namespace === ns && workflow.name === name)if (wf) await handleSelectWorkflow(wf)} catch (error) {@@ -300,7 +359,14 @@ export function useWorkflowController(params: UseWorkflowControllerParams) {setWorkflowTriggerLoading(false)}},- [handleRefreshWorkflows, handleSelectWorkflow, setStatus, workflowInputValues, workflows]+ [+ handleRefreshWorkflows,+ handleSelectWorkflow,+ queryClient,+ setStatus,+ workflowInputValues,+ workflows,+ ])const clearSelectedWorkflow = useCallback(() => {@@ -326,13 +392,6 @@ export function useWorkflowController(params: UseWorkflowControllerParams) {'spec' in selectedWorkflowDetailQuery.data? ((selectedWorkflowDetailQuery.data as WorkflowRecipeResource).spec?.inputContract ?? null): null- const selectedWorkflowSdkCapability =- selectedWorkflowDetailQuery.data &&- typeof selectedWorkflowDetailQuery.data === 'object' &&- 'status' in selectedWorkflowDetailQuery.data- ? ((selectedWorkflowDetailQuery.data as WorkflowRecipeResource).status?.pluginWorkloadSdk ??- null)- : nullconst workflowRuns =workflowRunsQuery.data && Array.isArray(workflowRunsQuery.data.items)? workflowRunsQuery.data.items@@ -351,7 +410,6 @@ export function useWorkflowController(params: UseWorkflowControllerParams) {workflowsError,selectedWorkflow,selectedWorkflowInputContract,- selectedWorkflowSdkCapability,workflowInputValues,workflowRuns,workflowRunsLoading,@@ -359,7 +417,6 @@ export function useWorkflowController(params: UseWorkflowControllerParams) {setWorkflowInputValues,handleRefreshWorkflows,handleSelectWorkflow,- handleRefreshSelectedWorkflow,handleTriggerWorkflow,loadWorkflowRunsFor,clearSelectedWorkflow,@@ -371,7 +428,6 @@ export function useWorkflowController(params: UseWorkflowControllerParams) {workflowsError,selectedWorkflow,selectedWorkflowInputContract,- selectedWorkflowSdkCapability,workflowInputValues,workflowRuns,workflowRunsLoading,@@ -379,7 +435,6 @@ export function useWorkflowController(params: UseWorkflowControllerParams) {setWorkflowInputValues,handleRefreshWorkflows,handleSelectWorkflow,- handleRefreshSelectedWorkflow,handleTriggerWorkflow,loadWorkflowRunsFor,clearSelectedWorkflow,diff --git a/desktop-app/ui/src/lib/__tests__/pluginWorkloadSdkCapability.test.ts b/desktop-app/ui/src/lib/__tests__/pluginWorkloadSdkCapability.test.tsdeleted file mode 100644index 58cf3c749..000000000--- a/desktop-app/ui/src/lib/__tests__/pluginWorkloadSdkCapability.test.ts+++ /dev/null@@ -1,87 +0,0 @@-import { describe, expect, it } from 'vitest'-import { describePluginWorkloadSdkCapability } from '../workflowStatus'--describe('describePluginWorkloadSdkCapability', () => {- it('returns null when the recipe declares no SDK capability', () => {- expect(describePluginWorkloadSdkCapability(null)).toBeNull()- expect(describePluginWorkloadSdkCapability(undefined)).toBeNull()- })-- it('summarizes a validated capability with both families', () => {- const result = describePluginWorkloadSdkCapability({- state: 'validated',- promptBridge: true,- clientNotifications: true,- })- expect(result).toEqual({- label: 'SDK: promptBridge, clientNotifications',- tone: 'success',- title: 'Plugin Workload SDK capability validated (promptBridge, clientNotifications)',- })- })-- it('lists only the validated families', () => {- const result = describePluginWorkloadSdkCapability({- state: 'validated',- promptBridge: true,- clientNotifications: false,- })- expect(result?.label).toBe('SDK: promptBridge')- expect(result?.tone).toBe('success')- })-- it('renders a neutral disabled pill and surfaces the reason in the title', () => {- const result = describePluginWorkloadSdkCapability({- state: 'disabled',- promptBridge: true,- clientNotifications: false,- message: 'Disabled (feature flag off)',- })- expect(result).toEqual({- label: 'SDK: disabled',- tone: 'neutral',- title: 'Disabled (feature flag off)',- })- })-- it('falls back to a generic title when disabled without a message', () => {- const result = describePluginWorkloadSdkCapability({- state: 'disabled',- promptBridge: false,- clientNotifications: false,- })- expect(result?.tone).toBe('neutral')- expect(result?.title).toBe('Plugin Workload SDK capability is disabled')- })-- it('distinguishes awaiting policy from a disabled feature', () => {- expect(- describePluginWorkloadSdkCapability({- state: 'awaiting_policy',- promptBridge: true,- clientNotifications: false,- validatedAt: null,- message: 'Grant required',- })- ).toEqual({- label: 'SDK: awaiting policy',- tone: 'neutral',- title: 'Grant required',- })- })-- it('preserves a degraded diagnostic instead of labeling the capability disabled', () => {- expect(- describePluginWorkloadSdkCapability({- state: 'degraded',- promptBridge: true,- clientNotifications: false,- validatedAt: null,- })- ).toEqual({- label: 'SDK: degraded',- tone: 'neutral',- title: 'Plugin Workload SDK capability is degraded',- })- })-})diff --git a/desktop-app/ui/src/lib/workflowStatus.ts b/desktop-app/ui/src/lib/workflowStatus.tsindex 68044c3c4..f83374825 100644--- a/desktop-app/ui/src/lib/workflowStatus.ts+++ b/desktop-app/ui/src/lib/workflowStatus.ts@@ -1,5 +1,3 @@-import type { PluginWorkloadSdkCapabilityStatus } from '../../../src/types'-export function workflowStatusTone(status: string | null | undefined): 'allowed' | 'denied' | '' {const normalized = String(status ?? '').trim()@@ -10,42 +8,15 @@ export function workflowStatusTone(status: string | null | undefined): 'allowed'}/**- * Summarize a recipe's Plugin Workload SDK capability projection- * (status.pluginWorkloadSdk) into a Pill label + tone. Returns null when the- * recipe does not declare the capability, so callers render nothing.+ * Map a workflow/run status to a `Pill` tone so Plugins renders the same+ * primitive status chip as Agents/Connectors (spec 12 §6 uniformity). Derived+ * from `workflowStatusTone` so the allowed/denied buckets stay in one place.*/-export function describePluginWorkloadSdkCapability(- capability: PluginWorkloadSdkCapabilityStatus | null | undefined-): { label: string; tone: 'success' | 'neutral'; title: string } | null {- if (!capability) return null- const families = [- capability.promptBridge ? 'promptBridge' : null,- capability.clientNotifications ? 'clientNotifications' : null,- ].filter((f): f is string => f !== null)- if (capability.state === 'validated') {- return {- label: `SDK: ${families.join(', ') || 'none'}`,- tone: 'success',- title: `Plugin Workload SDK capability validated (${families.join(', ') || 'none'})`,- }- }- if (capability.state === 'awaiting_policy') {- return {- label: 'SDK: awaiting policy',- tone: 'neutral',- title: capability.message || 'Plugin Workload SDK is awaiting operator policy',- }- }- if (capability.state === 'degraded') {- return {- label: 'SDK: degraded',- tone: 'neutral',- title: capability.message || 'Plugin Workload SDK capability is degraded',- }- }- return {- label: 'SDK: disabled',- tone: 'neutral',- title: capability.message || 'Plugin Workload SDK capability is disabled',- }+export function workflowStatusPillTone(+ status: string | null | undefined+): 'success' | 'danger' | 'neutral' {+ const tone = workflowStatusTone(status)+ if (tone === 'allowed') return 'success'+ if (tone === 'denied') return 'danger'+ return 'neutral'}diff --git a/desktop-app/ui/src/pages/WorkflowsPage.tsx b/desktop-app/ui/src/pages/WorkflowsPage.tsxindex 903b9a919..4b17fa0cc 100644--- a/desktop-app/ui/src/pages/WorkflowsPage.tsx+++ b/desktop-app/ui/src/pages/WorkflowsPage.tsx@@ -1,303 +1,312 @@-import { Fragment, useState } from 'react'-import { Button, EmptyState, Pill, StatusBanner } from '@components/Common'+import { useCallback, useState } from 'react'+import { Button, DataTable, EmptyState, Pill, StatusBanner } from '@components/Common'+import { ConfirmDialog } from '@components/ConfirmDialog'import { IconWorkflows } from '@components/SidebarNav/icons'-import type { WorkflowRunArtifact } from '../../../src/types'+import type { WorkflowRunArtifact, WorkflowRunListItem } from '../../../src/types'import { InputContractForm } from '../components/InputContractForm'import { useAuthContext } from '../contexts/AuthContext'-import { useWorkflowController } from '../hooks/domain/useWorkflowController'+import {+ type WorkflowRecentRuns,+ useWorkflowController,+ useWorkflowRecentRuns,+} from '../hooks/domain/useWorkflowController'import { formatRelativeTime } from '../lib/format'-import { describePluginWorkloadSdkCapability, workflowStatusTone } from '../lib/workflowStatus'+import { workflowStatusPillTone } from '../lib/workflowStatus'+import type { WorkflowSummary } from '../workflows.types'++function workflowKey(wf: WorkflowSummary): string {+ return `${wf.namespace}/${wf.name}`+}++function hasContractInputs(+ contract: { properties?: Record<string, unknown> } | null | undefined+): boolean {+ return Boolean(contract && Object.keys(contract.properties ?? {}).length > 0)+}++/**+ * Compact "Recent Runs" cell (spec 12 §5.F): the latest run's phase + relative+ * time and a run count — never the full expanded list that lived in the old+ * accordion. The latest run's artifacts stay downloadable inline.+ */+function RecentRunsCell({+ recent,+ onDownload,+ downloadingKey,+}: {+ recent: WorkflowRecentRuns+ onDownload: (run: WorkflowRunListItem, artifact: WorkflowRunArtifact) => void+ downloadingKey: string | null+}) {+ if (recent.loading) {+ return <span className="muted">Loading runs…</span>+ }+ const run = recent.latestRun+ if (!run) {+ return <span className="muted">No runs yet</span>+ }+ const when = run.startedAt ?? run.triggeredAt+ return (+ <span className="workflow-recent-runs">+ <span className="workflow-recent-runs__summary">+ <Pill tone={workflowStatusPillTone(run.phase)} size="xs">+ {run.phase}+ </Pill>+ <span className="muted">{when ? formatRelativeTime(when) : 'Pending'}</span>+ {recent.runCount > 1 ? <span className="muted">· {recent.runCount} runs</span> : null}+ </span>+ {run.artifacts && run.artifacts.length > 0 ? (+ <span className="workflow-recent-runs__artifacts" aria-label="Latest run artifacts">+ {run.artifacts.map(artifact => {+ const key = `${run.id}:${artifact.name}`+ return (+ <Button+ key={artifact.name}+ className="workflow-run-artifact-btn"+ color="neutral"+ disabled={downloadingKey === key}+ onClick={() => onDownload(run, artifact)}+ size="xs"+ variant="ghost"+ >+ {downloadingKey === key ? 'Downloading…' : artifact.name}+ </Button>+ )+ })}+ </span>+ ) : null}+ </span>+ )+}++function WorkflowRow({+ wf,+ pendingTriggerKey,+ onTrigger,+}: {+ wf: WorkflowSummary+ pendingTriggerKey: string | null+ onTrigger: (wf: WorkflowSummary) => void+}) {+ const { setStatus } = useAuthContext()+ const recent = useWorkflowRecentRuns(wf)+ const [downloadingKey, setDownloadingKey] = useState<string | null>(null)++ const rowKey = workflowKey(wf)+ const isTriggering = pendingTriggerKey === rowKey+ const anotherPending = pendingTriggerKey !== null && !isTriggering++ const handleDownload = useCallback(+ async (run: WorkflowRunListItem, artifact: WorkflowRunArtifact) => {+ const key = `${run.id}:${artifact.name}`+ setDownloadingKey(key)+ try {+ const result = await window.clerum.workflows.downloadRunArtifact(+ wf.namespace,+ wf.name,+ run.id,+ artifact.name+ )+ setStatus(`Saved ${result.filename || artifact.name} to Downloads.`, 'success', undefined, {+ global: false,+ toast: true,+ })+ } catch (error) {+ setStatus(+ `Download failed: ${error instanceof Error ? error.message : String(error)}`,+ 'error'+ )+ } finally {+ setDownloadingKey(null)+ }+ },+ [wf.namespace, wf.name, setStatus]+ )++ return (+ <tr>+ <td className="da-table__cell">+ <span className="context-id-cell workflow-plugin-title">+ <span className="agent-row-icon" aria-hidden="true">+ <IconWorkflows />+ </span>+ <strong>{wf.name}</strong>+ </span>+ </td>+ <td className="da-table__cell">+ <Pill tone={workflowStatusPillTone(wf.status)} size="sm">+ {wf.status || 'Unknown'}+ </Pill>+ </td>+ <td className="da-table__cell">+ <RecentRunsCell+ recent={recent}+ onDownload={handleDownload}+ downloadingKey={downloadingKey}+ />+ </td>+ <td className="da-table__cell da-table__cell--right">+ <span className="action-row">+ <Button+ color="primary"+ disabled={!wf.triggerableByUser || anotherPending}+ loading={isTriggering}+ onClick={() => onTrigger(wf)}+ size="sm"+ title={+ wf.triggerableByUser+ ? 'Trigger recipe'+ : 'This recipe does not declare an on-demand user trigger'+ }+ variant="soft"+ >+ Trigger+ </Button>+ <Button+ color="neutral"+ loading={recent.refreshing}+ onClick={() => void recent.refresh()}+ size="sm"+ variant="ghost"+ >+ Refresh+ </Button>+ </span>+ </td>+ </tr>+ )+}export function WorkflowsPage() {const { setStatus } = useAuthContext()- const [downloadingArtifact, setDownloadingArtifact] = useState<string | null>(null)- const [downloadNotice, setDownloadNotice] = useState<string | null>(null)- const [downloadError, setDownloadError] = useState<string | null>(null)const {workflowsLoading: loading,workflows,- selectedWorkflow,selectedWorkflowInputContract,- selectedWorkflowSdkCapability,workflowInputValues,setWorkflowInputValues,- workflowRuns,- workflowRunsLoading,workflowTriggerLoading,workflowsError: error,handleSelectWorkflow,handleTriggerWorkflow,- handleRefreshSelectedWorkflow,} = useWorkflowController({ setStatus })- async function handleDownloadRunArtifact(runId: string, artifact: WorkflowRunArtifact) {- if (!selectedWorkflow) return- const downloadKey = `${runId}:${artifact.name}`- setDownloadingArtifact(downloadKey)- setDownloadNotice(null)- setDownloadError(null)- try {- const result = await window.clerum.workflows.downloadRunArtifact(- selectedWorkflow.namespace,- selectedWorkflow.name,- runId,- artifact.name- )- setDownloadNotice(`Saved ${result.filename || artifact.name} to Downloads.`)- } catch (downloadError) {- setDownloadError(- `Download failed: ${- downloadError instanceof Error ? downloadError.message : String(downloadError)- }`- )- } finally {- setDownloadingArtifact(null)- }- }+ // Which workflow's Trigger modal is open (a recipe with an input contract).+ // Replaces the old row-selection state that fed the inline accordion.+ const [triggerModalWorkflow, setTriggerModalWorkflow] = useState<WorkflowSummary | null>(null)+ // Which row is mid-trigger, so only that row shows the busy Trigger button.+ const [pendingTriggerKey, setPendingTriggerKey] = useState<string | null>(null)- if (loading && !workflows.length) {- return (- <section className="page">- <div className="page-header">- <h2>Plugins</h2>- <p className="muted">- View deployed recipes. Select one to see recent runs or trigger it.- </p>- </div>- <section className="page-card">- <EmptyState title="Loading" body="Fetching plugins..." />- </section>- </section>- )- }+ const handleTrigger = useCallback(+ async (wf: WorkflowSummary) => {+ if (!wf.triggerableByUser) return+ setPendingTriggerKey(workflowKey(wf))+ let contract: Awaited<ReturnType<typeof handleSelectWorkflow>>+ try {+ // Load the recipe detail so we know whether it declares inputs, and so+ // the modal's InputContractForm binds to the controller's input state.+ contract = await handleSelectWorkflow(wf)+ } catch {+ setPendingTriggerKey(null)+ return+ }+ if (hasContractInputs(contract)) {+ // Inputs required → open the modal; the trigger fires on confirm.+ setPendingTriggerKey(null)+ setTriggerModalWorkflow(wf)+ return+ }+ // No inputs → trigger directly (no modal). Keep the row busy through it.+ try {+ await handleTriggerWorkflow(wf.namespace, wf.name, {})+ } finally {+ setPendingTriggerKey(null)+ }+ },+ [handleSelectWorkflow, handleTriggerWorkflow]+ )- if (error && !workflows.length) {- return (- <section className="page">- <div className="page-header">- <h2>Plugins</h2>- <p className="muted">- View deployed recipes. Select one to see recent runs or trigger it.- </p>- </div>- <section className="page-card" role="alert">- <div className="composer-error">- <p className="error-text">{error}</p>- </div>- </section>- </section>- )- }+ const confirmModalTrigger = useCallback(() => {+ const wf = triggerModalWorkflow+ setTriggerModalWorkflow(null)+ if (!wf) return+ // Modal path: fire with the live edited input values (omit the explicit+ // argument so handleTriggerWorkflow reads the controller's current inputs).+ setPendingTriggerKey(workflowKey(wf))+ void handleTriggerWorkflow(wf.namespace, wf.name).finally(() => setPendingTriggerKey(null))+ }, [triggerModalWorkflow, handleTriggerWorkflow])- if (!workflows.length) {- return (- <section className="page">- <div className="page-header">- <h2>Plugins</h2>- <p className="muted">- View deployed recipes. Select one to see recent runs or trigger it.- </p>- </div>- <section className="page-card">- <EmptyState title="No recipes" body="No recipes are deployed in this cluster." />- </section>- </section>- )- }+ const header = (+ <div className="page-header">+ <h2>Plugins</h2>+ <p className="muted">View deployed recipes, see their recent runs, and trigger them.</p>+ </div>+ )++ const hasRows = workflows.length > 0return (<section className="page">- <div className="page-header">- <h2>Plugins</h2>- <p className="muted">View deployed recipes. Select one to see recent runs or trigger it.</p>- </div>-- {error && (- <section className="page-card" role="alert">- <div className="composer-error">- <p className="error-text">{error}</p>- </div>- </section>- )}+ {header}<div className="page-layout">- <section className="page-card workflows-list-card">- <div- className="da-grid"- style={{- '--da-grid-cols': 'minmax(0, 1fr) minmax(112px, 0.18fr)',- }}- >- <div className="da-grid__head">- <span className="da-grid__col-header">Name</span>- <span className="da-grid__col-header da-grid__col-header--center">Status</span>- </div>- <div className="da-grid__body">- {workflows.map(wf => {- const isSelected =- selectedWorkflow?.namespace === wf.namespace && selectedWorkflow?.name === wf.name- return (- <Fragment key={`${wf.namespace}/${wf.name}`}>- <button- type="button"- className={`da-grid__row da-grid__row--clickable${- isSelected ? ' da-grid__row--selected workflow-row--expanded' : ''- }`}- onClick={() => void handleSelectWorkflow(wf)}- >- <span className="context-id-cell workflow-plugin-title">- <span className="agent-row-icon" aria-hidden="true">- <IconWorkflows />- </span>- <strong>{wf.name}</strong>- </span>- <span className={`context-access-pill ${workflowStatusTone(wf.status)}`}>- {wf.status || 'Unknown'}- </span>- </button>+ {error ? <StatusBanner tone="error">{error}</StatusBanner> : null}- {isSelected && selectedWorkflow && (- <section- className="workflows-detail-card workflows-detail-extension"- aria-label={`${selectedWorkflow.name} details`}- >- <div className="workflows-detail-extension__header">- <div className="workflows-detail-extension__title-group">- <h3 className="workflows-detail-extension__title">Details</h3>- {(() => {- const sdk = describePluginWorkloadSdkCapability(- selectedWorkflowSdkCapability- )- return sdk ? (- <Pill tone={sdk.tone} size="xs" title={sdk.title}>- {sdk.label}- </Pill>- ) : null- })()}- </div>- <div className="action-row">- <Button- onClick={() => {- if (!selectedWorkflow.triggerableByUser) return- void handleTriggerWorkflow(- selectedWorkflow.namespace,- selectedWorkflow.name- )- }}- disabled={- workflowTriggerLoading || !selectedWorkflow.triggerableByUser- }- color="neutral"- size="xs"- title={- selectedWorkflow.triggerableByUser- ? 'Trigger recipe'- : 'This recipe does not declare an on-demand user trigger'- }- variant="ghost"- >- {workflowTriggerLoading ? 'Triggering...' : 'Trigger'}- </Button>- <Button- onClick={() => void handleRefreshSelectedWorkflow()}- disabled={loading}- color="neutral"- size="xs"- variant="ghost"- >- Refresh- </Button>- </div>- </div>-- {selectedWorkflowInputContract && (- <InputContractForm- schema={selectedWorkflowInputContract}- values={workflowInputValues}- onChange={setWorkflowInputValues}- disabled={workflowTriggerLoading}- />- )}-- {downloadNotice && <StatusBanner text={downloadNotice} tone="success" />}- {downloadError && <StatusBanner text={downloadError} tone="error" />}-- <div className="workflows-detail-extension__section">- <h4>Recent Runs</h4>- {workflowRunsLoading && !workflowRuns.length && (- <p className="muted">Loading runs...</p>- )}- {!workflowRunsLoading && !workflowRuns.length && (- <p className="muted">No runs recorded yet.</p>- )}- {workflowRuns.length > 0 && (- <div className="context-resource-list">- {workflowRuns.map(run => (- <div- key={run.id}- className="context-resource-row workflow-run-row"- data-testid="workflow-run-row"- >- <div className="workflow-run-main">- <div>- <strong>{run.id.slice(0, 8)}</strong>- <p className="muted">- {run.startedAt- ? formatRelativeTime(run.startedAt)- : run.triggeredAt- ? formatRelativeTime(run.triggeredAt)- : 'Pending'}- </p>- </div>- {run.artifacts && run.artifacts.length > 0 && (- <div- className="workflow-run-artifacts"- aria-label="Run artifacts"- >- {run.artifacts.map(artifact => {- const downloadKey = `${run.id}:${artifact.name}`- return (- <Button- key={artifact.name}- className="workflow-run-artifact-btn"- onClick={() =>- void handleDownloadRunArtifact(run.id, artifact)- }- disabled={downloadingArtifact === downloadKey}- color="neutral"- size="xs"- variant="ghost"- >- {downloadingArtifact === downloadKey- ? 'Downloading...'- : artifact.name}- </Button>- )- })}- </div>- )}- </div>- <span- className={`context-access-pill ${workflowStatusTone(- run.phase- )}`}- >- {run.phase}- </span>- </div>- ))}- </div>- )}- </div>- </section>- )}- </Fragment>- )- })}- </div>- </div>+ <section className="page-card mcp-servers-board-card" aria-label="Plugins">+ {loading && !hasRows ? (+ <EmptyState title="Loading" body="Fetching plugins…" />+ ) : !hasRows ? (+ <EmptyState title="No recipes" body="No recipes are deployed in this cluster." />+ ) : (+ <DataTable frameless fullBleed className="mcp-servers-data-table">+ <thead>+ <tr>+ <th className="da-table__col-header" scope="col">+ Name+ </th>+ <th className="da-table__col-header" scope="col">+ Status+ </th>+ <th className="da-table__col-header" scope="col">+ Recent Runs+ </th>+ <th className="da-table__col-header da-table__col-header--right" scope="col">+ Actions+ </th>+ </tr>+ </thead>+ <tbody>+ {workflows.map(wf => (+ <WorkflowRow+ key={workflowKey(wf)}+ wf={wf}+ pendingTriggerKey={pendingTriggerKey}+ onTrigger={w => void handleTrigger(w)}+ />+ ))}+ </tbody>+ </DataTable>+ )}</section></div>++ {triggerModalWorkflow && selectedWorkflowInputContract ? (+ <ConfirmDialog+ title={`Trigger ${triggerModalWorkflow.name}`}+ cancelLabel="Cancel"+ confirmLabel={workflowTriggerLoading ? 'Triggering…' : 'Trigger'}+ onCancel={() => setTriggerModalWorkflow(null)}+ onConfirm={confirmModalTrigger}+ body={+ <InputContractForm+ schema={selectedWorkflowInputContract}+ values={workflowInputValues}+ onChange={setWorkflowInputValues}+ disabled={workflowTriggerLoading}+ />+ }+ />+ ) : null}</section>)}diff --git a/desktop-app/ui/src/pages/__tests__/WorkflowsPage.test.tsx b/desktop-app/ui/src/pages/__tests__/WorkflowsPage.test.tsxindex 6895f87b1..5d277baf6 100644--- a/desktop-app/ui/src/pages/__tests__/WorkflowsPage.test.tsx+++ b/desktop-app/ui/src/pages/__tests__/WorkflowsPage.test.tsx@@ -2,20 +2,34 @@import React from 'react'import { afterEach, describe, expect, it, vi } from 'vitest'import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'-import { useWorkflowController } from '../../hooks/domain/useWorkflowController'+import type { WorkflowInputContractSchema } from '../../../../src/types'+import {+ useWorkflowController,+ useWorkflowRecentRuns,+} from '../../hooks/domain/useWorkflowController'import { WorkflowsPage } from '../WorkflowsPage'+const setStatusSpy = vi.fn()+vi.mock('../../contexts/AuthContext', () => ({- useAuthContext: () => ({ setStatus: vi.fn() }),+ useAuthContext: () => ({ setStatus: setStatusSpy }),}))vi.mock('../../hooks/domain/useWorkflowController', () => ({useWorkflowController: vi.fn(),+ useWorkflowRecentRuns: vi.fn(),}))const useWorkflowControllerMock = vi.mocked(useWorkflowController)+const useWorkflowRecentRunsMock = vi.mocked(useWorkflowRecentRuns)++const CONTRACT: WorkflowInputContractSchema = {+ properties: {+ topic: { type: 'string', default: 'initial topic' },+ },+}-const SELECTED_WORKFLOW = {+const WORKFLOW = {namespace: 'sandbox-recipes',name: 'e2e-ondemand-simple',status: 'Active',@@ -29,120 +43,201 @@ function makeWorkflowsValue(return {workflowsLoading: false,workflowsError: null,- workflows: [SELECTED_WORKFLOW],- selectedWorkflow: SELECTED_WORKFLOW,+ workflows: [WORKFLOW],+ selectedWorkflow: null,selectedWorkflowInputContract: null,- selectedWorkflowSdkCapability: null,workflowInputValues: {},setWorkflowInputValues: vi.fn(),workflowRuns: [],workflowRunsLoading: false,workflowTriggerLoading: false,handleRefreshWorkflows: vi.fn(),- handleSelectWorkflow: vi.fn(),- handleTriggerWorkflow: vi.fn(),- handleRefreshSelectedWorkflow: vi.fn(),+ handleSelectWorkflow: vi.fn().mockResolvedValue(null),+ handleTriggerWorkflow: vi.fn().mockResolvedValue(undefined),loadWorkflowRunsFor: vi.fn(),clearSelectedWorkflow: vi.fn(),resetWorkflows: vi.fn(),...overrides,+ } as unknown as ReturnType<typeof useWorkflowController>+}++function makeRecentRuns(+ overrides: Partial<ReturnType<typeof useWorkflowRecentRuns>> = {}+): ReturnType<typeof useWorkflowRecentRuns> {+ return {+ latestRun: null,+ runCount: 0,+ loading: false,+ refreshing: false,+ error: null,+ refresh: vi.fn().mockResolvedValue(undefined),+ ...overrides,}}-function renderWorkflowsPage(overrides: Partial<ReturnType<typeof useWorkflowController>> = {}) {+function renderWorkflowsPage(+ overrides: Partial<ReturnType<typeof useWorkflowController>> = {},+ recent: Partial<ReturnType<typeof useWorkflowRecentRuns>> = {}+) {useWorkflowControllerMock.mockReturnValue(makeWorkflowsValue(overrides))+ useWorkflowRecentRunsMock.mockReturnValue(makeRecentRuns(recent))return render(<WorkflowsPage />)}describe('WorkflowsPage', () => {afterEach(() => {cleanup()- vi.restoreAllMocks()+ vi.clearAllMocks()delete (window as { clerum?: unknown }).clerum})- it('uses handleRefreshSelectedWorkflow when the detail card refresh button is clicked', () => {- const handleRefreshSelectedWorkflow = vi.fn()- const handleRefreshWorkflows = vi.fn()+ // Invariant 1: flat DataTable with Name/Status/Recent Runs/Actions columns,+ // one row per plugin, no inline accordion / detail panel.+ it('renders a flat table with columns and one row per plugin, no accordion', () => {+ const { container } = renderWorkflowsPage()++ expect(screen.getByRole('heading', { name: /^Plugins$/ })).toBeTruthy()- renderWorkflowsPage({ handleRefreshSelectedWorkflow, handleRefreshWorkflows })+ for (const header of ['Name', 'Status', 'Recent Runs', 'Actions']) {+ expect(screen.getByRole('columnheader', { name: header })).toBeTruthy()+ }- const detailCard = document.querySelector('.workflows-detail-card')- if (!detailCard) throw new Error('missing workflow detail card')- fireEvent.click(within(detailCard as HTMLElement).getByRole('button', { name: 'Refresh' }))+ // One data row for the single plugin; the row shows the name (not the+ // namespace) and the recipe status.+ const rows = within(screen.getByRole('table')).getAllByRole('row')+ // 1 header row + 1 data row+ expect(rows).toHaveLength(2)+ const dataRow = rows[1]!+ expect(within(dataRow).getByText('e2e-ondemand-simple')).toBeTruthy()+ expect(dataRow.textContent).not.toContain('sandbox-recipes')+ expect(within(dataRow).getByText('Active')).toBeTruthy()- expect(handleRefreshSelectedWorkflow).toHaveBeenCalledOnce()- expect(handleRefreshWorkflows).not.toHaveBeenCalled()+ // No accordion / detail panel survives.+ expect(container.querySelector('.workflows-detail-card')).toBeNull()+ expect(container.querySelector('.workflows-detail-extension')).toBeNull()+ expect(container.querySelector('.da-grid')).toBeNull()})- it('disables trigger when the selected workflow does not declare a user on-demand trigger', () => {- const handleTriggerWorkflow = vi.fn()+ // Invariant 2a: Trigger on a recipe WITH an input contract opens the modal+ // and does not fire the trigger yet; confirming the modal fires it.+ it('opens the Trigger modal for a recipe with an input contract', async () => {+ const handleTriggerWorkflow = vi.fn().mockResolvedValue(undefined)+ renderWorkflowsPage({+ handleSelectWorkflow: vi.fn().mockResolvedValue(CONTRACT),+ selectedWorkflowInputContract: CONTRACT,+ handleTriggerWorkflow,+ })++ const rowTrigger = within(screen.getByRole('table')).getByRole('button', { name: 'Trigger' })+ fireEvent.click(rowTrigger)+ const dialog = await screen.findByRole('dialog')+ expect(+ within(dialog).getByRole('heading', { name: /Trigger e2e-ondemand-simple/ })+ ).toBeTruthy()+ expect(dialog.querySelector('.input-contract-form')).not.toBeNull()+ // Not fired until the user confirms.+ expect(handleTriggerWorkflow).not.toHaveBeenCalled()++ fireEvent.click(within(dialog).getByRole('button', { name: 'Trigger' }))+ await waitFor(() =>+ expect(handleTriggerWorkflow).toHaveBeenCalledWith('sandbox-recipes', 'e2e-ondemand-simple')+ )+ })++ // Invariant 2b: Trigger on a recipe WITHOUT a contract fires directly, no modal.+ it('triggers directly (no modal) for a recipe without an input contract', async () => {+ const handleTriggerWorkflow = vi.fn().mockResolvedValue(undefined)renderWorkflowsPage({- selectedWorkflow: { ...SELECTED_WORKFLOW, triggerableByUser: false },+ handleSelectWorkflow: vi.fn().mockResolvedValue(null),+ selectedWorkflowInputContract: null,handleTriggerWorkflow,})- const detailCard = document.querySelector('.workflows-detail-card')- if (!detailCard) throw new Error('missing workflow detail card')- const trigger = within(detailCard as HTMLElement).getByRole('button', { name: 'Trigger' })+ fireEvent.click(within(screen.getByRole('table')).getByRole('button', { name: 'Trigger' }))++ await waitFor(() =>+ expect(handleTriggerWorkflow).toHaveBeenCalledWith(+ 'sandbox-recipes',+ 'e2e-ondemand-simple',+ {}+ )+ )+ expect(screen.queryByRole('dialog')).toBeNull()+ })+ it('does not fire trigger when the recipe declares no user on-demand trigger', () => {+ const handleTriggerWorkflow = vi.fn()+ renderWorkflowsPage({+ workflows: [{ ...WORKFLOW, triggerableByUser: false }],+ handleTriggerWorkflow,+ })++ const trigger = within(screen.getByRole('table')).getByRole('button', { name: 'Trigger' })expect((trigger as HTMLButtonElement).disabled).toBe(true)fireEvent.click(trigger)expect(handleTriggerWorkflow).not.toHaveBeenCalled()})- it('renders workflow rows as real buttons without test-only hooks', () => {- const { container } = renderWorkflowsPage()-- expect(screen.getByRole('heading', { name: /^Plugins$/ })).toBeTruthy()-- const row = screen.getByRole('button', { name: /e2e-ondemand-simple/i })- expect(row.textContent).not.toContain('sandbox-recipes')- expect(row.textContent).toContain('Active')+ // Invariant 3: Recent Runs shows the compact latest-run summary + a count,+ // never the full expanded run list.+ it('renders a compact Recent Runs summary, not the full run list', () => {+ renderWorkflowsPage(+ {},+ {+ latestRun: {+ id: '4771438b-0f8b-47bc-899b-5177b03b742f',+ source: 'live',+ phase: 'Succeeded',+ triggeredAt: '2026-05-06T00:00:00.000Z',+ startedAt: '2026-05-06T00:00:01.000Z',+ completedAt: '2026-05-06T00:00:10.000Z',+ message: null,+ actor: null,+ executionRef: { namespace: 'sandbox-recipes', name: 'child-run-one' },+ artifacts: [],+ },+ runCount: 3,+ }+ )- expect(container.querySelector('[data-testid="workflows-page"]')).toBeNull()- expect(container.querySelector('[data-testid="workflow-row"]')).toBeNull()+ const table = screen.getByRole('table')+ expect(within(table).getByText('Succeeded')).toBeTruthy()+ expect(within(table).getByText(/3 runs/)).toBeTruthy()+ // Compact: exactly one run status pill in the row, never a full list.+ expect(within(table).getAllByText('Succeeded')).toHaveLength(1)})- it('downloads workflow artifacts through the run-scoped workflows API', async () => {+ it('downloads the latest run artifact through the run-scoped workflows API', async () => {const downloadRunArtifact = vi.fn().mockResolvedValue({saved: true,filePath: '/Users/test/Downloads/4771438b-custom-sdk-result.json',filename: '4771438b-custom-sdk-result.json',})- const rpcDownloadArtifact = vi.fn();(window as unknown as { clerum: unknown }).clerum = {workflows: { downloadRunArtifact },- rpc: { downloadArtifact: rpcDownloadArtifact },}- renderWorkflowsPage({- workflowRuns: [- {+ renderWorkflowsPage(+ {},+ {+ latestRun: {id: '4771438b-0f8b-47bc-899b-5177b03b742f',+ source: 'live',phase: 'Succeeded',triggeredAt: '2026-05-06T00:00:00.000Z',startedAt: '2026-05-06T00:00:01.000Z',completedAt: '2026-05-06T00:00:10.000Z',message: null,- actor: { type: 'user', userId: 'user-123' },- executionRef: {- namespace: 'sandbox-recipes',- name: 'child-run-one',- },- source: 'live',+ actor: null,+ executionRef: { namespace: 'sandbox-recipes', name: 'child-run-one' },artifacts: [- {- name: 'custom-sdk-result.json',- format: 'json',- sizeBytes: 42,- createdAt: '2026-05-06T00:00:10.000Z',- },+ { name: 'custom-sdk-result.json', format: 'json', sizeBytes: 42, createdAt: 'x' },],},- ],- })+ runCount: 1,+ }+ )fireEvent.click(screen.getByRole('button', { name: 'custom-sdk-result.json' }))@@ -154,10 +249,14 @@ describe('WorkflowsPage', () => {'custom-sdk-result.json')})- expect(- await screen.findByText('Saved 4771438b-custom-sdk-result.json to Downloads.')- ).toBeTruthy()- expect(rpcDownloadArtifact).not.toHaveBeenCalled()+ await waitFor(() =>+ expect(setStatusSpy).toHaveBeenCalledWith(+ 'Saved 4771438b-custom-sdk-result.json to Downloads.',+ 'success',+ undefined,+ { global: false, toast: true }+ )+ )})it('does not style completed recipes as failed', () => {@@ -176,10 +275,9 @@ describe('WorkflowsPage', () => {triggerableByUser: true,},],- selectedWorkflow: null,})- expect(screen.getByText('completed').className).toContain('allowed')- expect(screen.getByText('failed').className).toContain('denied')+ expect(screen.getByText('completed').className).toContain('ui-pill--success')+ expect(screen.getByText('failed').className).toContain('ui-pill--danger')})})diff --git a/desktop-app/ui/src/styles.css b/desktop-app/ui/src/styles.cssindex 29ebadf7a..d0e737367 100644--- a/desktop-app/ui/src/styles.css+++ b/desktop-app/ui/src/styles.css@@ -7831,23 +7831,11 @@ h3 {align-content: start;}-/* `.workflows-list-card` is a standalone-grid card — the da-grid itself owns- the visual frame (border/radius/bg). Remove the redundant page-card frame- so there is only one border around the table. */-.workflows-list-card {- border: none;- background: transparent;- box-shadow: none;- padding: 0;- gap: var(--space-2);-}-/* Subtler `--list-item-*` palette so multiple board listings share the sameunderstated visual instead of the stronger default `--grid-card-*` look. */.contexts-board-card .da-grid,.context-detail-page .da-grid,-.team-detail-page .da-grid,-.workflows-list-card .da-grid {+.team-detail-page .da-grid {--grid-card-bg: var(--list-item-bg);--grid-card-border: rgba(var(--edge-rgb), 0.14);--grid-card-bg-hover: var(--list-item-hover-bg);@@ -7858,8 +7846,7 @@ h3 {.contexts-board-card .da-grid__row,.context-detail-page .da-grid__row,-.team-detail-page .da-grid__row,-.workflows-list-card .da-grid__row {+.team-detail-page .da-grid__row {border-radius: var(--radius-lg); /* 12px — matches legacy `.context-table-row` */}@@ -7886,50 +7873,27 @@ h3 {flex: 0 0 auto;}-.workflows-list-card .workflow-row--expanded {- border-bottom-right-radius: 0;- border-bottom-left-radius: 0;-}--.workflows-detail-extension {- display: grid;- gap: var(--space-3);- margin-top: calc(-1 * var(--grid-row-gap));- padding: var(--space-3) var(--space-4) var(--space-4);- border: 1px solid var(--grid-card-border-selected);- border-top: 0;- border-radius: 0 0 var(--radius-lg) var(--radius-lg);- background: rgba(var(--accent-rgb), 0.06);-}--.workflows-detail-extension__header {+/* Compact "Recent Runs" cell for the flat Plugins table (spec 12 §5.F):+ latest run summary on one line, its artifact download buttons wrapping below.+ Replaces the old inline accordion detail panel. */+.workflow-recent-runs {display: flex;- align-items: center;- justify-content: space-between;- gap: var(--space-3);-}--.workflows-detail-extension__title {- margin: 0;- color: var(--text);- font-size: var(--font-size-lg);- line-height: var(--line-height-tight);+ flex-direction: column;+ gap: var(--space-1-5);+ min-width: 0;}-.workflows-detail-extension__title-group {+.workflow-recent-runs__summary {display: flex;align-items: center;- gap: var(--space-2);- min-width: 0;-}--.workflows-detail-extension__section {- display: grid;- gap: var(--space-2);+ flex-wrap: wrap;+ gap: var(--space-1-5);}-.workflows-detail-extension__section h4 {- margin: 0;+.workflow-recent-runs__artifacts {+ display: flex;+ flex-wrap: wrap;+ gap: var(--space-1);}/* When `.context-id-cell` is the first cell of a `.da-grid__row`, every@@ -8052,16 +8016,6 @@ h3 {gap: var(--space-2);}-.workflow-run-row {- align-items: flex-start;-}--.workflow-run-main {- min-width: 0;- display: grid;- gap: var(--space-1-5);-}-.workflow-run-artifacts {display: flex;flex-wrap: wrap;