Skip to content

Workflow actions state-aware UI/UX, backend validation fixes, and documentation overhaul#2

Merged
dinosaurchi merged 10 commits into
mainfrom
chi/fix-remaining-issues
Apr 17, 2026
Merged

Workflow actions state-aware UI/UX, backend validation fixes, and documentation overhaul#2
dinosaurchi merged 10 commits into
mainfrom
chi/fix-remaining-issues

Conversation

@dinosaurchi

Copy link
Copy Markdown
Owner

Summary

This PR delivers the complete Workflow Actions State-Aware Fix as specified in the handoff document, plus a professional documentation overhaul for open-source readiness.

Changes

🔧 Workflow Actions — State-Aware UI/UX (Passes 1–6)

  • Centralized action model (web/src/pages/document-detail/workflow-actions.ts)

    • 8 predicate functions (canAnalyze, canApproveRouting, canReroute, canRequestConsultation, canResolveConsultation, canEscalate, canMarkOutOfScope, canClose)
    • getWorkflowActionStates(doc, role) returning available/disabled/hidden action arrays
    • getWorkflowStatusMessage() for contextual status-aware helper text
  • Refactored DocumentDetailPage to use model-driven action rendering

    • Terminal-state documents show a clear "no further actions" card with status-appropriate icons
    • Actions grouped by category (Analysis, Review, Consultation, Closeout)
    • Color-coded button variants: blue (primary), amber (caution), red (destructive), emerald (success)
    • Disabled actions shown at 40% opacity with explicit reason text
    • Reroute inline form with department select and rationale input
  • Backend transition validation fixes (api/app/api/v1/endpoints/review.py)

    • Added validate_transition() to reroute_document (was missing — allowed rerouting from terminal states)
    • Added validate_transition() to resolve_consultation (was missing — allowed resolving on non-consultation documents)
    • Consistent 400 INVALID_TRANSITION error responses across all endpoints

🧪 Tests

  • 45 frontend tests (Vitest) — action predicates, integration scenarios, status messages
  • 11 backend tests (Pytest) — reroute and resolve-consultation transition validation
  • 3 integration tests — end-to-end transition enforcement
  • Total: 227 tests passing

📚 Documentation Overhaul

  • README.md — Professional rewrite with badges, architecture diagram, workflow diagram, quick start, tech stack, role matrix, testing overview
  • CONTRIBUTING.md — Dev setup, code style, testing expectations, PR guidelines
  • CHANGELOG.md — Keep a Changelog format (v0.1.0)
  • GitHub issue templates — Bug report and feature request
  • metadata.json — Updated with major capabilities and version

Test Results

  • make ci: ✅ All checks pass (lint, build, test)
  • Frontend: 45 Vitest tests passing
  • Backend: 227 Pytest tests passing
  • Docker builds: Successful

Files Changed

New files (6):

  • web/src/pages/document-detail/workflow-actions.ts
  • web/src/pages/document-detail/workflow-actions.test.ts
  • api/tests/unit/test_review_endpoints.py
  • api/tests/integration/test_review_endpoint_transitions.py
  • CONTRIBUTING.md
  • CHANGELOG.md
  • .github/ISSUE_TEMPLATE/bug_report.md
  • .github/ISSUE_TEMPLATE/feature_request.md

Modified files (5):

  • web/src/pages/DocumentDetailPage.tsx
  • api/app/api/v1/endpoints/review.py
  • README.md
  • metadata.json
  • Makefile

- Create web/src/pages/document-detail/workflow-actions.ts with action availability matrix
- Add isTerminalStatus(), canAnalyze(), canApproveRouting(), canReroute(),
  canRequestConsultation(), canResolveConsultation(), canEscalate(),
  canMarkOutOfScope(), canClose() predicate helpers
- Add getWorkflowActionStates() returning available/disabled/hidden actions
- Refactor DocumentDetailPage to use model-driven action rendering
- Terminal-state documents now show 'no further actions' message
- Actions grouped by category (Analysis, Review, Consultation, Closeout)
- Disabled actions show explicit reason text
- Add getWorkflowStatusMessage() for contextual status-aware helper text
- Add TerminalStateCard component with status-appropriate icons
- Update button variants: blue (primary), amber (caution), red (destructive)
- Disabled actions render at 40% opacity with reason text
- Action group headers adapt styling based on availability
- Empty state message when no actions available for user role
- Consultation form colors updated to amber variant
…ion endpoints

- reroute_document now validates transition before setting status to routed
- resolve_consultation now validates transition before setting status to under_review
- Both return 400 INVALID_TRANSITION for illegal state changes
- Prevents rerouting from terminal states (closed, out_of_scope)
- Prevents resolving consultation on documents not in in_consultation
- All other endpoints confirmed to already have proper validation
…ests

Frontend tests (39 tests via vitest):
- isTerminalStatus, canAnalyze, canApproveRouting, canRequestConsultation
- canResolveConsultation, canEscalate, canMarkOutOfScope, canClose
- getWorkflowActionStates integration tests for key statuses
- getWorkflowStatusMessage tests

Backend tests (11 tests):
- reroute endpoint: validates transition from under_review succeeds,
  from terminal states (closed, out_of_scope) returns 400
- resolve-consultation endpoint: validates transition from
  in_consultation succeeds, from terminal states returns 400

Added vitest config and test scripts to web/package.json
… routed is invalid)

- canReroute now only returns true for under_review status
- Removed in_consultation from allowed reroute states
- Updated disabled reason text
- Added canReroute unit tests and integration tests
- Frontend now matches backend VALID_TRANSITIONS exactly
- Add reroute inline form with department select and rationale input
- Fetch departments from API and display actual department names
- Add 'success' button variant (emerald) for approve, resolve, close actions
- Add frontend tests to make test target in Makefile
- Add integration tests for reroute and resolve-consultation transition validation
- Rewrite README.md with professional structure: badges, features, architecture,
  workflow diagram, quick start, tech stack, role-based access, testing overview
- Create CONTRIBUTING.md with dev setup, code style, testing, and PR guidelines
- Create CHANGELOG.md using Keep a Changelog format (v0.1.0)
- Create GitHub issue templates (bug_report.md, feature_request.md)
- Update metadata.json with major capabilities and version
@dinosaurchi dinosaurchi self-assigned this Apr 17, 2026
…ulation

- Remove standalone API Documentation section (Swagger/ReDoc not accessible through main UI)
- Add API health endpoint reference to Development commands table
- Rename 'Role-Based Access' to 'Simulated Multi-Role Workflow' and 'Demo Roles'
- Add note clarifying role switching is a demo simulation, not production auth
@dinosaurchi
dinosaurchi merged commit 96d7a42 into main Apr 17, 2026
1 check passed
@dinosaurchi
dinosaurchi deleted the chi/fix-remaining-issues branch April 17, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant