From fa0b0760eb55416495d3e0992c73eaffa48a4b84 Mon Sep 17 00:00:00 2001 From: abccodes Date: Tue, 23 Jun 2026 03:02:51 -0700 Subject: [PATCH] [aidan] fix/workflows: optimistically apply edits so the schedule banner updates instantly --- frontend/src/shared/state/workflowsSlice.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/frontend/src/shared/state/workflowsSlice.ts b/frontend/src/shared/state/workflowsSlice.ts index f24e4a4b..0f9bd989 100644 --- a/frontend/src/shared/state/workflowsSlice.ts +++ b/frontend/src/shared/state/workflowsSlice.ts @@ -593,6 +593,16 @@ const slice = createSlice({ }) .addCase(fetchWorkflows.rejected, (state) => { state.loading = false; state.loaded = true; }) .addCase(createWorkflow.fulfilled, (state, action) => { state.items[action.payload.id] = action.payload; }) + // Optimistic: reflect the patch in the store immediately so store-driven + // UI (the schedule test-first banner, status, etc.) updates the instant + // the user edits, not after the PATCH round-trips (which awaits an aux + // relabel LLM call server-side). fulfilled overwrites with server truth; + // a 409 stale triggers a refetch in useWorkflowPatch. + .addCase(updateWorkflow.pending, (state, action) => { + const { id, patch } = action.meta.arg; + const cur = state.items[id]; + if (cur) state.items[id] = { ...cur, ...patch }; + }) .addCase(updateWorkflow.fulfilled, (state, action) => { state.items[action.payload.id] = action.payload; }) .addCase(commitDraft.fulfilled, (state, action) => { state.items[action.payload.id] = action.payload; }) .addCase(discardDraft.fulfilled, (state, action) => { state.items[action.payload.id] = action.payload; })