Skip to content

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.

Merge remote-tracking branch 'origin/main' into fix/mes-ui-imp

aashu48d28bd4da07
diff --cc .ai/lessons.md
index c454a4a544,a048472675..6a99a053c5
--- a/.ai/lessons.md
+++ b/.ai/lessons.md
@@@ -1287,9 -1287,45 +1287,52 @@@ as the breakdown. Name the two so they
(`findExportScopeViolationsDetailed`, `computeScopeExclusions`, `totalExcludedRows`),
`Manifest.excludedRowsByTable`, and any future "N things are wrong" surface.
+## Browser-testing MES flows that write data
+
+- **Context:** Verifying AssemblyView keyboard shortcuts with agent-browser while editing the same file (Vite HMR live).
+- **Problem:** Step records appeared at timestamps with no corresponding keypress; hours went into suspecting the new code. Cause: overlapping test sessions — a page left open across HMR edits (sometimes with a modal up) replays/refires interactions, and interleaved key presses land on freshly auto-advanced steps.
+- **Rule:** When a browser test writes rows, run it as a closed loop: wipe the rows, reload the page fresh, then check the DB after EVERY single action before pressing the next key. Never diagnose from an accumulated tail of prior test sessions.
+- **Applies to:** agent-browser verification of any MES/ERP flow with side effects, especially while HMR is live.
++
+ ## Full-screen height calcs must subtract the app-shell inset
+
+ **Context:** The ERP app shell (`apps/erp/app/routes/x+/_layout.tsx`, PR #1551) moved
+ content into an inset floating panel with `md:mt-2 md:mb-2` (8px top + 8px bottom
+ gutters). ~81 full-screen pages/explorers sized themselves with
+ `calc(100dvh - var(--topbar-height) [- var(--header-height)])`, which assumes the
+ content spans the full viewport.
+
+ **Problem:** Those containers are 16px taller than the panel at md+, so bottom-pinned
+ content is pushed below the panel's clipped edge. The Procedures "Add Step" footer was
+ sheared in half; the overflow was invisible on pages whose content merely scrolls.
+
+ **Rule:** `vh`/`dvh` ignore the panel inset by nature, so any full-height calc inside the
+ content panel must subtract `var(--content-inset)` (defined in `styles/tailwind.css`: 0
+ below md, 1rem at md+), e.g. `h-[calc(100dvh-var(--topbar-height)-var(--content-inset))]`.
+ Prefer `h-full`/flex height inheritance from `<main>` for new pages so the inset never
+ has to be tracked by hand. Do NOT add the inset to viewport-fixed/body-portaled elements
+ (dialogs, drawers) or to `PrimaryNavigation`, which live outside the panel.
+
+ **Applies to:** every `calc(100dvh-var(--topbar-height)...)` in `apps/erp/app`, the shared
+ `components/Layout/Panels.tsx` + `Navigation/CollapsibleSidebar.tsx`, and any new
+ full-screen ERP route.
+
+ ## The backups schema baseline on main can carry phantom tables from a dirty local DB
+
+ **Context:** `pnpm db:check:backups` blocked the currency-refactor commit on `onshapeSyncRun`/`onshapeItemSyncState` — tables with NO migration anywhere in the repo.
+
+ **Problem:** `packages/jobs/manifests/schema.json` regenerates from the committing developer's LIVE schema. If that database has tables applied from an unmerged branch, they enter the committed baseline, and every later committer's check flags them as "dropped without a rename mapping" — a false alarm that invites `--no-verify` reflexes or, worse, bogus `TABLE_RENAMES: null` entries declaring never-shipped tables dropped.
+
+ **Rule:** When `db:check:backups` blocks on a missing table, first verify the table exists in ANY migration (`grep -r <table> packages/database/supabase/migrations/`). No migration ⇒ baseline pollution, not your break: regenerate `schema.json` from a clean fully-migrated database (the catalog code in `src/backups/schema.ts` + the manifest shape in `check-backups.ts`), commit it with `CARBON_SKIP_BACKUP_CHECK=1`, and say why in the commit message. Never add a rename entry for a table that never shipped.
+
+ **Applies to:** `packages/jobs/manifests/schema.json`, `packages/jobs/src/scripts/check-backups.ts`, `.husky/pre-commit`.
+
+ ## Adding CHECK + VALIDATE requires auditing every WRITER of the column and pre-cleaning data in the same migration
+
+ **Context:** The currency refactor added `CHECK ("exchangeRate" > 0)` + `VALIDATE` on 12 document tables. Review found `get-method` had been writing `exchangeRate: l.exchangeRate ?? 0` into `quoteLinePrice` for every legacy null-rate quote line, and the old `NUMERIC(10,4)` clamp had stored sub-0.00005 rates as literal `0.0000`.
+
+ **Problem:** `VALIDATE CONSTRAINT` scans existing rows mid-deploy — one violating row anywhere fails the whole migration in production, and post-deploy the unfixed writer fails at runtime (a whole edge-function transaction). A constraint that is obviously true "going forward" says nothing about years of rows written by code paths you didn't grep.
+
+ **Rule:** Before adding a CHECK on an existing column: (1) grep EVERY writer of that column — app services, edge functions, triggers, seeds — and fix any that can produce a violating value in the same change set; (2) repair existing violating rows in the same migration, before the VALIDATE (`UPDATE … WHERE <violates>` with an explainable value); (3) remember old NUMERIC(p,s) clamps — a widened column can still hold rounded-to-zero values from its clamped era.
+
+ **Applies to:** any `ADD CONSTRAINT … CHECK` + `VALIDATE` migration; `packages/database/supabase/functions/**` writers of the constrained column.
diff --cc apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
index e1c5887ec7,3f69603932..7cdb63232f
--- a/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
+++ b/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
@@@ -1,6 -1,6 +1,6 @@@
{
- "generated": "2026-09-03T02:17:05.898Z",
- "totalTools": 1490,
- "generated": "2026-09-03T15:31:57.926Z",
++ "generated": "2026-09-04T09:40:33.003Z",
+ "totalTools": 1495,
"modules": 15,
"tools": [
{
diff --cc packages/react/src/index.tsx
index 527b603433,b8189e1776..0509effdd1
--- a/packages/react/src/index.tsx
+++ b/packages/react/src/index.tsx
@@@ -665,7 -662,7 +668,8 @@@ export type
OperatingSystemPlatform,
Shortcut,
ShortcutDefinition,
+ ShortcutInput,
+ SubheadingProps,
TextareaProps,
ExpiredEntityPolicy,
TrackedEntityOption,