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(assembly): scope the hidden-parts save to its instruction and drop the draft when the save fails
aashu25dd4d712708
diff --git a/.ai/specs/2026-09-25-assembly-step-hidden-components.md b/.ai/specs/2026-09-25-assembly-step-hidden-components.mdindex 3e266c711c..85b3566efb 100644--- a/.ai/specs/2026-09-25-assembly-step-hidden-components.md+++ b/.ai/specs/2026-09-25-assembly-step-hidden-components.md@@ -30,7 +30,8 @@ MES. This is why the earlier "isolate" release missed the ask.That is requirement 2 and gets its own spec.- Hiding that carries forward to later steps. Each step's list covers only thatstep (see Q1).-- A temporary, unsaved hide. Isolate remains the tool for quick looks.+- A temporary, unsaved hide. Selecting a component in the Components panel+ still isolates it for a quick look (`focusedNodeIds`), but nothing is saved.- Any control in MES.- Translating the Components panel's existing, untouched English strings. Onlycopy that this work adds or changes is made translatable.@@ -72,24 +73,26 @@ One new column on `assemblyInstructionStep`:2. Hidden applies only while that step is active (Q1). During full playback,the part disappears when the step starts and comes back on the next step.3. Hidden parts are not drawn at all. They are not ghosted.-4. Isolate is unchanged. It stays temporary and is never saved.+4. The temporary focus (select a component in the Components panel to see it+ alone) is unchanged and never saved. The named Isolate view was removed.### Viewer (`@carbon/viewer`)- `AssemblyStep` gains `hiddenComponentNodeIds?: string[]`.-- In the scene's visibility pass, the existing explicit-hide pass hides the- union of the `hiddenNodeIds` prop and `activeStep.hiddenComponentNodeIds`,- minus the active step's own `componentNodeIds`. The pass already runs last,- after step-state visuals, highlight, and isolate. The effect already depends- on the active step, so playback updates per step automatically.-- The `hiddenNodeIds` prop stays for other callers. The ERP editor stops passing- its temporary set.+- In the scene's visibility pass, the explicit-hide pass hides+ `activeStep.hiddenComponentNodeIds` minus the active step's own+ `componentNodeIds`. The pass runs last, after step-state visuals, highlight,+ and focus. The effect depends on the active step, so playback updates per+ step automatically.+- The player has no separate `hiddenNodeIds` prop; the step's list is the only+ input.### Services and routes (ERP)-- `updateAssemblyStepHiddenComponents(client, { id, hiddenComponentNodeIds, updatedBy })`- reads the step's `componentNodeIds`, strips them from the list, dedupes, and- updates only the hidden column.+- `updateAssemblyStepHiddenComponents(client, { id, assemblyInstructionId, hiddenComponentNodeIds, updatedBy })`+ updates only the hidden column, matching the step by id AND instruction so a+ route can't reach a step of another instruction. The trigger strips the+ step's own parts and dedupes.- Validator `assemblyInstructionStepHiddenComponentsValidator`, with a JSONstring array like the components validator.- Route `x+/assembly+/$id.steps.hidden.$stepId.tsx` is a POST autosave that@@ -148,7 +151,7 @@ player applies them.| Hide scope | This step only | Q1 answer. || Hide visual | Not drawn, never ghosted | The ask is to remove clutter. Ghosting still clutters and costs rendering. || Own parts | Server strips them, UI disables them, player ignores them | Q3 answer. Three layers, so old or edited data can't make a step animate an invisible part. |-| Temporary hide | Removed, eye now saves | Q2 answer. Isolate covers quick looks. |+| Temporary hide | Removed, eye now saves | Q2 answer. Selecting a component still focuses it for a quick look. || Save style | Immediate autosave route per field | Matches the components and motion autosave routes. || Regenerate | Drops hidden lists with the steps | Consistent with every other authored step field. |@@ -202,3 +205,4 @@ closest match here is the per-step "exception list".- 2026-09-25: first draft, with Q1 to Q4 answered by the user.- 2026-09-25: after review, the own-parts rule moved into a DB trigger; hidden-list rows are no longer clickable; the player's unused `hiddenNodeIds` prop was removed.+- 2026-09-28: aligned with the implementation after PR review: the named Isolate view is gone (temporary focus remains), the player takes no `hiddenNodeIds` prop, and the hidden-list update is scoped to its instruction.diff --git a/apps/erp/app/modules/production/production.service.ts b/apps/erp/app/modules/production/production.service.tsindex d7a005b4b1..5bcc5720ae 100644--- a/apps/erp/app/modules/production/production.service.ts+++ b/apps/erp/app/modules/production/production.service.ts@@ -7426,6 +7426,7 @@ export async function updateAssemblyStepHiddenComponents(client: SupabaseClient<Database>,data: {id: string;+ assemblyInstructionId: string;hiddenComponentNodeIds: string[];updatedBy: string;}@@ -7438,6 +7439,7 @@ export async function updateAssemblyStepHiddenComponents(updatedAt: new Date().toISOString()}).eq("id", data.id)+ .eq("assemblyInstructionId", data.assemblyInstructionId).select("id").single();}diff --git a/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json b/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.jsonindex f2b0bb08b8..5ba2cafc1f 100644--- a/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json+++ b/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json@@ -823,7 +823,7 @@{"name":"production_updateAssemblyInstructionStepOrder","classification":"WRITE","paramCount":2,"schema":"5a4d7dc208a5","response":"none","injectAuth":"companyId+updatedBy","permission":"production:update","paginates":false},{"name":"production_updateAssemblyInstructionStepStatus","classification":"WRITE","paramCount":2,"schema":"9291eed55a4a","response":"3797626bd17e","injectAuth":"companyId+updatedBy","permission":"production:update","paginates":false},{"name":"production_updateAssemblyStepComponents","classification":"WRITE","paramCount":2,"schema":"d7ea6b1800f7","response":"3797626bd17e","injectAuth":"companyId+updatedBy","permission":"production:update","paginates":false},- {"name":"production_updateAssemblyStepHiddenComponents","classification":"WRITE","paramCount":2,"schema":"d5e5982cfa52","response":"3797626bd17e","injectAuth":"companyId+updatedBy","permission":"production:update","paginates":false},+ {"name":"production_updateAssemblyStepHiddenComponents","classification":"WRITE","paramCount":3,"schema":"3ac4e88c4df0","response":"3797626bd17e","injectAuth":"companyId+updatedBy","permission":"production:update","paginates":false},{"name":"production_updateAssemblyStepJoin","classification":"WRITE","paramCount":3,"schema":"fe25857086d1","response":"3797626bd17e","injectAuth":"companyId+updatedBy","permission":"production:update","paginates":false},{"name":"production_updateAssemblyStepMotion","classification":"WRITE","paramCount":3,"schema":"6665a9b53a17","response":"3797626bd17e","injectAuth":"companyId+updatedBy","permission":"production:update","paginates":false},{"name":"production_updateInspectionDocumentSampling","classification":"WRITE","paramCount":7,"schema":"e85058fba971","response":"bcde375ebd4c","injectAuth":"companyId+updatedBy+userId","permission":"production:update","paginates":false},diff --git a/apps/erp/app/routes/x+/assembly+/$id.steps.hidden.$stepId.tsx b/apps/erp/app/routes/x+/assembly+/$id.steps.hidden.$stepId.tsxindex c907af7cd3..15e1740d7a 100644--- a/apps/erp/app/routes/x+/assembly+/$id.steps.hidden.$stepId.tsx+++ b/apps/erp/app/routes/x+/assembly+/$id.steps.hidden.$stepId.tsx@@ -36,6 +36,7 @@ export async function action({ request, params }: ActionFunctionArgs) {const update = await updateAssemblyStepHiddenComponents(client, {id: stepId,+ assemblyInstructionId: id,hiddenComponentNodeIds: validation.data.hiddenComponentNodeIds,updatedBy: userId});diff --git a/apps/erp/app/routes/x+/assembly+/$id.tsx b/apps/erp/app/routes/x+/assembly+/$id.tsxindex 7747ca12b3..7230fb2635 100644--- a/apps/erp/app/routes/x+/assembly+/$id.tsx+++ b/apps/erp/app/routes/x+/assembly+/$id.tsx@@ -22,7 +22,7 @@ import {stagedGroupNodeIds} from "@carbon/viewer";import { msg } from "@lingui/core/macro";-import { useCallback, useMemo, useRef, useState } from "react";+import { useCallback, useEffect, useMemo, useRef, useState } from "react";import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";import {data,@@ -298,6 +298,15 @@ export default function AssemblyInstructionRoute() {},[hiddenFetcher, id]);+ // A failed save must not keep showing the unsaved list: fall back to the step's saved one.+ useEffect(() => {+ if (+ hiddenFetcher.state === "idle" &&+ hiddenFetcher.data?.success === false+ ) {+ setDraftHiddenNodeIds(null);+ }+ }, [hiddenFetcher.state, hiddenFetcher.data]);// The selected step shows its hidden draft before the autosave round-trips.const viewerSteps = useMemo(