Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
7.3 KiB
PRD: Move Workflow EE UI into ee/server Folder Structure
Problem Statement
The Workflow UI currently uses “feature package” entrypoints under packages/workflows/src/{oss,ee} and relies on build-time aliasing of @alga-psa/workflows/entry to select the correct implementation.
In practice, Enterprise builds can still ship the OSS/CE stub UI (“Enterprise Feature / Please upgrade…”) even when:
- The app is deployed with EE images, and
- Runtime env vars indicate Enterprise (
EDITION=enterprise,NEXT_PUBLIC_EDITION=enterprise).
We observed this in the HV dev2 environment: the deployed .next output contained the OSS/CE stub strings (historically under packages/workflows/src/oss/entry.tsx), indicating a “hybrid” build.
Root cause class: TS path-based resolution (Next’s JsConfigPathsPlugin) can override/short-circuit webpack aliasing, meaning the EE/OSS selection is not consistently enforced at build time.
This is confusing operationally and erodes trust: users see EE-only gating dialogs even in Enterprise deployments.
Status (as of 2026-01-29)
This plan is implemented in the current repo state.
Implemented (in repo today)
- The authoritative EE entry is
ee/server/src/workflows/entry.tsxand exportsDnDFlow. - The authoritative CE stub entry is
server/src/empty/workflows/entry.tsxand exportsDnDFlowwith the legacy stub text. server/next.config.mjsaliases@alga-psa/workflows/entrydeterministically for both webpack + turbopack.server/tsconfig.jsonandee/server/tsconfig.jsonno longer map@alga-psa/workflows/entry.- Typings for
@alga-psa/workflows/entryare provided viaserver/src/types/external-modules.d.ts. - CI/build guards exist to prevent hybrid EE builds and to validate CE builds:
scripts/guard-workflows-entry-edition-selection.mjsscripts/guard-ee-workflows-next-build.mjsscripts/guard-ce-workflows-next-build.mjs.github/workflows/workflows-ee-build-guard.yml
- A UI smoke test exists:
ee/server/src/__tests__/integration/workflows-ee-entry-smoke.playwright.test.ts.
Not yet implemented (still outstanding)
None. Remaining work is optional cleanup (e.g. removing any empty legacy directories under packages/workflows/src/ee/** if desired).
User Value
- Enterprise deployments reliably load the real Workflow UI (designer, toggles, run studio).
- CE deployments reliably load stubs (or hide the feature), without “hybrid” behavior.
- A clearer code layout: EE-only UI lives in
ee/server/src/**, aligning with other EE feature wiring. - Fewer build-time footguns: no reliance on TS “paths” for runtime selection.
Goals
- Relocate the Workflow UI EE implementation from
packages/workflows/src/ee/**into the EE tree underee/server/src/**. - Ensure
@alga-psa/workflows/entryresolves deterministically to:ee/server/src/**in EE buildsserver/src/empty/**(or other CE stub) in CE builds
- Remove or neutralize TS path mappings that can cause the OSS stub to be bundled in EE.
- Keep the import surface stable for app code (
@alga-psa/workflows/entry,@alga-psa/workflows/components/*) to avoid widespread refactors. - Add regression tests that detect “OSS stub shipped in EE build”.
Non-Goals
- Rewriting the workflow engine/runtime or Temporal workflows.
- Changing licensing/entitlement policy (still EE-only where intended).
- Migrating all workflow-related shared code into
ee/(schemas/types/shared runtime can remain inpackages/workflows). - UI redesign.
Background / Current Architecture
Current entrypoint selection
packages/workflows/src/components/WorkflowComponentLoader.tsdynamically imports@alga-psa/workflows/entry.server/next.config.mjsattempts to alias@alga-psa/workflows/entryto:- EE:
packages/workflows/src/ee/entry.tsx - OSS/CE:
packages/workflows/src/oss/entry.tsx
- EE:
server/tsconfig.jsoncurrently maps@alga-psa/workflows/entrytopackages/workflows/src/entry(which re-exports the OSS stub).
Why this breaks
Next’s TS/JS config path resolver can resolve @alga-psa/workflows/entry via tsconfig paths before webpack aliasing, causing the OSS stub to end up in the EE bundle (hybrid build).
Proposed Architecture
Code placement
- EE Workflow UI lives under
ee/server/src/**(new home), e.g.:ee/server/src/workflows/entry.tsx(oree/server/src/components/workflows/entry.tsx)ee/server/src/workflows/**for designer subcomponents
- CE/OSS stub lives under
server/src/empty/**, e.g.:server/src/empty/workflows/entry.tsx- (or reuse existing
server/src/empty/components/flow/DnDFlow.tsxwith a thin entry wrapper)
Build-time wiring (authoritative)
- In
server/next.config.mjs, alias@alga-psa/workflows/entrydirectly to these concrete files. - Ensure both webpack and turbopack aliasing cover it.
TypeScript wiring (non-authoritative)
- Remove tsconfig
pathsmapping for@alga-psa/workflows/entry(and any similar “runtime-selected” specifiers). - Provide typings via:
server/src/types/external-modules.d.ts(or a dedicatedworkflows-entry.d.ts) declaringDnDFlowand related exports.
This makes TS happy without allowing TS paths to affect runtime bundling.
Migration / Rollout Plan
- Introduce new EE entry file in
ee/server/src/**that exports the expectedDnDFlownamed export. - Introduce new CE stub entry file in
server/src/empty/**matching the export shape. - Update
server/next.config.mjsto point@alga-psa/workflows/entryat the new locations for both webpack + turbopack. - Remove tsconfig
pathsentry for@alga-psa/workflows/entry(and update any dependent tsconfigs, e.g.ee/server/tsconfig.json). - Remove legacy
packages/workflows/src/{ee,oss}entrypoints rather than keeping re-export shims, to prevent any accidental “hybrid” resolution paths in future builds. - Add a CI guard for EE builds:
- After
next buildwith EE env, grep.next/serverfor known OSS stub strings and fail if present.
- After
- Deploy to HV dev2 and validate:
- Workflows page loads real designer UI
- No EE-only gating dialog appears in EE deployments
Risks
- Moving UI code may introduce import boundary violations (feature-to-feature lint rules).
ee/server/srccode may depend on packages not present in some build contexts; require careful aliasing andtranspilePackages.- Turbopack vs webpack differences: ensure both codepaths are wired identically.
- Any other “runtime-selected” entrypoints could have similar TS-path precedence issues; scope creep risk.
Open Questions (needs user confirmation)
Resolved (2026-01-29):
- All workflow UI will be moved into
ee/server/src/**(designer, run studio, and related workflow surfaces). - CE behavior will be a stub message indicating the feature requires Enterprise.
- Scope is workflows-only (do not expand to other runtime-selected entrypoints).
Acceptance Criteria / Definition of Done
- In an EE
next buildoutput,.next/server/**does not contain strings from the OSS workflow stub entry. - In HV dev2 (or equivalent), the deployed EE image loads the real workflow designer UI.
- CE builds still compile and behave as expected (stub/hide), with no EE-only code shipped unintentionally.
- Added CI regression check(s) prevent hybrid workflow builds going forward.