The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(settings): remove the dead Play button from Agent Workflows
purplea296c769b365
diff --git a/src/components/agents/WorkflowList.tsx b/src/components/agents/WorkflowList.tsxindex 39379b26..418ec971 100644--- a/src/components/agents/WorkflowList.tsx+++ b/src/components/agents/WorkflowList.tsx@@ -1,5 +1,5 @@import { useState } from 'react'-import { Play, Pencil, Trash2, Copy, Plus, Search, FileText, Code, Zap } from 'lucide-react'+import { Pencil, Trash2, Copy, Plus, Search, FileText, Code, Zap } from 'lucide-react'import { useAgentWorkflowStore } from '../../stores/agentWorkflowStore'import type { AgentWorkflow } from '../../types/agent-workflows'@@ -9,12 +9,11 @@ const ICON_MAP: Record<string, typeof Search> = {}interface WorkflowListProps {- onRun: (workflowId: string) => voidonEdit: (workflowId: string) => voidonCreate: () => void}-export function WorkflowList({ onRun, onEdit, onCreate }: WorkflowListProps) {+export function WorkflowList({ onEdit, onCreate }: WorkflowListProps) {const { workflows, removeWorkflow, duplicateWorkflow } = useAgentWorkflowStore()const [confirmDelete, setConfirmDelete] = useState<string | null>(null)@@ -47,13 +46,6 @@ export function WorkflowList({ onRun, onEdit, onCreate }: WorkflowListProps) {<p className="text-[0.55rem] text-gray-600">{workflow.steps.length} steps</p></div><div className="flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity shrink-0">- <button- onClick={() => onRun(workflow.id)}- className="p-1 rounded hover:bg-green-500/20 text-gray-500 hover:text-green-400"- title="Run"- >- <Play size={11} />- </button>{!workflow.isBuiltIn && (<buttononClick={() => onEdit(workflow.id)}diff --git a/src/components/agents/WorkflowRunner.tsx b/src/components/agents/WorkflowRunner.tsxdeleted file mode 100644index fdd2c594..00000000--- a/src/components/agents/WorkflowRunner.tsx+++ /dev/null@@ -1,169 +0,0 @@-import { useEffect, useState } from 'react'-import { Loader2, Check, X, Circle, Send, Square } from 'lucide-react'-import { useAgentWorkflowStore } from '../../stores/agentWorkflowStore'-import { Hinweis } from '../ui/Hinweis'-import type { StepStatus } from '../../types/agent-workflows'--const STATUS_ICONS: Record<StepStatus | 'waiting', typeof Check> = {- pending: Circle,- running: Loader2,- completed: Check,- failed: X,- skipped: Circle,- waiting: Loader2,-}--// `waiting` war gelb und stand damit zwischen „laeuft" und „kaputt", als gaebe-// es einen halben Fehler. Es gibt keinen: der Lauf laeuft, er haengt nur an-// einer Eingabe. Also dieselbe Farbe wie `running`. Was die beiden trennt, ist-// die Bewegung (Puls statt Drehung) und die Frage, die darunter steht.-const STATUS_COLORS: Record<StepStatus | 'waiting', string> = {- pending: 'text-gray-600',- running: 'text-blue-400 animate-spin',- completed: 'text-green-400',- failed: 'text-red-400',- skipped: 'text-gray-600',- waiting: 'text-blue-400 animate-pulse',-}--interface WorkflowRunnerProps {- executionId: string- workflowSteps: Array<{ id: string; label: string; type: string }>- waitingForInput: string | null- onProvideInput: (input: string) => void- onCancel: () => void-}--export function WorkflowRunner({- executionId,- workflowSteps,- waitingForInput,- onProvideInput,- onCancel,-}: WorkflowRunnerProps) {- const execution = useAgentWorkflowStore((s) => s.executions.find(e => e.id === executionId))- const [inputValue, setInputValue] = useState('')-- // The clock the "Running… Ns" line divides by. It used to be `Date.now()`- // read straight from the render body — impure (React 19 `purity`), and it- // only advanced when the store happened to push a step update, so a slow- // step froze the counter. A one-second tick while the run is live says the- // same thing honestly; a finished run needs no clock at all.- const live = execution?.status === 'running' || execution?.status === 'waiting_input'- const [now, setNow] = useState(() => Date.now())- useEffect(() => {- if (!live) return- const t = setInterval(() => setNow(Date.now()), 1000)- return () => clearInterval(t)- }, [live, executionId])-- if (!execution) return null-- const handleSubmitInput = () => {- if (!inputValue.trim()) return- onProvideInput(inputValue.trim())- setInputValue('')- }-- const elapsed = execution.completedAt- ? Math.round((execution.completedAt - execution.startedAt) / 1000)- : Math.max(0, Math.round((now - execution.startedAt) / 1000))-- return (- <div className="space-y-3 p-3 rounded-lg border border-white/10 bg-white/[0.02]">- {/* Header */}- <div className="flex items-center justify-between">- <div>- <p className="text-[0.7rem] font-medium text-gray-200">{execution.workflowName}</p>- <p className="t-micro text-gray-500">- {execution.status === 'running' || execution.status === 'waiting_input'- ? `Running... ${elapsed}s`- : execution.status === 'completed'- ? `Completed in ${elapsed}s`- : execution.status === 'failed'- ? `Failed after ${elapsed}s`- : execution.status === 'cancelled'- ? 'Cancelled'- : execution.status}- </p>- </div>- {(execution.status === 'running' || execution.status === 'waiting_input') && (- <button- onClick={onCancel}- className="p-1 rounded hover:bg-red-500/20 text-gray-500 hover:text-red-400"- title="Cancel"- >- <Square size={12} />- </button>- )}- </div>-- {/* Step progress */}- <div className="space-y-1">- {workflowSteps.map((step, index) => {- const result = execution.stepResults.find(r => r.stepId === step.id)- let status: StepStatus | 'waiting' = 'pending'- if (result) {- status = result.status- } else if (index === execution.currentStepIndex && execution.status === 'waiting_input') {- status = 'waiting'- } else if (index === execution.currentStepIndex && execution.status === 'running') {- status = 'running'- }-- const Icon = STATUS_ICONS[status]-- return (- <div key={step.id} className="flex items-start gap-2">- <Icon size={11} className={`mt-0.5 shrink-0 ${STATUS_COLORS[status]}`} />- <div className="flex-1 min-w-0">- <p className={`t-micro ${status === 'completed' || status === 'running' || status === 'waiting' ? 'text-gray-300' : 'text-gray-500'}`}>- {step.label}- </p>- {result?.output && status === 'completed' && (- <p className="t-micro text-gray-500 truncate mt-0.5">- {result.output.substring(0, 100)}- </p>- )}- {result?.error && (- <p className="t-micro text-red-400/70 mt-0.5">{result.error}</p>- )}- </div>- </div>- )- })}- </div>-- {/* User input prompt */}- {waitingForInput && (- <div className="space-y-1.5 pt-1 border-t border-white/5">- {/* Das ist die Frage an den Nutzer, keine Warnung. Sie gehoert zum- Feld darunter und traegt deshalb dessen Textfarbe. */}- <p className="t-micro text-gray-200">{waitingForInput}</p>- <div className="flex gap-1.5">- <input- value={inputValue}- onChange={(e) => setInputValue(e.target.value)}- onKeyDown={(e) => e.key === 'Enter' && handleSubmitInput()}- placeholder="Type your input..."- className="flex-1 px-2 py-1 rounded bg-white/5 border border-white/10 text-[0.7rem] text-gray-300 placeholder-gray-600 focus:outline-none focus:border-white/20"- autoFocus- />- <button- onClick={handleSubmitInput}- className="px-2 py-1 rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors"- >- <Send size={11} />- </button>- </div>- </div>- )}-- {/* Error. Der Kasten um die Zeile ist weg: die rote Schrift sagt schon- alles, was Rahmen und Fuellflaeche dazutun sollten. */}- {execution.error && (- <Hinweis ton="fehler">{execution.error}</Hinweis>- )}- </div>- )-}diff --git a/src/components/agents/__tests__/workflow-list-hat-keinen-play-knopf.test.tsx b/src/components/agents/__tests__/workflow-list-hat-keinen-play-knopf.test.tsxnew file mode 100644index 00000000..59c7e279--- /dev/null+++ b/src/components/agents/__tests__/workflow-list-hat-keinen-play-knopf.test.tsx@@ -0,0 +1,70 @@+// @vitest-environment jsdom+/**+ * bau/review-wfplay.md Teil A, klaerung-n4.md Fund 2: der Play-Knopf neben+ * einem Arbeitsablauf in Settings > Agent > Agent Workflows war tot+ * (`onRun={() => {}}` in SettingsPage.tsx). Der Knopf ist entfernt statt+ * verdrahtet zu werden, denn der Weg, ihn "echt" zu machen, wurde in+ * fix/301-wfplay geprueft und mit Auflagen 1-4 (Blocker) zurueckgewiesen: der+ * einzige tatsaechlich funktionierende Startweg fuer einen Ablauf bleibt das+ * Agenten-Werkzeug `run_workflow`.+ *+ * Dieser Test haelt fest, dass die Liste ohne den Knopf rendert und die+ * beiden anderen Aktionen (Bearbeiten, Loeschen) unveraendert da sind.+ */+import { beforeEach, describe, expect, it, vi } from 'vitest'+import { cleanup, render, screen } from '@testing-library/react'+import { WorkflowList } from '../WorkflowList'+import { useAgentWorkflowStore } from '../../../stores/agentWorkflowStore'+import type { AgentWorkflow } from '../../../types/agent-workflows'++function workflow(overrides: Partial<AgentWorkflow> = {}): AgentWorkflow {+ return {+ id: 'wf-1',+ name: 'Custom workflow',+ description: 'a test workflow',+ icon: 'Zap',+ steps: [],+ variables: {},+ isBuiltIn: false,+ createdAt: 0,+ updatedAt: 0,+ ...overrides,+ }+}++beforeEach(() => {+ cleanup()+ useAgentWorkflowStore.setState({ workflows: [workflow()], executions: [], activeExecutionId: null })+})++describe('WorkflowList', () => {+ it('renders without a Run/Play control', () => {+ render(<WorkflowList onEdit={() => {}} onCreate={() => {}} />)++ expect(screen.queryByTitle('Run')).toBeNull()+ // The lucide Play icon renders an svg with this class; the surest+ // negative is simply that no button anywhere is titled "Run".+ expect(screen.queryAllByRole('button').some((b) => b.getAttribute('title') === 'Run')).toBe(false)+ })++ it('keeps Edit and Delete for a custom workflow', () => {+ render(<WorkflowList onEdit={() => {}} onCreate={() => {}} />)++ expect(screen.getByTitle('Edit')).toBeTruthy()+ expect(screen.getByTitle('Delete')).toBeTruthy()+ })++ it('Edit still calls back with the workflow id', () => {+ const onEdit = vi.fn()+ render(<WorkflowList onEdit={onEdit} onCreate={() => {}} />)++ screen.getByTitle('Edit').click()+ expect(onEdit).toHaveBeenCalledWith('wf-1')+ })++ it('does not accept an onRun prop anymore (compile-time contract)', () => {+ // @ts-expect-error onRun was removed with the dead button; a caller+ // that still passes it should not type-check.+ render(<WorkflowList onRun={() => {}} onEdit={() => {}} onCreate={() => {}} />)+ })+})diff --git a/src/components/settings/SettingsPage.tsx b/src/components/settings/SettingsPage.tsxindex 3c2aab84..b0b270f1 100644--- a/src/components/settings/SettingsPage.tsx+++ b/src/components/settings/SettingsPage.tsx@@ -246,7 +246,6 @@ function WorkflowSection() {return (<WorkflowList- onRun={() => {}}onEdit={(id) => { setEditingId(id); setWfView('builder') }}onCreate={() => { setEditingId(undefined); setWfView('builder') }}/>diff --git a/src/hooks/useWorkflow.ts b/src/hooks/useWorkflow.tsdeleted file mode 100644index 091c1c03..00000000--- a/src/hooks/useWorkflow.ts+++ /dev/null@@ -1,135 +0,0 @@-/**- * useWorkflow — Hook for running agent workflows.- *- * Manages workflow lifecycle: start, provide input, cancel.- * Delegates execution to WorkflowEngine.- */--import { useRef, useState, useCallback } from 'react'-import { WorkflowEngine } from '../lib/workflow-engine'-import { useAgentWorkflowStore } from '../stores/agentWorkflowStore'-import { useChatStore } from '../stores/chatStore'-import { v4 as uuid } from 'uuid'-import type { StepResult, WorkflowEngineCallbacks } from '../types/agent-workflows'--export function useWorkflow() {- const [isRunning, setIsRunning] = useState(false)- const [waitingForInput, setWaitingForInput] = useState<string | null>(null)- const [currentStepLabel, setCurrentStepLabel] = useState('')- const engineRef = useRef<WorkflowEngine | null>(null)-- const startWorkflow = useCallback(async (- workflowId: string,- variables?: Record<string, string>- ) => {- const store = useAgentWorkflowStore.getState()- const workflow = store.getWorkflow(workflowId)- if (!workflow) return-- const chatStore = useChatStore.getState()- const convId = chatStore.activeConversationId || chatStore.createConversation(- '', // model will be resolved by engine- ''- )-- const executionId = store.startExecution(workflowId, convId)- if (!executionId) return-- setIsRunning(true)- setWaitingForInput(null)-- // Add workflow start message to chat- chatStore.addMessage(convId, {- id: uuid(),- role: 'assistant',- content: `Running workflow: **${workflow.name}**...`,- timestamp: Date.now(),- })-- const callbacks: WorkflowEngineCallbacks = {- onStepStart: (stepIndex, step) => {- setCurrentStepLabel(step.label)- store.updateExecution(executionId, { currentStepIndex: stepIndex })- },- onStepComplete: (_stepIndex, result) => {- store.addStepResult(executionId, result)- },- onStepError: (stepIndex, error) => {- store.addStepResult(executionId, {- stepId: workflow.steps[stepIndex].id,- status: 'failed',- output: '',- startedAt: Date.now(),- error,- })- },- onWaitingForInput: (_stepIndex, prompt) => {- setWaitingForInput(prompt)- store.updateExecution(executionId, { status: 'waiting_input' })- },- onComplete: (results: StepResult[]) => {- store.updateExecution(executionId, {- status: 'completed',- completedAt: Date.now(),- })-- // Add final result to chat- const lastOutput = results.filter(r => r.output).pop()- if (lastOutput) {- chatStore.addMessage(convId, {- id: uuid(),- role: 'assistant',- content: lastOutput.output,- timestamp: Date.now(),- })- }- },- onError: (error) => {- store.updateExecution(executionId, {- status: 'failed',- completedAt: Date.now(),- error,- })- chatStore.addMessage(convId, {- id: uuid(),- role: 'assistant',- content: `Workflow failed: ${error}`,- timestamp: Date.now(),- })- },- }-- const engine = new WorkflowEngine(workflow, convId, callbacks, variables)- engineRef.current = engine-- try {- await engine.run()- } finally {- setIsRunning(false)- setWaitingForInput(null)- setCurrentStepLabel('')- engineRef.current = null- }- }, [])-- const provideInput = useCallback((input: string) => {- engineRef.current?.provideUserInput(input)- setWaitingForInput(null)- }, [])-- const cancelWorkflow = useCallback(() => {- engineRef.current?.cancel()- setIsRunning(false)- setWaitingForInput(null)- setCurrentStepLabel('')- }, [])-- return {- startWorkflow,- provideInput,- cancelWorkflow,- isRunning,- waitingForInput,- currentStepLabel,- }-}diff --git a/src/lib/__tests__/workflow-teilt-sich-unterhaltung-mit-laufendem-chat.test.ts b/src/lib/__tests__/workflow-teilt-sich-unterhaltung-mit-laufendem-chat.test.tsindex 0537d804..7ea2ed4d 100644--- a/src/lib/__tests__/workflow-teilt-sich-unterhaltung-mit-laufendem-chat.test.ts+++ b/src/lib/__tests__/workflow-teilt-sich-unterhaltung-mit-laufendem-chat.test.ts@@ -4,8 +4,14 @@** Gemessen: eine fremde Unterhaltung haelt die lokale Spur, in Unterhaltung* `a` laeuft ein Chat und hat seinen Abbruchgriff registriert, dann startet- * aus dem Ablauf-Fenster ein Arbeitsablauf, der `activeConversationId` als- * Buchungskennung nimmt (`useWorkflow.ts:30`) und sich anstellt.+ * ein Arbeitsablauf, der dieselbe Unterhaltung als Buchungskennung nimmt+ * (`this.conversationId`, siehe der Kommentar in `workflow-engine.ts`s+ * `run()`) und sich anstellt. Der urspruengliche Messfall kam ueber den+ * inzwischen entfernten Settings-Play-Knopf und `useWorkflow.ts`+ * (`activeConversationId`, seit review-wfplay.md geloescht); der Fix in+ * `run-slot.ts` selbst ist an der Buchungskennung verankert und gilt daher+ * unveraendert fuer den heutigen einzigen Startweg, den `run_workflow`-+ * Werkzeugaufruf.* `run-slot.ts` registrierte beim Anstellen seinen eigenen Griff unter* DERSELBEN Kennung und ueberschrieb damit den des laufenden Chats; am Ende* loeschte `aufraeumen` ihn ersatzlos. Solange der Ablauf wartete, rief@@ -45,6 +51,7 @@*/import { describe, it, expect, beforeEach, vi } from 'vitest'import { WorkflowEngine } from '../workflow-engine'+import { APPROVE_ALL } from '../../api/agents/tool-executor'import { runInLane } from '../run-slot'import { localLaneHolder, queuedRunIds, __resetRunLanesForTests } from '../run-lanes'import { useGenerationStore } from '../../stores/generationStore'@@ -133,7 +140,7 @@ describe("Opus' Messfall: ein Chat laeuft in 'a', ein Arbeitsablauf stellt sichexpect(localLaneHolder()).toBe('a')const errors: string[] = []- const engine = new WorkflowEngine(workflowOf([noteStep('x')]), 'a', callbacks((e) => errors.push(e)))+ const engine = new WorkflowEngine(workflowOf([noteStep('x')]), 'a', callbacks((e) => errors.push(e)), APPROVE_ALL)const ablaufLauf = engine.run()await takte(3)@@ -166,7 +173,7 @@ describe("Opus' Messfall: ein Chat laeuft in 'a', ein Arbeitsablauf stellt sichawait takte(3)const errors: string[] = []- const engine = new WorkflowEngine(workflowOf([noteStep('x')]), 'a', callbacks((e) => errors.push(e)))+ const engine = new WorkflowEngine(workflowOf([noteStep('x')]), 'a', callbacks((e) => errors.push(e)), APPROVE_ALL)const ablaufLauf = engine.run()await takte(3)expect(queuedRunIds()).toEqual(['a'])@@ -190,7 +197,7 @@ describe('NEGATIVKONTROLLE: ohne einen zweiten, sich die Kennung teilenden Lauf// ueberhaupt geprueft werden kann, dass er noch laeuft.const step: WorkflowStep = { id: 'warte', type: 'user_input', label: 'warte', userInputPrompt: 'weiter?' }const errors: string[] = []- const engine = new WorkflowEngine(workflowOf([step]), 'allein', callbacks((e) => errors.push(e)))+ const engine = new WorkflowEngine(workflowOf([step]), 'allein', callbacks((e) => errors.push(e)), APPROVE_ALL)const ablaufLauf = engine.run()await takte(2)expect(localLaneHolder()).toBe('allein')