# Refactor Large Scripts

Each script should have fewer than 250 LOC; special cases may extend but must stay under 300 LOC.

## Refactoring Checklist (2025-11-06)

- [x] `apps/canvas/src/features/workflow/pages/workflow-canvas.tsx` — 4809 LOC
- [x] `tests/sdk/test_cli.py` — 3954 LOC
- [x] `tests/backend/test_app_init.py` — 3286 LOC
- [x] `tests/backend/test_authentication_extended.py` — 2448 LOC
- [x] `apps/backend/src/orcheo_backend/app/__init__.py` — 2089 LOC
- [x] `tests/test_backend_api.py` — 1919 LOC
- [x] `tests/backend/test_authentication.py` — 1604 LOC
- [x] `tests/backend/test_repository.py` — 1509 LOC
- [x] `tests/backend/test_chatkit_service.py` — 1503 LOC
- [x] `apps/backend/src/orcheo_backend/app/authentication.py` — 1491 LOC
- [x] `tests/sdk/test_mcp_server.py` — 1488 LOC
- [x] `tests/backend/test_chatkit_store_sqlite.py` — 1340 LOC
- [x] `apps/canvas/src/features/workflow/pages/workflow-gallery.tsx` — 1067 LOC
- [x] `tests/test_vault.py` — 1058 LOC
- [x] `apps/canvas/src/features/workflow/components/panels/node-inspector.tsx` — 1030 LOC
- [x] `apps/canvas/src/features/workflow/lib/node-schemas.ts` — 1005 LOC
- [x] `packages/sdk/src/orcheo_sdk/cli/workflow.py` — 996 LOC
- [x] `src/orcheo/vault/__init__.py` — 986 LOC
- [x] `apps/backend/src/orcheo_backend/app/repository_sqlite.py` — 953 LOC
- [x] `tests/nodes/test_utility_nodes.py` — 880 LOC
- [x] `apps/canvas/src/features/workflow/lib/graph-config.ts` — 861 LOC
- [x] `src/orcheo/models/workflow.py` — 856 LOC
- [x] `apps/backend/src/orcheo_backend/app/repository.py` — 835 LOC
- [x] `apps/canvas/src/design-system/ui/sidebar.tsx` — 787 LOC
- [x] `tests/backend/test_service_token_repository.py` — 785 LOC
- [x] `apps/canvas/src/features/workflow/components/panels/sidebar-panel.tsx` — 756 LOC
- [x] `tests/test_triggers_webhook.py` — 752 LOC
- [x] `tests/sdk/test_workflow_cli_helpers.py` — 741 LOC
- [x] `apps/backend/src/orcheo_backend/app/chatkit_store_sqlite.py` — 727 LOC
- [x] `apps/canvas/src/features/workflow/components/panels/workflow-execution-history.tsx` — 679 LOC
- [x] `tests/test_triggers_layer.py` — 679 LOC
- [x] `apps/canvas/src/features/workflow/components/panels/rjsf-theme.tsx` — 627 LOC
- [x] `apps/canvas/src/features/workflow/lib/workflow-storage.ts` — 603 LOC
- [x] `apps/backend/src/orcheo_backend/app/history.py` — 589 LOC
- [x] `tests/sdk/test_client.py` — 589 LOC
- [x] `tests/backend/test_service_token_endpoints.py` — 576 LOC
- [x] `apps/canvas/src/features/support/pages/help-support.tsx` — 573 LOC
- [x] `apps/backend/src/orcheo_backend/app/chatkit_service.py` — 571 LOC
- [x] `apps/canvas/src/features/workflow/data/workflow-data.ts` — 569 LOC
- [x] `tests/backend/test_chatkit_tokens.py` — 567 LOC
- [x] `tests/nodes/test_logic_nodes.py` — 560 LOC
- [x] `apps/canvas/src/features/workflow/components/dialogs/notification-settings.tsx` — 559 LOC
- [x] `tests/nodes/test_data_nodes.py` — 556 LOC
- [x] `packages/sdk/src/orcheo_sdk/mcp_server/tools.py` — 554 LOC
- [x] `tests/sdk/test_cli_service_token.py` — 544 LOC
- [x] `tests/test_app.py` — 542 LOC
- [x] `tests/test_backend_coverage.py` — 537 LOC
- [x] `apps/canvas/src/features/account/pages/settings.tsx` — 518 LOC
- [x] `tests/nodes/test_ai.py` — 517 LOC
- [x] `tests/nodes/test_mongodb.py` — 507 LOC
- [x] `apps/canvas/src/features/workflow/components/dialogs/credentials-vault.tsx` — 503 LOC
- [x] `packages/sdk/src/orcheo_sdk/mcp_server/main.py` — 500 LOC
- [x] `src/orcheo/nodes/logic.py` — 492 LOC
- [x] `apps/backend/src/orcheo_backend/app/service_token_repository.py` — 480 LOC
- [x] `tests/graph/test_builder.py` — 473 LOC
- [x] `src/orcheo/nodes/data.py` — 468 LOC
- [x] `src/orcheo/vault/oauth.py` — 465 LOC
- [x] `src/orcheo/triggers/layer.py` — 462 LOC
- [x] `tests/test_workflow_models.py` — 460 LOC
- [x] `tests/nodes/test_storage_nodes.py` — 454 LOC
- [x] `tests/backend/test_history.py` — 452 LOC
- [x] `tests/graph/test_ingestion.py` — 451 LOC
- [x] `src/orcheo/graph/ingestion.py` — 432 LOC
- [x] `tests/backend/test_app_integration.py` — 380 LOC
- [x] `tests/test_vault_oauth_service.py` — 334 LOC
- [x] `tests/runtime/test_credentials.py` — 332 LOC
- [x] `tests/test_triggers_manual.py` — 313 LOC
- [x] `tests/nodes/test_base.py` — 294 LOC
- [x] `src/orcheo/triggers/webhook.py` — 419 LOC
- [x] `src/orcheo/nodes/utility.py` — 390 LOC
- [x] `packages/sdk/src/orcheo_sdk/services/workflows.py` — 389 LOC
- [x] `apps/backend/src/orcheo_backend/app/schemas.py` — 357 LOC
- [x] `src/orcheo/config.py` — 336 LOC
- [x] `packages/sdk/src/orcheo_sdk/client.py` — 287 LOC
- [x] `src/orcheo/graph/builder.py` — 262 LOC
- [x] `apps/backend/src/orcheo_backend/app/service_token_endpoints.py` — 256 LOC
- [x] `src/orcheo/runtime/credentials.py` — 256 LOC
- [x] `apps/canvas/src/features/workflow/components/panels/workflow-history.tsx` — 459 LOC
- [x] `apps/canvas/src/features/workflow/components/canvas/time-travel-debugger.tsx` — 444 LOC
- [x] `apps/canvas/src/features/workflow/components/dialogs/user-role-management.tsx` — 427 LOC
- [x] `apps/canvas/src/features/shared/components/chat-input.tsx` — 401 LOC
- [x] `apps/canvas/src/features/shared/components/top-navigation.tsx` — 393 LOC
- [x] `apps/canvas/src/features/workflow/components/panels/variable-inspector.tsx` — 381 LOC
- [x] `apps/canvas/src/setupTests.ts` — 367 LOC
- [x] `apps/canvas/src/design-system/ui/chart.tsx` — 365 LOC
- [x] `apps/canvas/src/features/workflow/components/panels/workflow-node-gallery.tsx` — 354 LOC
- [x] `apps/canvas/src/features/workflow/components/dialogs/command-palette.tsx` — 336 LOC
- [x] `apps/canvas/src/features/workflow/components/nodes/workflow-node.tsx` — 336 LOC
- [x] `apps/canvas/src/features/workflow/lib/graph-config.integration.test.ts` — 328 LOC
- [x] `apps/canvas/src/features/workflow/lib/workflow-storage.test.ts` — 309 LOC
- [x] `apps/canvas/src/features/shared/components/chat-interface.tsx` — 308 LOC
- [x] `apps/canvas/src/features/workflow/lib/workflow-execution-storage.ts` — 307 LOC
- [x] `apps/canvas/src/features/account/pages/profile.tsx` — 306 LOC
- [x] `apps/canvas/src/features/workflow/components/canvas/workflow-controls.tsx` — 300 LOC
- [x] `apps/canvas/src/features/workflow/components/canvas/annotations-layer.tsx` — 299 LOC
- [x] `apps/canvas/src/features/workflow/components/panels/workflow-governance-panel.tsx` — 283 LOC
- [x] `apps/canvas/src/design-system/ui/carousel.tsx` — 262 LOC
- [x] `apps/canvas/src/features/shared/components/chat-message.tsx` — 260 LOC
- [x] `apps/canvas/src/design-system/ui/menubar.tsx` — 256 LOC
- [x] `apps/canvas/src/features/workflow/components/layouts/sidebar-layout.tsx` — 255 LOC
- [x] `apps/canvas/src/features/account/components/theme-settings.tsx` — 252 LOC


## Wrap up

- [x] Tell coding agents to respect the LOC limit in future commits
