Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
Fix empty MES step descriptions and ungate assembly instructions (#1266)
Brad Barbinad977d2691f8
diff --git a/apps/erp/app/modules/production/AGENTS.md b/apps/erp/app/modules/production/AGENTS.mdindex 4285c08da2..7c212581f0 100644--- a/apps/erp/app/modules/production/AGENTS.md+++ b/apps/erp/app/modules/production/AGENTS.md@@ -11,7 +11,7 @@ Work orders (jobs), scheduling, routings (operations), bill of materials, proced- **Production Event** — time tracking (Labor/Machine/Setup) against an operation.- **Production Quantity** — output recording (Production/Scrap/Rework) against an operation with optional `scrapReason`.- **Procedure** — versioned work instructions linked to operations via `processId`. Statuses: Draft/Active/Archived.-- **Assembly Instructions are internal-only** (feature flag) while the module matures: the nav entry is in `internalOnlyRoutes` (`useProductionSubmodules.tsx`, via `useFlags().isInternal`), and `requireAssembliesInternal` (`production.server.ts`) redirects non-internal users out of `production/assemblies`, `production/assemblies/new`, and every `x+/assembly+` route (layout loader). Mirrors the settings backups gate; drop the gates to ship publicly.+- **Assembly Instructions** — 3D animated work instructions, available to all users. (Previously gated to Carbon-internal emails via `requireAssembliesInternal` / `useFlags().isInternal`; that gate was removed to ship publicly.)- **Maintenance Dispatch** — reactive/scheduled repair for work centers with comments, events, items, and linked work centers.- **Scheduling** — infinite-capacity backward scheduling via `schedule` edge function. MUST use `triggerJobSchedule` to reschedule, never direct date writes.diff --git a/apps/erp/app/modules/production/production.server.ts b/apps/erp/app/modules/production/production.server.tsindex 195e9595fe..b28edcbfad 100644--- a/apps/erp/app/modules/production/production.server.ts+++ b/apps/erp/app/modules/production/production.server.ts@@ -1,8 +1,5 @@import { ASSEMBLER_SERVICE_URL } from "@carbon/env";import { trigger } from "@carbon/jobs";-import { isInternalEmail } from "@carbon/utils";-import { redirect } from "react-router";-import { path } from "~/utils/path";// The geometry (assembler) service backs model conversion and motion planning.// When it's unreachable those actions can't run, so loaders probe its health and@@ -53,16 +50,6 @@ export async function isAssemblerServiceHealthy(): Promise<boolean> {return healthy;}-/**- * Assemblies (animated work instructions) are internal-only while the module- * matures. Mirrors the backups gate in settings.- */-export function requireAssembliesInternal(email: string | null) {- if (!isInternalEmail(email)) {- throw redirect(path.to.production);- }-}-/*** Triggers a job scheduling task via inngest.* Supports both initial scheduling and rescheduling.diff --git a/apps/erp/app/modules/production/ui/useProductionSubmodules.tsx b/apps/erp/app/modules/production/ui/useProductionSubmodules.tsxindex 00eae6c41a..39d19d53b4 100644--- a/apps/erp/app/modules/production/ui/useProductionSubmodules.tsx+++ b/apps/erp/app/modules/production/ui/useProductionSubmodules.tsx@@ -10,17 +10,13 @@ import {LuTrash} from "react-icons/lu";import { usePermissions } from "~/hooks";-import { useFlags } from "~/hooks/useFlags";import { useSavedViews } from "~/hooks/useSavedViews";import type { AuthenticatedRouteGroup } from "~/types";import { path } from "~/utils/path";-const internalOnlyRoutes = new Set<string>([path.to.assemblyInstructions]);-export default function useProductionSubmodules() {const { t } = useLingui();const permissions = usePermissions();- const { isInternal } = useFlags();const productionRoutes: AuthenticatedRouteGroup[] = [{@@ -98,7 +94,6 @@ export default function useProductionSubmodules() {if (route.role && !permissions.is(route.role)) return false;if (route.permission && !permissions.can("view", route.permission))return false;- if (!isInternal && internalOnlyRoutes.has(route.to)) return false;return true;};diff --git a/apps/erp/app/routes/x+/assembly+/_layout.tsx b/apps/erp/app/routes/x+/assembly+/_layout.tsxindex 0fbed5d46b..1de5ced3b0 100644--- a/apps/erp/app/routes/x+/assembly+/_layout.tsx+++ b/apps/erp/app/routes/x+/assembly+/_layout.tsx@@ -2,7 +2,6 @@ import { requirePermissions } from "@carbon/auth/auth.server";import { msg } from "@lingui/core/macro";import type { LoaderFunctionArgs, MetaFunction } from "react-router";import { Outlet } from "react-router";-import { requireAssembliesInternal } from "~/modules/production/production.server";import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";@@ -11,10 +10,9 @@ export const meta: MetaFunction = () => {};export async function loader({ request }: LoaderFunctionArgs) {- const { email } = await requirePermissions(request, {+ await requirePermissions(request, {view: "production"});- requireAssembliesInternal(email);return null;}diff --git a/apps/erp/app/routes/x+/production+/assemblies.new.tsx b/apps/erp/app/routes/x+/production+/assemblies.new.tsxindex 14b44082bf..5e49020720 100644--- a/apps/erp/app/routes/x+/production+/assemblies.new.tsx+++ b/apps/erp/app/routes/x+/production+/assemblies.new.tsx@@ -13,18 +13,14 @@ import {getModelForItem,upsertAssemblyInstruction} from "~/modules/production";-import {- isAssemblerServiceHealthy,- requireAssembliesInternal-} from "~/modules/production/production.server";+import { isAssemblerServiceHealthy } from "~/modules/production/production.server";import AssemblyInstructionForm from "~/modules/production/ui/Assemblies/AssemblyInstructionForm";import { path } from "~/utils/path";export async function loader({ request }: LoaderFunctionArgs) {- const { email } = await requirePermissions(request, {+ await requirePermissions(request, {create: "production"});- requireAssembliesInternal(email);const url = new URL(request.url);@@ -37,13 +33,9 @@ export async function loader({ request }: LoaderFunctionArgs) {export async function action({ request }: ActionFunctionArgs) {assertIsPost(request);- const { client, companyId, userId, email } = await requirePermissions(- request,- {- create: "production"- }- );- requireAssembliesInternal(email);+ const { client, companyId, userId } = await requirePermissions(request, {+ create: "production"+ });const validation = await validator(assemblyInstructionFromItemValidatordiff --git a/apps/erp/app/routes/x+/production+/assemblies.tsx b/apps/erp/app/routes/x+/production+/assemblies.tsxindex a708bb8c19..8c04ba39a1 100644--- a/apps/erp/app/routes/x+/production+/assemblies.tsx+++ b/apps/erp/app/routes/x+/production+/assemblies.tsx@@ -4,7 +4,6 @@ import { msg } from "@lingui/core/macro";import type { LoaderFunctionArgs } from "react-router";import { Outlet, useLoaderData } from "react-router";import { getAssemblyInstructions } from "~/modules/production";-import { requireAssembliesInternal } from "~/modules/production/production.server";import AssemblyInstructionsTable from "~/modules/production/ui/Assemblies/AssemblyInstructionsTable";import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";@@ -16,11 +15,10 @@ export const handle: Handle = {};export async function loader({ request }: LoaderFunctionArgs) {- const { client, companyId, email } = await requirePermissions(request, {+ const { client, companyId } = await requirePermissions(request, {view: "production",role: "employee"});- requireAssembliesInternal(email);const url = new URL(request.url);const searchParams = new URLSearchParams(url.search);diff --git a/apps/mes/app/components/AssemblyView.tsx b/apps/mes/app/components/AssemblyView.tsxindex 90af6a7547..65794cb37a 100644--- a/apps/mes/app/components/AssemblyView.tsx+++ b/apps/mes/app/components/AssemblyView.tsx@@ -955,7 +955,11 @@ export function AssemblyView({| ProductionEventType| undefined;- const stepHasDescription = richTextToPlainText(step?.description).length > 0;+ // Empty descriptions are persisted as JSON.stringify({}) === "{}" (and legacy+ // rows as a tiptap doc whose only text is "{}"); treat those as "no description".+ const stepDescriptionText = richTextToPlainText(step?.description);+ const stepHasDescription =+ stepDescriptionText.length > 0 && stepDescriptionText !== "{}";const stepDescriptionHtml =step && stepHasDescription? generateHTML(diff --git a/apps/mes/app/components/JobOperation/components/Step.tsx b/apps/mes/app/components/JobOperation/components/Step.tsxindex f7ed0eb26f..17c12d78a9 100644--- a/apps/mes/app/components/JobOperation/components/Step.tsx+++ b/apps/mes/app/components/JobOperation/components/Step.tsx@@ -35,7 +35,8 @@ import {} from "@carbon/react";import {parseMentionsFromDocument,- stripSpecialCharacters+ stripSpecialCharacters,+ tiptapToText} from "@carbon/utils";import { Trans, useLingui } from "@lingui/react/macro";import { useNumberFormatter } from "@react-aria/i18n";@@ -59,6 +60,19 @@ import { useItems, usePeople } from "~/stores";import { getPrivateUrl, path } from "~/utils/path";import FileDropzone from "../../FileDropzone";+// An empty step description is persisted by the ERP editors as+// JSON.stringify({}) === "{}" (and some legacy rows carry it as a tiptap doc+// whose only text is literally "{}"). Treat an empty object, empty doc, or+// "{}"-only text as "no description" so we render nothing instead of a bare "{}".+function hasStepDescription(+ description: JobOperationStep["description"]+): boolean {+ if (!description) return false;+ const text = tiptapToText(description as JSONContent).trim();+ if (text.length > 0 && text !== "{}") return true;+ return parseMentionsFromDocument(description as JSONContent).length > 0;+}+export function StepsListItem({activeStep,step,@@ -82,12 +96,12 @@ export function StepsListItem({const { name, description, type, unitOfMeasureCode, minValue, maxValue } =step;- const hasDescription = description && Object.keys(description).length > 0;+ const hasDescription = hasStepDescription(description);const mentionIds = hasDescription? parseMentionsFromDocument(description as JSONContent): [];const disclosure = useDisclosure({- defaultIsOpen: !!hasDescription+ defaultIsOpen: hasDescription});if (!operationId) return null;@@ -483,7 +497,7 @@ export function RecordModal({</>)}<VStack spacing={4}>- {attribute.description && (+ {hasStepDescription(attribute.description) && (<divclassName="flex flex-col gap-2"dangerouslySetInnerHTML={{