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.
Change Notices as a "where referenced" category — implementation plan
Spec / source: .ai/specs/2026-08-18-change-notices-used-in-and-issue-sidebar.md
Branch: feat/cn-improvements
No migrations, no schema changes, no new service functions. Every query already exists and is already called by the routes being changed.
Progress
- Task 1: Add the
changeNoticescategory to the sharedUsedIntree component - Task 2: Wire the Change Notices category into the Part detail route
- Task 3: Wire the Change Notices category into the Tool detail route
- Task 4: Widen
IssueAssociationNodewith a read-only, non-junction key - Task 5: Support read-only categories in
IssueAssociations.tsx - Task 6: Wire the Change Notices category into the Issue detail route
- Task 7: Remove the Change Notices block from
IssueProperties.tsx - Task 8: Full verification pass (typecheck + biome + tests green; browser checks below still pending)
Dependencies
- Task 2 needs Task 1
- Task 3 needs Task 1
- Tasks 2 and 3 are independent of each other — may run in parallel
- Task 5 needs Task 4
- Task 6 needs Tasks 4 and 5
- Task 7 is independent of Tasks 1–6 — may run in parallel with any of them
- Task 8 needs everything
Task 1: Add the changeNotices category to the shared UsedIn tree component
Depends on: none
Files:
- Modify:
apps/erp/app/modules/items/ui/Item/UsedIn.tsx— add the key, an optionalstatuson children, a link case, a status badge, and an exported node builder. - Copy from (precedent): the
jobstrailing-Badgeblock already inUsedInItematapps/erp/app/modules/items/ui/Item/UsedIn.tsx:566-579, and theChangeNoticeStatususage atapps/erp/app/modules/quality/ui/Issue/IssueProperties.tsx:572.
Steps:
Add the import after the existing
ItemChangeNoticeLockimport block (which currently ends at line 52):import ChangeNoticeStatus from "../ChangeNotice/ChangeNoticeStatus";ChangeNoticeStatusis a default export fromapps/erp/app/modules/items/ui/ChangeNotice/ChangeNoticeStatus.tsx. It takes{ status?: ChangeNoticeStatusType | null }and returnsnullfor an unknown or missing status, so no guard is needed at the call site.Add
"changeNotices"to theUsedInKeyunion (currently at lines 67–82). Insert it in alphabetical position, i.e. between"assemblyInstructions"and"inspections":export type UsedInKey = | Database["public"]["Enums"]["itemType"] | "assemblyInstructions" | "changeNotices" | "inspections" // …rest unchangedAdd an optional
statustoUsedInNode["children"](the type at lines 115–129). Add it as the last field:export type UsedInNode = { key: UsedInKey; name: string; module: string; children: { id: string; documentReadableId: string; documentId?: string; documentParentId?: string; itemType?: ItemType; methodType?: string; revision?: string; version?: number; status?: string; }[]; };This is additive and optional, so the existing
ImpactPanel.tsxconsumer and all current route call sites keep compiling unchanged.In
getUseInLink(theswitchstarting at line 599), add a case immediately aftercase "assemblyInstructions"::case "changeNotices": return path.to.changeNotice(child.documentId ?? child.id);path.to.changeNoticealready exists (apps/erp/app/utils/path.ts:387) and returns/x/items/change-notice/${id}.In
UsedInItem, add the status badge. Insert this block immediately after thenode.key === "jobs"badge block (which currently ends at line 579) and before the{child.version && (block at line 580:{node.key === "changeNotices" && child.status && ( <div className="ml-2"> <ChangeNoticeStatus status={child.status as ChangeNoticeStatusType} /> </div> )}Add the type-only import alongside the value import from step 1:
import type { ChangeNoticeStatus as ChangeNoticeStatusType } from "../../types";(
apps/erp/app/modules/items/types.tsis whereChangeNoticeStatusthe type lives — this is the same pair of importsChangeNoticeStatus.tsxitself uses at its line 2. Theascast is deliberate:child.statusis a plainstringon the shared node type, andChangeNoticeStatusalready returnsnullfor any value not in its colour map.)Also confirm the icon branch renders acceptably:
UsedInItempicks the row icon at lines 541–550 bychild.methodType/node.module. Change-notice children set neithermethodTypenormodule: "quality", so they fall through to<MethodIcon type="Method" />. Leave this as-is — do not add a change-notice icon branch. (Out of scope; the status badge is the distinguishing signal.)At the end of the file (after
getUseInLink), export the node builder so the four route call sites stay one line each:export function changeNoticesUsedInNode( changeNotices: { id: string; changeOrderId: string; status: string }[], name: string ): UsedInNode { return { key: "changeNotices", name, module: "parts", children: changeNotices.map((cn) => ({ id: cn.id, documentId: cn.id, documentReadableId: cn.changeOrderId, status: cn.status })) }; }module: "parts"is the change-notice permission domain, so the existingpermissions.can("view", node.module)gate at line 493 applies with no new logic.
Verify:
pnpm exec turbo run typecheck --filter=erp
# Expected: exits 0. No errors mentioning UsedIn.tsx or ImpactPanel.tsx.
Out of scope: Do not touch getPartUsedIn or getMaterialUsedIn in
items.service.ts. Do not touch ImpactPanel.tsx. Do not refactor the
duplicated tree-building in the route files.
Task 2: Wire the Change Notices category into the Part detail route
Depends on: Task 1
Files:
- Modify:
apps/erp/app/routes/x+/part+/$itemId.tsx— fold the existing open-only change-notice query into an all-statuses one, return both, and append the category node at both tree-building sites.
Steps:
Loader. At lines 75–96 the loader destructures
openChangeNoticesfrom aPromise.allwhose last entry is:// Locks manual version/revision creation while a CO owns this part findChangeNoticesForItem(client, { itemId, companyId, statuses: changeNoticeOpenStatuses })Rename the destructured binding to
allChangeNoticesand drop thestatusesargument, so the array entry becomes:// Every CO that references this part, any status. The open subset (which // locks manual version/revision creation) is derived below. findChangeNoticesForItem(client, { itemId, companyId })After the
partSummary.errorguard (i.e. after line 110, before theconst url = new URL(request.url);line), add:const changeNotices = allChangeNotices.data ?? []; const openChangeNotices = changeNotices.filter((cn) => changeNoticeOpenStatuses.includes(cn.status) );In the returned object (lines 151–163), replace the existing
openChangeNotices: openChangeNotices.data ?? []line with:changeNotices, openChangeNoticeschangeNoticeOpenStatusesis already imported in this file — do not add the import again. IfchangeNoticeOpenStatuses.includes(cn.status)produces a TypeScript error because the const array is narrowly typed, widen the check to(changeNoticeOpenStatuses as readonly string[]).includes(cn.status)rather than changing the const array initems.models.ts.openChangeNoticeskeeps its exact previous shape and meaning, souseItemOpenChangeNotices/ItemChangeNoticeLock/MakeMethodToolsneed no changes.Component. At line 178 the component reads
const { usedIn, methodTree } = useLoaderData<typeof loader>();. Change it to:const { usedIn, methodTree, changeNotices } = useLoaderData<typeof loader>();Tabbed branch. At line 381 there is a
tree.push({ key: "inspections", … })followed byreturn (<UsedInTree tree={tree} … />). Immediately after thattree.push(...)call (i.e. after line 386), add:tree.push(changeNoticesUsedInNode(changeNotices, t`Change Notices`));Buy (no-tabs) branch. The same structure is duplicated lower in the file:
tree.push({ key: "inspections", name: "Inspections", … })ending at line 553. Immediately after it add — note this branch uses plain string literals, nott\``, matching its neighbours:tree.push(changeNoticesUsedInNode(changeNotices, "Change Notices"));Add
changeNoticesUsedInNodeto the existing import from~/modules/items/ui/Item/UsedInin this file (the file already importsUsedInSkeleton, UsedInTreefrom that path).
Verify:
pnpm exec turbo run typecheck --filter=erp
# Expected: exits 0. No errors mentioning x+/part+/$itemId.tsx.
Out of scope: Do not touch apps/erp/app/routes/x+/part+/$itemId.details.tsx
— its separate getItemChangeNoticeData call, the ItemOpenChangeNoticeAlert
banner, and the ItemChangeNotices history card all stay exactly as they are.
Do not deduplicate the two tree-building branches.
Task 3: Wire the Change Notices category into the Tool detail route
Depends on: Task 1
Files:
- Modify:
apps/erp/app/routes/x+/tool+/$itemId.tsx— identical treatment to Task 2. - Copy from (precedent): the finished
apps/erp/app/routes/x+/part+/$itemId.tsxfrom Task 2 (this route is a near-verbatim clone of it).
Steps:
Loader. At lines 70–91 the
Promise.all's last entry is the samefindChangeNoticesForItem(client, { itemId, companyId, statuses: changeNoticeOpenStatuses })call, destructured asopenChangeNoticesat line- Apply the identical change as Task 2 step 1: rename the binding to
allChangeNoticesand drop thestatusesargument.
- Apply the identical change as Task 2 step 1: rename the binding to
After the
toolSummary.errorguard (after line 101, beforeconst url = new URL(request.url);at line 103), add:const changeNotices = allChangeNotices.data ?? []; const openChangeNotices = changeNotices.filter((cn) => changeNoticeOpenStatuses.includes(cn.status) );In the returned object (lines 135–147), replace
openChangeNotices: openChangeNotices.data ?? [](line 146) with:changeNotices, openChangeNoticesComponent. Find the
useLoaderData<typeof loader>()destructure in the default-exported component and addchangeNoticesto it.Tabbed branch. The tree is built at line 263 (
const tree: UsedInNode[] = [) and there is atree.push({ key: "inspections", … })at line 356 followed by<UsedInTreeat line 363. Insert after thattree.push(...)closes:tree.push(changeNoticesUsedInNode(changeNotices, t`Change Notices`));Buy (no-tabs) branch. Second tree at line 419, second
key: "inspections"push at line 512,<UsedInTreeat line 519. Insert after thattree.push(...)closes. Check whether this branch usest\Inspections`or the plain string"Inspections"` and match it exactly — uset\Change Notices`if the neighbour is translated,"Change Notices"` if it is a bare literal.Add
changeNoticesUsedInNodeto the existing import from~/modules/items/ui/Item/UsedIn(line 47 already importsUsedInSkeleton, UsedInTree).
Verify:
pnpm exec turbo run typecheck --filter=erp
# Expected: exits 0. No errors mentioning x+/tool+/$itemId.tsx.
Out of scope: apps/erp/app/routes/x+/tool+/$itemId.details.tsx. Do not
touch the material, consumable, or service routes — they use getMaterialUsedIn
and are deliberately excluded (change notices cannot target those item types).
Task 4: Widen IssueAssociationNode with a read-only, non-junction key
Depends on: none
Files:
- Modify:
apps/erp/app/modules/quality/types.ts— widenkey, addreadOnly, addstatusto children.
Steps:
Change the
IssueAssociationNodetype (lines 44–70) as follows. Only thekeyline, the newreadOnlyline, and the newstatuschild field change — everything else stays byte-identical:export type IssueAssociationNode = { key: IssueAssociationKey | "changeNotices"; name: string; pluralName: string; module: string; readOnly?: boolean; children: { id: string; documentId: string; documentReadableId: string; documentLineId: string; type: string; quantity?: number; disposition?: string | null; status?: string; links?: { // …unchanged }[]; }[]; };Leave
IssueAssociationKey(lines 41–42) unchanged. It must stay derived fromnonConformanceAssociationType, which is the contract for the 10 real junction tables and drives theswitchstatements inapps/erp/app/routes/x+/issue+/$id.association.new.tsxand$id.association.delete.$type.$associationId.tsx. A change notice is a reverse foreign key onchangeOrder.nonConformanceId, not a junction row.
Verify:
pnpm exec turbo run typecheck --filter=erp
# Expected: type errors ONLY in apps/erp/app/modules/quality/ui/Issue/IssueAssociations.tsx,
# where node.key (now widened) is passed to getAssociationIcon / getAssociationLink /
# NewAssociationModal, which all still expect IssueAssociationKey. Task 5 fixes these.
# If errors appear in any OTHER file, STOP and report — do not improvise.
Out of scope: Do not add "changeNotices" to nonConformanceAssociationType
in quality.models.ts. Do not create any nonConformanceChangeOrder table.
Task 5: Support read-only categories in IssueAssociations.tsx
Depends on: Task 4
Files:
- Modify:
apps/erp/app/modules/quality/ui/Issue/IssueAssociations.tsx - Copy from (precedent): the existing
node.key === "items"inline<Count>render at lines 252–254 (same slot, same pattern), and theChangeNoticeStatususage atapps/erp/app/modules/quality/ui/Issue/IssueProperties.tsx:572.
Steps:
Add imports.
ChangeNoticeStatusis already imported into the quality module elsewhere the same way — use the identical specifier:import type { ChangeNoticeStatus as ChangeNoticeStatusType } from "~/modules/items"; import { ChangeNoticeStatus } from "~/modules/items/ui/ChangeNotice";Add
LuGitPullRequestArrowto the existingreact-icons/luimport list.Widen the two helper signatures. Change
getAssociationIcon(line 299) andgetAssociationLink(lines 1043–1046) to take the widened key:function getAssociationIcon(key: IssueAssociationNode["key"]) {function getAssociationLink( child: IssueAssociationNode["children"][number], key: IssueAssociationNode["key"] ) {Add a case to
getAssociationIcon, immediately after the"inspections"case at line 319–320:case "changeNotices": return <LuGitPullRequestArrow className="text-purple-600" />;Add a case to
getAssociationLink, immediately after the"inspections"case at lines 1071–1072:case "changeNotices": return path.to.changeNotice(child.documentId);Hide the
+button for read-only nodes. InIssueAssociationItem, change the condition at line 211 from:{permissions.can("create", node.module) && (to:
{!node.readOnly && permissions.can("create", node.module) && (Hide the per-row delete menu for read-only nodes. Change the condition at line 257 from:
{permissions.can("delete", node.module) && (to:
{!node.readOnly && permissions.can("delete", node.module) && (Guard the new-association modal. The modal at lines 286–294 passes
type={node.key}, which no longer type-checks against the widened key. Change the guard at line 286 from:{newAssociationModal.isOpen && (to:
{newAssociationModal.isOpen && node.key !== "changeNotices" && (This narrows
node.keyback toIssueAssociationKeyinside the block, sotype={node.key}compiles with no cast. (It is also unreachable — step 5 means the modal can never be opened for a read-only node — but the narrowing is what makes it type-safe.)Render the status badge. In the child row, add a branch alongside the existing
node.key === "items"<Count>at lines 252–254. Replace that block with:{node.key === "items" && <Count count={child.quantity ?? 0} />} {node.key === "changeNotices" && child.status && ( <ChangeNoticeStatus status={child.status as ChangeNoticeStatusType} /> )}Leave
IssueAssociationsTree'strackedEntitiesfilter (lines 121–130) untouched — change notices must not be filtered out when empty. The empty state ("No change notice found" at lines 227–233) renders for them like every other category.
Verify:
pnpm exec turbo run typecheck --filter=erp
# Expected: exits 0. The errors Task 4's verify predicted are gone and no new ones appear.
Out of scope: Do not add a NewChangeNoticeAssociation form component. Do
not touch NewAssociationModal itself, $id.association.new.tsx, or
$id.association.delete.$type.$associationId.tsx.
Task 6: Wire the Change Notices category into the Issue detail route
Depends on: Tasks 4 and 5
Files:
- Modify:
apps/erp/app/routes/x+/issue+/$id.tsx— add one node to the hardcoded sidebar tree.
Steps:
The loader already fetches this data —
getChangeNoticesForNonConformanceat line 70, returned aschangeNotices: changeNotices.data ?? []at line 88. Make no loader change.In the component, line 94 currently reads:
const { associations } = useLoaderData<typeof loader>();Change it to:
const { associations, changeNotices } = useLoaderData<typeof loader>();In the
treearray (lines 110–182), append one node after the existinginspectionsnode (which ends at line 181, before the closing];at line 182). Add a comma after theinspectionsnode's closing brace, then:{ key: "changeNotices", name: t`Change Notice`, pluralName: t`Change Notices`, module: "parts", readOnly: true, children: changeNotices.map((cn) => ({ id: cn.id, documentId: cn.id, documentReadableId: cn.changeOrderId, documentLineId: "", type: "changeNotices", status: cn.status })) }documentLineIdandtypeare required on the child type but unused for this category:getAssociationLink'schangeNoticescase reads onlydocumentId, andtypeis only read by the deleteConfirmDeletepath, which read-only nodes never reach.module: "parts"gates the whole category behind the change-notice permission domain via the existingpermissions.can("view", node.module)check — a user withoutpartsview sees no category at all, matching every other category in this tree.IssueAssociationsTreesorts byname, so "Change Notice" lands between "Customer" and "Inspection". No ordering work needed.
Verify:
pnpm exec turbo run typecheck --filter=erp
# Expected: exits 0. No errors mentioning x+/issue+/$id.tsx.
Out of scope: Do not change the loader. Do not remove the "Create Change
Notice" item from the IssueHeader ⋮ menu
(apps/erp/app/modules/quality/ui/Issue/IssueHeader.tsx:75-89) — that stays as
the way to create one from an issue.
Task 7: Remove the Change Notices block from IssueProperties.tsx
Depends on: none (independent of Tasks 1–6)
Files:
- Modify:
apps/erp/app/modules/quality/ui/Issue/IssueProperties.tsx
Steps:
Delete the entire block at lines 557–577 — the
{changeNotices.length > 0 && ( … )}expression ending just before the closing</VStack>at line 578.Delete line 69:
const changeNotices = routeData?.changeNotices ?? [];Delete the
changeNoticesfield from theuseRouteDatageneric (lines 61–66), i.e. remove:changeNotices: { id: string; changeOrderId: string; name: string; status: ChangeNoticeStatusType; }[];Delete the two now-unused imports at lines 32–33:
import type { ChangeNoticeStatus as ChangeNoticeStatusType } from "~/modules/items"; import { ChangeNoticeStatus } from "~/modules/items/ui/ChangeNotice";Check whether
Link(fromreact-router) andpath(from~/utils/path, line 36) are still used elsewhere in the file. They almost certainly are —path.to.issue(id)is used at line 67. Only remove an import if Biome flags it as unused in Task 8; do not removepath.
Verify:
pnpm exec turbo run typecheck --filter=erp
# Expected: exits 0. No "declared but never used" errors in IssueProperties.tsx.
Out of scope: Do not touch any other block in this properties panel (assignee, priority, source, tags, custom fields).
Task 8: Full verification pass
Depends on: Tasks 1–7
Files: none modified (unless a check fails).
Steps:
Typecheck the ERP app. Note the package is named
erp, not@carbon/erp— a wrong filter silently no-ops and gives a false pass:pnpm exec turbo run typecheck --filter=erpLint. Biome is its own CI gate. This repo has roughly 419 pre-existing warnings — fix only error-severity findings introduced by this change and leave the pre-existing warnings alone:
pnpm exec biome check apps/erp/app/modules/items/ui/Item/UsedIn.tsx apps/erp/app/routes/x+/part+/\$itemId.tsx apps/erp/app/routes/x+/tool+/\$itemId.tsx apps/erp/app/modules/quality/types.ts apps/erp/app/modules/quality/ui/Issue/IssueAssociations.tsx apps/erp/app/routes/x+/issue+/\$id.tsx apps/erp/app/modules/quality/ui/Issue/IssueProperties.tsxRun the unit tests:
pnpm run testReport the actual output of each command. If any command fails, report the failure verbatim — do not claim the task is complete.
Verify:
pnpm exec turbo run typecheck --filter=erp && pnpm run test
# Expected: typecheck exits 0; test suite reports 0 failures.
Out of scope: Do not run pnpm lingui:extract or pnpm translate. On
this branch the extractor rewrites roughly 120k lines of unrelated .po churn,
which would bury the real diff. New t\Change Notices`` strings will be picked
up by the next intentional extract run.
Manual acceptance checks (after Task 8, requires a running app)
These map 1:1 to the spec's acceptance criteria and need a browser. Ask the user before starting the dev server.
- Part with an open change notice → Used In tab shows Change Notices with
count 1, the readable id (e.g.
CN-000004), and anImplementationbadge; clicking navigates to/x/items/change-notice/{id}. - Part whose only change notice is
Done→ still listed,Donebadge, and the Details-tab warning banner is absent and the+new-revision button is not locked. - Part with a
Cancelledchange notice → listed with aCancelledbadge. - Part with none → header row, no count, "No change notices found" when expanded.
- A Buy part (no Manufacturing/Used In tabs) → category present.
- Tool detail page → checks 1–4 behave identically.
- Issue with a linked change notice → left sidebar shows Change Notices with the id + status badge, and the right properties panel no longer shows a Change Notices block.
- The Change Notices sidebar row has no
+button and its rows have no delete option, while Items / Job Operations still have both. - A change notice's own Impact panel is unchanged — no Change Notices category inside it.