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.
Assembly step hidden components — implementation plan
Spec / source: .ai/specs/2026-09-25-assembly-step-hidden-components.md
Branch: feat/asembly-view-isolation
Worktree root: /Users/aashu/work/carbon/carbon-feat-asembly-view-isolation
(run every command from here)
Progress
- Task 1: Add the
hiddenComponentNodeIdscolumn, apply it, regenerate DB types - Task 2: Viewer — per-step hidden set (type, pure helper + test, scene wiring)
- Task 3: ERP data layer — validator, service, strip-on-add, route, path,
toViewerStep - Task 4: MES — read and pass the hidden lists
- Task 5: ERP editor state — draft + autosave in
$id.tsx, thread through the explorer - Task 6: ERP Components panel — eye edits the selected step's saved list
- Task 7: ERP step Details — "Hidden on this step" list
- Task 8: Translations, typecheck, lint, tests
- Task 9: End-to-end verification against the local stack
Dependencies
Task 2 and Task 3 need Task 1. Task 4 needs Tasks 1–2. Task 5 needs Tasks 2–3. Tasks 6 and 7 need Task 5 and are independent of each other. Task 8 needs 1–7. Task 9 needs 8.
Task 1: Add the column, apply it, regenerate DB types
Depends on: none Files:
- Create:
packages/database/supabase/migrations/<timestamp>_assembly-step-hidden-components.sql - Modify (generated): database type output files written by
pnpm db:types - Copy from (precedent):
packages/database/supabase/migrations/20260910093006_assembly-step-lineage.sql
Steps:
pnpm db:migrate:new assembly-step-hidden-components(creates the timestamped file). If the generated file is not inpackages/database/supabase/migrations/, STOP and report.- File contents:
-- Per-step hidden components: nodeIds (same id space as "componentNodeIds") -- the author hides on THIS step only — tooling, fixtures, or installed parts -- blocking the view. Applied by the 3D player in the ERP editor and in MES. -- Never contains the step's own "componentNodeIds" (stripped on write). ALTER TABLE "assemblyInstructionStep" ADD COLUMN IF NOT EXISTS "hiddenComponentNodeIds" TEXT[] NOT NULL DEFAULT '{}'; pnpm db:migrate, thenpnpm db:types.
Verify:
docker exec carbon-carbon-feat-asembly-view-isolation-postgres-1 psql -U postgres -d postgres -At -c "select data_type, column_default from information_schema.columns where table_name='assemblyInstructionStep' and column_name='hiddenComponentNodeIds';"
# Expected: ARRAY|'{}'::text[]
git grep -c "hiddenComponentNodeIds" -- packages/database/src
# Expected: at least one file with a non-zero count
Out of scope: RLS policies (the table's existing policies cover the new column), jobOperationStep.
Task 2: Viewer — per-step hidden set
Depends on: 1 Files:
- Modify:
packages/viewer/src/types.ts—AssemblyStepgainshiddenComponentNodeIds?: string[]with a doc comment. - Modify:
packages/viewer/src/visibility.ts— addstepHiddenNodeIds. - Modify:
packages/viewer/src/visibility.test.ts— tests for it. - Modify:
packages/viewer/src/AssemblyPlayer.tsx— scenehiddenSetmemo. - Copy from (precedent):
visualForComponentinpackages/viewer/src/visibility.tsand its tests.
Steps:
- In
visibility.ts:
Import/** * The nodeIds to hide while `step` is active: the always-hidden set plus the * step's own authored hidden list, never including the parts the step itself * installs (a step must not animate an invisible part). */ export function stepHiddenNodeIds( alwaysHidden: readonly string[] | undefined, step: Pick<AssemblyStep, "componentNodeIds" | "hiddenComponentNodeIds"> | null ): Set<string> { const hidden = new Set(alwaysHidden ?? []); for (const nodeId of step?.hiddenComponentNodeIds ?? []) hidden.add(nodeId); for (const nodeId of step?.componentNodeIds ?? []) hidden.delete(nodeId); return hidden; }AssemblyStepas a type from./types. - Tests: step list added; own parts removed even when also in
alwaysHidden;nullstep returns onlyalwaysHidden; undefined inputs return an empty set. - In the scene component of
AssemblyPlayer.tsx, replace thehiddenSetmemo (currentlynew Set(hiddenNodeIds ?? []), near line 1020) withuseMemo(() => stepHiddenNodeIds(hiddenNodeIds, activeStep), [hiddenNodeIds, activeStep]).activeStepis defined earlier in the same component (steps[activeStepIndex] ?? null, near line 988). If it is not in scope at that point, STOP and report.
Verify:
pnpm --filter @carbon/viewer test -- visibility
# Expected: all visibility tests pass, including the new stepHiddenNodeIds cases
pnpm --filter @carbon/viewer typecheck
# Expected: exit 0
Out of scope: the hiddenNodeIds prop's contract (kept), isolate/focus logic, ghost modes.
Task 3: ERP data layer
Depends on: 1 Files:
- Modify:
apps/erp/app/modules/production/production.models.ts— add afterassemblyInstructionStepComponentsValidator:export const assemblyInstructionStepHiddenComponentsValidator = z.object({ hiddenComponentNodeIds: jsonField(z.array(z.string())) }); - Modify:
apps/erp/app/modules/production/production.service.ts:- New
updateAssemblyStepHiddenComponents(client, { id, hiddenComponentNodeIds, updatedBy }): select the step'scomponentNodeIds; compute[...new Set(hidden)].filter(id => !own.has(id)); update onlyhiddenComponentNodeIds,updatedBy,updatedAt;.select("id").single(). Place it right afterupdateAssemblyStepComponents. updateAssemblyStepComponents: also select the step's currenthiddenComponentNodeIdsfirst, and writehiddenComponentNodeIds: hidden.filter(id => !newComponents.has(id))in the same update.reassignAssemblyStepComponents: selecthiddenComponentNodeIdsalongsidecomponentNodeIds; in the per-step update (the.set({ componentNodeIds: next, ... })call), also sethiddenComponentNodeIdsto the current hidden list minusnext's members. Keep the no-op skip, but do not skip when the hidden list would change.toViewerStep(near line 9241): addhiddenComponentNodeIds: step.hiddenComponentNodeIds ?? [].- Export the new function from the module index the same way
updateAssemblyStepComponentsis exported (checkapps/erp/app/modules/production/index.ts).
- New
- Modify:
apps/erp/app/utils/path.ts— next toassemblyInstructionStepComponents, addassemblyInstructionStepHiddenComponents: (id: string, stepId: string) => generatePath(\${x}/assembly/${id}/steps/hidden/${stepId}`)`, matching the neighbour's exact form. - Create:
apps/erp/app/routes/x+/assembly+/$id.steps.hidden.$stepId.tsx - Copy from (precedent):
apps/erp/app/routes/x+/assembly+/$id.steps.components.$stepId.tsx
Steps:
- The route mirrors the precedent:
assertIsPost,requirePermissions(request, { update: "production" }), validate with the new validator, callupdateAssemblyStepHiddenComponents, flasherror(..., "Failed to update hidden components")on failure, return{ success: true }. No material sync.
Verify:
pnpm --filter erp typegen && pnpm --filter erp typecheck
# Expected: exit 0
Out of scope: jobOperationStep sync, copyAssemblyInstructionAsVersion (spreads all columns already), step regenerate.
Task 4: MES — read and pass the hidden lists
Depends on: 1, 2 Files:
- Modify:
apps/mes/app/services/operations.service.ts— addhiddenComponentNodeIdsto the playback step select (near line 640). - Modify:
apps/mes/app/components/AssemblyView.tsx—AssemblyPlaybackstep type gainshiddenComponentNodeIds: string[] | null;toViewerStepmapshiddenComponentNodeIds: step.hiddenComponentNodeIds ?? [].
Verify:
pnpm --filter mes typecheck
# Expected: exit 0
Out of scope: any MES UI control.
Task 5: ERP editor state
Depends on: 2, 3 Files:
- Modify:
apps/erp/app/routes/x+/assembly+/$id.tsx - Modify:
apps/erp/app/modules/production/ui/Assemblies/AssemblyInstructionExplorer.tsx— thread props toAssemblyBomTree. - Copy from (precedent): the
draftComponentNodeIds+componentsFetcher+saveComponentNodeIdspattern in$id.tsx.
Steps:
- Remove the
hiddenNodeIdsstate and stop passinghiddenNodeIdstoAssemblyPlayer. - Add
draftHiddenNodeIds: string[] | nullstate, reset tonullinonSelectStepnext tosetDraftComponentNodeIds(null). - Add
hiddenFetcher+saveHiddenNodeIds(stepId, nodeIds)postinghiddenComponentNodeIds(JSON) topath.to.assemblyInstructionStepHiddenComponents(id, stepId). selectedHiddenNodeIds = draftHiddenNodeIds ?? selectedStep?.hiddenComponentNodeIds ?? []andselectedOwnNodeIds = draftComponentNodeIds ?? selectedStep?.componentNodeIds ?? [].onSetHiddenComponents(nodeIds: string[]): no-op whenisDisabledor noselectedStep; drops own ids; sets draft; saves.- When the components draft changes (in
onSelectComponentsadd-mode and inonRemoveComponents), if any added node is inselectedHiddenNodeIds, also set the hidden draft to exclude it. The server does the same, so no second save is needed. viewerSteps: map withtoViewerStep, then for the selected step overridehiddenComponentNodeIdswithselectedHiddenNodeIds, so the viewer updates instantly.- Explorer: replace the
onHideComponentsprop withhiddenNodeIds: string[],ownNodeIds: string[],hasSelectedStep: boolean, andonSetHiddenComponents: (nodeIds: string[]) => void, passed straight toAssemblyBomTree.
Verify:
pnpm --filter erp typecheck
# Expected: errors only in AssemblyBomTree.tsx and AssemblyInstructionProperties.tsx about the new props (fixed in Tasks 6–7), or exit 0 if those were done first
Out of scope: isolate/focus behaviour (unchanged).
Task 6: ERP Components panel
Depends on: 5 Files:
- Modify:
apps/erp/app/modules/production/ui/Assemblies/AssemblyBomTree.tsx - Copy from (precedent): the existing eye
IconButton+Tooltipusage in the same file.
Steps:
- Props: replace
onHideComponentswithhiddenNodeIds,ownNodeIds,hasSelectedStep, andonSetHiddenComponents. Replace the localhiddenNodeIdsstate and its push-up effect withuseMemo(() => new Set(hiddenNodeIds)). AddownSetthe same way. canHide = hasSelectedStep && !isDisabled.onToggleHide(nodes):const eligible = nodes.filter(n => !ownSet.has(n)); if empty or!canHide, return. If every eligible node is hidden, remove them, otherwise add them. Then callonSetHiddenComponents([...next]).onHideSelection: add the selection minus own ids, then clear the selection as today.onShowAll:onSetHiddenComponents([]).- Add a local
HideTogglecomponent used by all four row types (UnitListRow,UnitChildRow,InstanceRow,ComponentRow) in place of their eyeIconButton. Props:label,hiddenstate,disabledReason?: string,onToggle. WhendisabledReasonis set, render the button disabled inside aTooltipwith that text. - Per row:
disabledReason=t\Select a step to hide parts on it.`when!hasSelectedStep`undefined, button disabled with no tooltip, whenisDisabledt\Installed on this step, so it can't be hidden here.`when every node of the row is inownSet`
- The toolbar "Hide selected components" button and context-menu item are disabled unless
canHide. The "Show all hidden components" controls are disabled unlesscanHide && hiddenNodeIds.length > 0. Translate the labels you touch witht/<Trans>viauseLinguifrom@lingui/react/macro(precedent:apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx:30).
Verify:
pnpm --filter erp typecheck
# Expected: no errors in AssemblyBomTree.tsx
Out of scope: unit/mapping features, untouched strings in the file.
Task 7: ERP step Details — "Hidden on this step"
Depends on: 5 Files:
- Modify:
apps/erp/app/modules/production/ui/Assemblies/AssemblyInstructionProperties.tsx - Modify:
apps/erp/app/routes/x+/assembly+/$id.tsx— pass the new props. - Copy from (precedent):
StepComponentsEditorin the same file (grouped rows viagroupComponentNodeIds, list styling, row click selects).
Steps:
- New props on
AssemblyInstructionProperties:hiddenNodeIds: string[]andonSetHiddenComponents: (nodeIds: string[]) => void. Thread them to whereverStepComponentsEditoris rendered (both call sites, near lines 214 and 591). - New
StepHiddenComponentsEditorrendered right belowStepComponentsEditor:- Header label:
<Trans>Hidden on this step</Trans>, plus a "Show all" button (<Trans>Show all</Trans>), shown when the list isn't empty and notisDisabled. - Rows:
groupComponentNodeIds(hiddenNodeIds, graphIndex). Clicking a row callsonSelectComponents(group.nodeIds). An eyeIconButtonwitharia-label={t\Show ${group.name}`}callsonSetHiddenComponents(hidden minus group.nodeIds), hidden whenisDisabled`. - Empty text:
<Trans>Nothing hidden. Use the eye in the Components panel to hide parts on this step.</Trans>.
- Header label:
Verify:
pnpm --filter erp typecheck
# Expected: exit 0
Out of scope: changing StepComponentsEditor.
Task 8: Translations, typecheck, lint, tests
Depends on: 1–7 Steps:
pnpm lingui:extract, thenpnpm lingui:compile.pnpm --filter @carbon/viewer typecheck,pnpm --filter erp typecheck,pnpm --filter mes typecheck.pnpm exec biome checkon the changed files only (list them withgit diff --name-only, plus untracked files).pnpm --filter @carbon/viewer test.
Verify:
git diff --stat -- '*.po' | tail -1
# Expected: the catalogs changed (new msgids present)
grep -rn "Hidden on this step" apps/erp/locales 2>/dev/null | head -1 || git grep -n "Hidden on this step" -- '*.po' | head -1
# Expected: one match
Out of scope: fixing pre-existing lint warnings in untouched code.
Task 9: End-to-end verification
Depends on: 8 Steps (local stack; the ERP dev server must be restarted by the user if it doesn't pick up the new route):
- Pick the "engine with piston" instruction (
daqc4a80a0gij77qs4sg). Choose a step S with components and a node N that is not one of S's components. - Sign in as the local dev-bypass user (POST
/loginwith that user's email; the email must matchDEV_BYPASS_EMAIL, compared without printing it). Then POSThiddenComponentNodeIds=["N", <one of S's own ids>]to/x/assembly/<id>/steps/hidden/<S>. - The DB row for S has
hiddenComponentNodeIds = {N}, with the own id stripped (criterion 2). - POST S's components plus N to the components route. S's hidden list becomes empty (criterion 6). Restore S's components afterwards.
- Criterion 7 (version copy keeps the list) is checked by reading code, not by creating a version: confirm
copyAssemblyInstructionAsVersionstill selects*fromassemblyInstructionStepand spreads each row. Record it in the report as verified by code reading. - Screenshot the ERP editor with step S selected via Playwright (the headless tooling in the scratchpad), confirming the "Hidden on this step" box lists N and the part is not drawn (criteria 1, 3).
- Delete the session cookie file afterwards.
Verify: the DB queries in steps 3–4 return the expected arrays; the screenshot shows the list. Out of scope: MES screenshot (MES needs a job operation linked to the instruction; covered by the playback query + shared player code and typecheck. Report this as not verified in a browser).