Merge PR #388: Daily Workflow Integration & Enhanced Reliability
- Resolve merge conflicts in backend/services/today_workflow_service.py and frontend/src/stores/workflowStore.ts - Backend: Keep robust handling for both dict and object types in TaskProposal conversion - Backend: Combine dependencies coercion with task metadata normalization - Frontend: Implement graceful fallback pattern (try server first, then local generation on unavailability) - Add provenanceSummary integration from server responses - Ensure degraded mode handling with appropriate messaging
This commit is contained in:
@@ -164,32 +164,36 @@ export const useWorkflowStore = create<WorkflowState>()(
|
||||
// Generate daily workflow
|
||||
generateDailyWorkflow: async (userId: string, date?: string) => {
|
||||
set({ isLoading: true, error: null });
|
||||
|
||||
|
||||
try {
|
||||
const resp = await apiClient.get('/api/today-workflow', { params: date ? { date } : {} });
|
||||
const serverWorkflow = resp?.data?.data?.workflow as DailyWorkflow | undefined;
|
||||
|
||||
if (!serverWorkflow || !Array.isArray(serverWorkflow.tasks)) {
|
||||
throw new WorkflowError({
|
||||
code: 'WORKFLOW_SCHEMA_INVALID',
|
||||
message: 'Server workflow response is missing a valid tasks array.',
|
||||
timestamp: new Date(),
|
||||
recoverable: false,
|
||||
suggestedAction: 'Refresh and try again. If this persists, contact support.'
|
||||
const planSummary = resp?.data?.data?.plan?.provenance_summary;
|
||||
|
||||
if (serverWorkflow && Array.isArray(serverWorkflow.tasks)) {
|
||||
if (planSummary && !serverWorkflow.provenanceSummary) {
|
||||
serverWorkflow.provenanceSummary = planSummary;
|
||||
}
|
||||
const normalizedWorkflow = normalizeServerWorkflow(serverWorkflow);
|
||||
const derived = computeProgressAndNavigation(normalizedWorkflow);
|
||||
set({
|
||||
currentWorkflow: normalizedWorkflow,
|
||||
workflowProgress: derived.progress,
|
||||
navigationState: derived.navigation,
|
||||
isLoading: false,
|
||||
isDegradedMode: false,
|
||||
degradedModeReason: null,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const normalizedWorkflow = normalizeServerWorkflow(serverWorkflow);
|
||||
const derived = computeProgressAndNavigation(normalizedWorkflow);
|
||||
set({
|
||||
currentWorkflow: normalizedWorkflow,
|
||||
workflowProgress: derived.progress,
|
||||
navigationState: derived.navigation,
|
||||
isLoading: false,
|
||||
isDegradedMode: false,
|
||||
degradedModeReason: null,
|
||||
throw new WorkflowError({
|
||||
code: 'WORKFLOW_SCHEMA_INVALID',
|
||||
message: 'Server workflow response is missing a valid tasks array.',
|
||||
timestamp: new Date(),
|
||||
recoverable: false,
|
||||
suggestedAction: 'Refresh and try again. If this persists, contact support.'
|
||||
});
|
||||
return;
|
||||
} catch (error) {
|
||||
if (!isServerUnavailableError(error)) {
|
||||
set({
|
||||
|
||||
Reference in New Issue
Block a user