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(agent): delete the dead workflow execution-history slice
purple2000805d062c
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.tsxindex 59c7e279..0ca2f39d 100644--- 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.tsx@@ -5,8 +5,12 @@* (`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`.+ * verbleibende Startweg fuer einen Ablauf ist das Agenten-Werkzeug+ * `run_workflow` (und der Chat-Ausloeser "run workflow <name>"). Richtigstellung,+ * bau/review-wfgate.md Auflage 6: "funktionierend" war zum Zeitpunkt dieses+ * Kommentars zu grosszuegig formuliert, alle drei eingebauten Ablaeufe+ * haengen ueber diesen Weg am ersten user_input-Schritt, siehe die Korrektur+ * dazu in workflow-engine.ts (`prefilledUserInput`).** Dieser Test haelt fest, dass die Liste ohne den Knopf rendert und die* beiden anderen Aktionen (Bearbeiten, Loeschen) unveraendert da sind.@@ -34,7 +38,7 @@ function workflow(overrides: Partial<AgentWorkflow> = {}): AgentWorkflow {beforeEach(() => {cleanup()- useAgentWorkflowStore.setState({ workflows: [workflow()], executions: [], activeExecutionId: null })+ useAgentWorkflowStore.setState({ workflows: [workflow()] })})describe('WorkflowList', () => {diff --git a/src/lib/__tests__/workflow-e2e.test.ts b/src/lib/__tests__/workflow-e2e.test.tsindex 92a685a3..0711bcf9 100644--- a/src/lib/__tests__/workflow-e2e.test.ts+++ b/src/lib/__tests__/workflow-e2e.test.ts@@ -8,8 +8,6 @@ import { useMemoryStore } from '../../stores/memoryStore'function resetStores() {useAgentWorkflowStore.setState({workflows: [...BUILT_IN_WORKFLOWS],- executions: [],- activeExecutionId: null,})useMemoryStore.setState({entries: [],@@ -166,70 +164,13 @@ describe('Workflow Store CRUD', () => {})// ── Workflow Execution Store ───────────────────────────────────--describe('Workflow Execution Store', () => {- beforeEach(resetStores)-- it('startExecution creates execution record', () => {- const builtInId = BUILT_IN_WORKFLOWS[0].id- const execId = useAgentWorkflowStore.getState().startExecution(builtInId, 'conv-123')-- expect(execId).toBeTruthy()- const { executions, activeExecutionId } = useAgentWorkflowStore.getState()- expect(executions).toHaveLength(1)- expect(executions[0].workflowId).toBe(builtInId)- expect(executions[0].status).toBe('running')- expect(executions[0].conversationId).toBe('conv-123')- expect(activeExecutionId).toBe(execId)- })-- it('startExecution returns null for non-existent workflow', () => {- const result = useAgentWorkflowStore.getState().startExecution('non-existent')- expect(result).toBeNull()- })-- it('updateExecution modifies execution fields', () => {- const execId = useAgentWorkflowStore.getState().startExecution(BUILT_IN_WORKFLOWS[0].id)!- useAgentWorkflowStore.getState().updateExecution(execId, { status: 'waiting_input' })- expect(useAgentWorkflowStore.getState().executions[0].status).toBe('waiting_input')- })-- it('addStepResult appends result and increments step index', () => {- const execId = useAgentWorkflowStore.getState().startExecution(BUILT_IN_WORKFLOWS[0].id)!- useAgentWorkflowStore.getState().addStepResult(execId, {- stepId: 'step-1', status: 'completed', output: 'Step 1 done', startedAt: Date.now(), completedAt: Date.now(),- })-- const exec = useAgentWorkflowStore.getState().executions[0]- expect(exec.stepResults).toHaveLength(1)- expect(exec.currentStepIndex).toBe(1)- })-- it('cancelExecution sets status and clears active', () => {- const execId = useAgentWorkflowStore.getState().startExecution(BUILT_IN_WORKFLOWS[0].id)!- useAgentWorkflowStore.getState().cancelExecution(execId)-- const exec = useAgentWorkflowStore.getState().executions[0]- expect(exec.status).toBe('cancelled')- expect(exec.completedAt).toBeGreaterThan(0)- expect(useAgentWorkflowStore.getState().activeExecutionId).toBeNull()- })-- it('caps execution history at 50', () => {- for (let i = 0; i < 55; i++) {- useAgentWorkflowStore.getState().startExecution(BUILT_IN_WORKFLOWS[0].id, `conv-${i}`)- }- expect(useAgentWorkflowStore.getState().executions.length).toBeLessThanOrEqual(50)- })-- it('clearExecutionHistory removes all', () => {- useAgentWorkflowStore.getState().startExecution(BUILT_IN_WORKFLOWS[0].id)- useAgentWorkflowStore.getState().startExecution(BUILT_IN_WORKFLOWS[1].id)- useAgentWorkflowStore.getState().clearExecutionHistory()- expect(useAgentWorkflowStore.getState().executions).toHaveLength(0)- expect(useAgentWorkflowStore.getState().activeExecutionId).toBeNull()- })-})+//+// Auflage 7, bau/review-wfgate.md: this describe block used to exercise the+// store's execution-history slice (`startExecution`, `updateExecution`,+// `addStepResult`, `cancelExecution`, `clearExecutionHistory`), deleted as+// dead code alongside the `useWorkflow.ts` hook that was its only+// production caller (commit 8ca0df85). WorkflowEngine (workflow-engine.ts)+// tracks a run's own state independently of this store.// ── Variable Interpolation (indirect via built-in workflow templates) ──@@ -289,19 +230,10 @@ describe('Workflow Lifecycle E2E', () => {const copyId = useAgentWorkflowStore.getState().duplicateWorkflow(id)!expect(useAgentWorkflowStore.getState().getWorkflow(copyId)!.name).toBe('My Workflow v2 (copy)')- // Start execution- const execId = useAgentWorkflowStore.getState().startExecution(id)!- expect(useAgentWorkflowStore.getState().executions[0].status).toBe('running')-- // Simulate step completion- useAgentWorkflowStore.getState().addStepResult(execId, {- stepId: 's1', status: 'completed', output: 'user typed something', startedAt: Date.now(),- })- expect(useAgentWorkflowStore.getState().executions[0].stepResults).toHaveLength(1)-- // Complete execution- useAgentWorkflowStore.getState().updateExecution(execId, { status: 'completed', completedAt: Date.now() })- expect(useAgentWorkflowStore.getState().executions[0].status).toBe('completed')+ // Run: WorkflowEngine tracks a run's own state independently of this+ // store (Auflage 7, bau/review-wfgate.md removed the store's own+ // execution-history slice as dead code), so lifecycle coverage of an+ // actual run lives in workflow-engine-*.test.ts, not here.// Delete customuseAgentWorkflowStore.getState().removeWorkflow(id)diff --git a/src/stores/__tests__/agentWorkflowStore.test.ts b/src/stores/__tests__/agentWorkflowStore.test.tsindex a3087f13..4916fa3e 100644--- a/src/stores/__tests__/agentWorkflowStore.test.ts+++ b/src/stores/__tests__/agentWorkflowStore.test.ts@@ -21,7 +21,6 @@ vi.mock('../../lib/built-in-workflows', () => ({}))import { useAgentWorkflowStore } from '../agentWorkflowStore'-import type { StepResult } from '../../types/agent-workflows'describe('agentWorkflowStore', () => {beforeEach(() => {@@ -39,8 +38,6 @@ describe('agentWorkflowStore', () => {updatedAt: 1000,},],- executions: [],- activeExecutionId: null,})})@@ -191,114 +188,10 @@ describe('agentWorkflowStore', () => {})})- // ── startExecution ─────────────────────────────────────────-- describe('startExecution', () => {- it('creates execution with running status and currentStepIndex=0', () => {- const execId = useAgentWorkflowStore.getState().startExecution('builtin-1', 'conv-1')- expect(execId).not.toBeNull()- const exec = useAgentWorkflowStore.getState().executions[0]- expect(exec.status).toBe('running')- expect(exec.currentStepIndex).toBe(0)- expect(exec.conversationId).toBe('conv-1')- })-- it('copies workflow variables to execution', () => {- const execId = useAgentWorkflowStore.getState().startExecution('builtin-1')!- const exec = useAgentWorkflowStore.getState().executions.find(e => e.id === execId)!- expect(exec.variables).toEqual({ topic: 'default' })- })-- it('sets activeExecutionId', () => {- const execId = useAgentWorkflowStore.getState().startExecution('builtin-1')- expect(useAgentWorkflowStore.getState().activeExecutionId).toBe(execId)- })-- it('returns null for non-existent workflow', () => {- const result = useAgentWorkflowStore.getState().startExecution('nonexistent')- expect(result).toBeNull()- })-- it('trims execution history to MAX_EXECUTION_HISTORY (50)', () => {- // Fill up with 50 executions- for (let i = 0; i < 55; i++) {- useAgentWorkflowStore.getState().startExecution('builtin-1')- }- expect(useAgentWorkflowStore.getState().executions.length).toBeLessThanOrEqual(50)- })- })-- // ── addStepResult ──────────────────────────────────────────-- describe('addStepResult', () => {- it('appends result and increments currentStepIndex', () => {- const execId = useAgentWorkflowStore.getState().startExecution('builtin-1')!- const result: StepResult = {- stepId: 's1',- status: 'completed',- output: 'done',- startedAt: Date.now(),- completedAt: Date.now(),- }- useAgentWorkflowStore.getState().addStepResult(execId, result)- const exec = useAgentWorkflowStore.getState().executions.find(e => e.id === execId)!- expect(exec.stepResults).toHaveLength(1)- expect(exec.stepResults[0].stepId).toBe('s1')- expect(exec.currentStepIndex).toBe(1)- })-- it('adds multiple step results sequentially', () => {- const execId = useAgentWorkflowStore.getState().startExecution('builtin-1')!- for (let i = 0; i < 3; i++) {- useAgentWorkflowStore.getState().addStepResult(execId, {- stepId: `s${i}`,- status: 'completed',- output: `output-${i}`,- startedAt: Date.now(),- })- }- const exec = useAgentWorkflowStore.getState().executions.find(e => e.id === execId)!- expect(exec.stepResults).toHaveLength(3)- expect(exec.currentStepIndex).toBe(3)- })- })-- // ── cancelExecution ────────────────────────────────────────-- describe('cancelExecution', () => {- it('sets status to cancelled and completedAt', () => {- const execId = useAgentWorkflowStore.getState().startExecution('builtin-1')!- const before = Date.now()- useAgentWorkflowStore.getState().cancelExecution(execId)- const exec = useAgentWorkflowStore.getState().executions.find(e => e.id === execId)!- expect(exec.status).toBe('cancelled')- expect(exec.completedAt).toBeGreaterThanOrEqual(before)- })-- it('clears activeExecutionId if cancelled execution was active', () => {- const execId = useAgentWorkflowStore.getState().startExecution('builtin-1')!- expect(useAgentWorkflowStore.getState().activeExecutionId).toBe(execId)- useAgentWorkflowStore.getState().cancelExecution(execId)- expect(useAgentWorkflowStore.getState().activeExecutionId).toBeNull()- })-- it('does not clear activeExecutionId if a different execution is cancelled', () => {- const exec1 = useAgentWorkflowStore.getState().startExecution('builtin-1')!- const exec2 = useAgentWorkflowStore.getState().startExecution('builtin-1')!- // exec2 is now active- useAgentWorkflowStore.getState().cancelExecution(exec1)- expect(useAgentWorkflowStore.getState().activeExecutionId).toBe(exec2)- })- })-- // ── clearExecutionHistory ──────────────────────────────────-- describe('clearExecutionHistory', () => {- it('clears all executions and activeExecutionId', () => {- useAgentWorkflowStore.getState().startExecution('builtin-1')- useAgentWorkflowStore.getState().clearExecutionHistory()- expect(useAgentWorkflowStore.getState().executions).toEqual([])- expect(useAgentWorkflowStore.getState().activeExecutionId).toBeNull()- })- })+ // Auflage 7, bau/review-wfgate.md: the execution-history slice this store+ // used to carry (`startExecution`, `updateExecution`, `addStepResult`,+ // `cancelExecution`, `clearExecutionHistory`, `activeExecutionId`,+ // `MAX_EXECUTION_HISTORY`) was deleted as dead code, its last production+ // reader and writer having gone with the deleted `useWorkflow.ts` (commit+ // 8ca0df85). The test cases that exercised it are removed with it.})diff --git a/src/stores/agentWorkflowStore.ts b/src/stores/agentWorkflowStore.tsindex 74483bc4..6e99d096 100644--- a/src/stores/agentWorkflowStore.ts+++ b/src/stores/agentWorkflowStore.ts@@ -2,20 +2,23 @@ import { create } from 'zustand'import { persist } from 'zustand/middleware'import { safeJSONStorage } from '../lib/storage-quota'import { v4 as uuid } from 'uuid'-import type { AgentWorkflow, WorkflowExecution, StepResult } from '../types/agent-workflows'+import type { AgentWorkflow } from '../types/agent-workflows'import { BUILT_IN_WORKFLOWS } from '../lib/built-in-workflows'import { isRecord, prop, asString } from '../types/json-guards'-// ── Max execution history ─────────────────────────────────────--const MAX_EXECUTION_HISTORY = 50-// ── Store Interface ───────────────────────────────────────────+// Auflage 7, bau/review-wfgate.md: this store used to also carry an+// execution-history slice (`executions`, `activeExecutionId`,+// `startExecution`, `updateExecution`, `addStepResult`, `cancelExecution`,+// `clearExecutionHistory`, `MAX_EXECUTION_HISTORY`) written and read only by+// the now-deleted `useWorkflow.ts` hook and `WorkflowRunner.tsx` panel+// (removed in commit 8ca0df85, the dead Settings Play button). Harte Regel+// "alten Code sofort loeschen": a repo-wide grep for every one of those+// names outside this store and its own tests found nothing (WorkflowEngine+// tracks its own run state independently and never touches this slice).interface AgentWorkflowState {workflows: AgentWorkflow[]- executions: WorkflowExecution[]- activeExecutionId: string | null// Workflow CRUDaddWorkflow: (workflow: Omit<AgentWorkflow, 'id' | 'createdAt' | 'updatedAt'>) => string@@ -23,13 +26,6 @@ interface AgentWorkflowState {removeWorkflow: (id: string) => voidduplicateWorkflow: (id: string) => string | nullgetWorkflow: (id: string) => AgentWorkflow | undefined-- // Execution management- startExecution: (workflowId: string, conversationId?: string) => string | null- updateExecution: (id: string, updates: Partial<WorkflowExecution>) => void- addStepResult: (executionId: string, result: StepResult) => void- cancelExecution: (id: string) => void- clearExecutionHistory: () => void}// ── Store ─────────────────────────────────────────────────────@@ -38,8 +34,6 @@ export const useAgentWorkflowStore = create<AgentWorkflowState>()(persist((set, get) => ({workflows: [...BUILT_IN_WORKFLOWS],- executions: [],- activeExecutionId: null,// ── Workflow CRUD ─────────────────────────────────────@@ -87,61 +81,6 @@ export const useAgentWorkflowStore = create<AgentWorkflowState>()(},getWorkflow: (id) => get().workflows.find(w => w.id === id),-- // ── Execution ─────────────────────────────────────────-- startExecution: (workflowId, conversationId) => {- const workflow = get().workflows.find(w => w.id === workflowId)- if (!workflow) return null-- const id = uuid()- const execution: WorkflowExecution = {- id,- workflowId,- workflowName: workflow.name,- status: 'running',- currentStepIndex: 0,- stepResults: [],- variables: { ...workflow.variables },- conversationId,- startedAt: Date.now(),- }-- set((state) => {- // Trim history if needed- const executions = [execution, ...state.executions].slice(0, MAX_EXECUTION_HISTORY)- return { executions, activeExecutionId: id }- })-- return id- },-- updateExecution: (id, updates) =>- set((state) => ({- executions: state.executions.map((e) =>- e.id === id ? { ...e, ...updates } : e- ),- })),-- addStepResult: (executionId, result) =>- set((state) => ({- executions: state.executions.map((e) =>- e.id === executionId- ? { ...e, stepResults: [...e.stepResults, result], currentStepIndex: e.currentStepIndex + 1 }- : e- ),- })),-- cancelExecution: (id) =>- set((state) => ({- executions: state.executions.map((e) =>- e.id === id ? { ...e, status: 'cancelled', completedAt: Date.now() } : e- ),- activeExecutionId: state.activeExecutionId === id ? null : state.activeExecutionId,- })),-- clearExecutionHistory: () =>- set({ executions: [], activeExecutionId: null }),}),{name: 'locally-uncensored-agent-workflows',@@ -159,9 +98,14 @@ export const useAgentWorkflowStore = create<AgentWorkflowState>()(// Ensure built-ins are present (may have been added in updates)const existingIds = new Set(workflows.map((w) => asString(prop(w, 'id'))))const missingBuiltIns = BUILT_IN_WORKFLOWS.filter(w => !existingIds.has(w.id))+ // A persisted blob from before Auflage 7 (bau/review-wfgate.md) may+ // still carry the now-removed `executions`/`activeExecutionId` keys;+ // dropping `state`'s own copy and building the result from named+ // fields only, instead of spreading `state`, keeps them out of the+ // store going forward without a separate migration step.const next = version < 1 || workflows.length === 0- ? { ...state, workflows: BUILT_IN_WORKFLOWS, executions: [], activeExecutionId: null }- : { ...state, workflows: [...missingBuiltIns, ...workflows] }+ ? { workflows: BUILT_IN_WORKFLOWS }+ : { workflows: [...missingBuiltIns, ...workflows] }// zustand types migrate as returning the FULL store, but a blob only// ever carries the partialized slice and `merge` puts the actions// back. The cast claims exactly what went in, nothing about actions.@@ -169,8 +113,6 @@ export const useAgentWorkflowStore = create<AgentWorkflowState>()(},partialize: (state) => ({workflows: state.workflows,- executions: state.executions.slice(0, MAX_EXECUTION_HISTORY),- // Don't persist activeExecutionId}),})diff --git a/src/types/agent-workflows.ts b/src/types/agent-workflows.tsindex 3e88198a..53d18c33 100644--- a/src/types/agent-workflows.ts+++ b/src/types/agent-workflows.ts@@ -78,7 +78,6 @@ export interface AgentWorkflow {// ── Execution ─────────────────────────────────────────────────export type StepStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped'-export type WorkflowStatus = 'idle' | 'running' | 'waiting_input' | 'completed' | 'failed' | 'cancelled'export interface StepResult {stepId: string@@ -94,19 +93,13 @@ export interface StepResult {}>}-export interface WorkflowExecution {- id: string- workflowId: string- workflowName: string- status: WorkflowStatus- currentStepIndex: number- stepResults: StepResult[]- variables: Record<string, string> // runtime variable state- conversationId?: string- startedAt: number- completedAt?: number- error?: string-}+// Auflage 7, bau/review-wfgate.md: `WorkflowExecution` and `WorkflowStatus`+// (a full execution-history record type: id, status, currentStepIndex,+// stepResults, variables, conversationId, timestamps) were removed here+// alongside the dead execution-history slice of `agentWorkflowStore.ts`+// that was their only production reader and writer. `WorkflowEngine`+// (workflow-engine.ts) tracks a run's own state independently via+// `StepResult[]` and never touched this type.// ── Engine Callbacks ──────────────────────────────────────────