Streaming seems to work but copilot is dumb

This commit is contained in:
Siddharth Ganesan
2026-02-03 19:19:26 -08:00
parent 71701f1049
commit 24319744c3
3 changed files with 41 additions and 3 deletions

View File

@@ -1303,11 +1303,25 @@ const sseHandlers: Record<string, SSEHandler> = {
const resultPayload =
data?.result || data?.data?.result || data?.data?.data || data?.data || {}
const workflowState = resultPayload?.workflowState
logger.info('[SSE] edit_workflow result received', {
hasWorkflowState: !!workflowState,
blockCount: workflowState ? Object.keys(workflowState.blocks || {}).length : 0,
edgeCount: workflowState?.edges?.length ?? 0,
})
if (workflowState) {
const diffStore = useWorkflowDiffStore.getState()
void diffStore.setProposedChanges(workflowState)
// Await the diff application to catch any errors
diffStore.setProposedChanges(workflowState).catch((err) => {
logger.error('[SSE] Failed to apply edit_workflow diff', {
error: err instanceof Error ? err.message : String(err),
})
})
}
} catch {}
} catch (err) {
logger.error('[SSE] edit_workflow result handling failed', {
error: err instanceof Error ? err.message : String(err),
})
}
}
}

View File

@@ -121,6 +121,13 @@ export const useWorkflowDiffStore = create<WorkflowDiffState & WorkflowDiffActio
const candidateState = diffResult.diff.proposedState
logger.info('[WorkflowDiff] Applying proposed state', {
blockCount: Object.keys(candidateState.blocks || {}).length,
edgeCount: candidateState.edges?.length ?? 0,
hasLoops: !!candidateState.loops,
hasParallels: !!candidateState.parallels,
})
// Validate proposed workflow using serializer round-trip
const serializer = new Serializer()
const serialized = serializer.serializeWorkflow(
@@ -134,6 +141,7 @@ export const useWorkflowDiffStore = create<WorkflowDiffState & WorkflowDiffActio
// OPTIMISTIC: Apply state immediately to stores (this is what makes UI update)
applyWorkflowStateToStores(activeWorkflowId, candidateState)
logger.info('[WorkflowDiff] Applied state to stores')
// OPTIMISTIC: Update diff state immediately so UI shows the diff
const triggerMessageId =

View File

@@ -37,10 +37,26 @@ export function applyWorkflowStateToStores(
workflowState: WorkflowState,
options?: { updateLastSaved?: boolean }
) {
logger.info('[applyWorkflowStateToStores] Applying state', {
workflowId,
blockCount: Object.keys(workflowState.blocks || {}).length,
edgeCount: workflowState.edges?.length ?? 0,
edgePreview: workflowState.edges?.slice(0, 3).map((e) => `${e.source} -> ${e.target}`),
})
const workflowStore = useWorkflowStore.getState()
workflowStore.replaceWorkflowState(cloneWorkflowState(workflowState), options)
const cloned = cloneWorkflowState(workflowState)
logger.info('[applyWorkflowStateToStores] Cloned state edges', {
clonedEdgeCount: cloned.edges?.length ?? 0,
})
workflowStore.replaceWorkflowState(cloned, options)
const subBlockValues = extractSubBlockValues(workflowState)
useSubBlockStore.getState().setWorkflowValues(workflowId, subBlockValues)
// Verify what's in the store after apply
const afterState = workflowStore.getWorkflowState()
logger.info('[applyWorkflowStateToStores] After apply', {
afterEdgeCount: afterState.edges?.length ?? 0,
})
}
export function captureBaselineSnapshot(workflowId: string): WorkflowState {