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.
Mobile chrome: one compact signal, one record header, one slot primitive
Status: approved Author: Claude (with the branch owner) Date: 2026-10-07
TLDR
The mobile redesign works, but its phone chrome is built three times over:
- The breakpoint: "is this a phone?" is answered by two hooks and two breakpoint units.
- Record headers: every record header writes its desktop header and its phone header separately, and is wired to the phone bar by 149 hand-placed wrappers.
- Registries: five separate registries move content into the shell.
This spec merges each of these into one mechanism and keeps behaviour the same:
- one compact signal (B3);
- one
RecordHeaderthat renders the desktop row and the phone chrome from one set of props (B1); - one slot module with two primitives, a portal slot and a value slot, which replaces the five registries (B2).
Research: .ai/research/2026-10-07-record-header-catalogue.md.
Overview diagram
flowchart LR
subgraph Today
H["*Header.tsx"] --> RC["RecordChrome (hero, ⋯, bar)"]
H --> DS["hand-built desktop shell"]
H --> RA["149 × RecordAction → zustand targets"]
DT["DetailsTopbar"] -- effect --> PC["PanelContext.recordTabs"]
P["pages"] --> OV["override store"]
P --> CS["ChromeSlots context + count store"]
end
subgraph After
H2["*Header.tsx"] --> RH["RecordHeader (one prop set)"]:::new
RH --> PS["portal slots"]:::new
DT2["DetailsTopbar"] --> VS["value slots"]:::new
P2["pages / NewRecordPage"] --> VS
end
classDef new stroke-dasharray:4 3
Problem Statement
Each item below cites the file and line where the problem is.
- "Compact" has several sources of truth.
- The breakpoint is written twice. JS uses
(max-width: 767px)(packages/utils/src/viewport.ts:15-17). CSS useswidth < 48rem(packages/config/tailwind/theme.css:19,33,448). - The opt-in is written twice: the
data-compact-uiattribute (apps/erp/app/root.tsx:260) andCompactProvider enabled(root.tsx:346). - There are two hooks:
useCompact(built on useSyncExternalStore) anduseIsMobile(built on useState plus an effect, and seeded throughuseCompactSeed). - In the ERP,
isMobile === isCompactalways. That makes theuseIsMobilebranches dead code: the Panels drawer branch atPanels.tsx:279-327sits behindif (isCompact)at:268.
- The breakpoint is written twice. JS uses
- Every record header is built twice.
- The duplication: 27 topbar headers render
<RecordChrome hero menu copyValue>and also a hand-writtencompact:hiddendesktop shell, passing the same title, Copy value, ⋯ menu and status to both. The catalogue found no case where the two disagree, which shows they are pure duplication. - Stateful titles need
{!isCompact && …}guards so they don't mount twice (Assembly, Builder). - The overflow sheet restyles other components' buttons with CSS selectors such as
[&_button]…and[&_.bg-destructive](RecordChrome.tsx:106-117). - The sheet closes through a native capture listener, a
setTimeoutand anaria-haspopupheuristic (RecordChrome.tsx:138-154). - In about 14 actions, the phone slot and the desktop variant disagree, so the bar shows two filled buttons or a main cell styled grey. PO patches this with an
isCompactbranch (PurchaseOrderHeader.tsx:238-243).
- The duplication: 27 topbar headers render
- Five registries do one job.
- The five:
- ChromeSlots, a context holding
useStatetargets, plus a separate zustand count store. - RecordChrome's zustand target and count store.
- The app-bar override store.
recordTabs, pushed into PanelContext from an effect keyed on a hand-serialisedlinksKey.CompactPanelProvider/inert, which exist only to give phones that registry.
- ChromeSlots, a context holding
- On top of that, the app bar marks
/newroutes as pushed with a pathname rule (useAppBar.ts:34-42). - Two routes copy the app bar's Back button JSX word for word (
issue-workflow+/new.tsx:82,inventory+/quantities+/$itemId.tsx:110).
- The five:
Proposed Solution
B3 — one compact signal
- The query:
viewport.tsexports one query,COMPACT_QUERY = "(width < 48rem)". It is the same string Tailwind andtheme.cssuse.COMPACT_MAX_WIDTHis deleted, and the inline cookie-hint script keeps usingCOMPACT_QUERY. - The hooks:
Compact.tsxowns onesubscribe/getSnapshotpair over that query.useCompact(): aCompactProvideris present and the query matches.useIsMobile(): the query alone, with no opt-in. It moves intoCompact.tsxon the same store:- its server snapshot is the provider's
initialCompact, elsefalse, so MES and starter keep gettingfalsebefore hydration, as!!isMobilereturned before; useCompact()isuseIsMobile()plus the provider check;hooks/useIsMobile.tsre-exports it.
- its server snapshot is the provider's
useCompactSeedis deleted.
- The provider:
CompactProviderloses itsenabledprop. Its presence is the JS opt-in.root.tsxsetsdata-compact-uion the same element tree, with a one-line comment linking the two, and those are the only two opt-in sites. - ERP callers of
useIsMobile:Panels.tsx:- the
PanelProvidercollapse effect switches toisCompact, which is the same value, so behaviour is identical; - the drawer branch and its pathname-collapse effect are deleted.
- the
CollapsibleSidebar.tsx: itswasMobileeffect switches toisCompactif the stored-open behaviour across the breakpoint is still wanted, and is deleted if it only served the removed drawer. The plan step reads it and records which.Breadcrumbs.tsx: its!isMobilebranches are deleted. Breadcrumbs only renders whenTopbaris not compact.
B1 — one record header
RecordHeader (apps/erp/app/components/Layout/RecordHeader.tsx) replaces RecordChrome and the hand-built shells.
<RecordHeader
title={id} // ReactNode; rendered once per breakpoint
titleTo={path.to.xDetails(id)} // optional Link
copyValue={id} // optional; desktop <Copy> + app-bar "Copy ID"
menu={menuItems} // optional; desktop ⋯ + app-bar ⋯
status={badges} // optional; desktop row + hero
subtitle={metaLine} // optional; hero (and desktop under the title)
onToggleExplorer={toggleExplorer} // optional leading IconButton
onToggleProperties={toggleProperties} // optional trailing IconButton
aside={<DetailsTopbar links={…} />} // optional right-hand node (item tabs)
actions={<>…RecordActions…</>}
/>
Desktop shell
- It is rendered from the props in one fixed order: leading toggle, title, Copy, ⋯, status, then on the right side the aside, actions and trailing toggle.
- Padding comes from whether there is a toggle:
- with a toggle at an edge, it is
p-2at that edge (shell A); - otherwise
px-4 py-2(shell B). - So no padding prop is needed.
- with a toggle at an edge, it is
- Stays mounted on phones: the shell is still rendered there, hidden with
compact:hidden. That keeps its modals,DetailsTopbarand the action portals alive. - Rendered once:
titlegoes into the shell only on desktop and into the hero only on phones. That replaces the{!isCompact && …}guards.
Phone chrome
- The hero holds
subtitleandstatus, in place, with--header-height/--hero-heightpublished as today. The app bar already names the record, so the hero showstitleonly when the caller setstitleInHero(an editable title, such as Assembly's name input). - The app bar ⋯ holds "Copy ID" and
menu. - The bottom bar holds the primary cell, the secondary cell and the ⋯ button for the overflow sheet.
- The hero, bar and sheet move into the
RecordPhoneChromepart, whichRecordHeaderand the card header share.
RecordAction
- It keeps
slot: "primary" | "secondary" | "overflow", and its children stay JSX. That includesfetcher.Form, SplitButton, PrintButton, Suspense/Await and DropdownMenu triggers. - On phones it fills the matching portal slot (B2) and provides a presentation context to what it wraps:
bar-primary: Button renders asvariant="primary" size="lg" w-full, whatevervariantit was given;bar-secondary: the same, withvariant="secondary";row: Button renders as an action-sheet row (h-12, start-aligned, transparent, 15px). Adestructivevariant becomes destructive text. After its ownonClickruns, the Button calls the context'sonSelect()to close the sheet, unless it is a popup trigger (aria-haspopup).SplitButtonreads the same context: its chevron becomes a 44px cell.- This replaces the
[&_button]/[&_.bg-destructive]selector overrides and the native listener. - The close is deferred to the next task, so a submit button's form is still mounted when the browser submits it. A comment keeps that reason.
- Controls that are not a Button render unchanged in the sheet: the Assignee popover trigger, and children that render null.
Overflow sheet: each portal slot owns its DOM element, and the slot's Target only shows that element. The sheet body is the overflow Target. When the sheet closes, the actions stay mounted in the detached element, so a PrintButton keeps its Modal. This fixes catalogue hazard 3. (Radix forceMount cannot do this: a closed, force-mounted modal Dialog still hides the rest of the app and blocks its pointer events.)
Card headers
DocumentHeader(the card variant) takes the same props:title,subtitle,status,menu,actions, andcopyValuedefaulting totitle.- On phones it hides its
CardHeaderand renders the hero through arecordHeroportal slot. - The 6 callers, plus
JournalEntryForm's hand-rolled copy, replace<RecordChrome …/>with<RecordHeroTarget bleed />. That keeps the hero where it renders today: outside the Card, full-bleed. The data is passed once.
Actions-only pages (InventoryCount, Reimbursement) render <RecordPhoneChrome /> (the bar only) in place of <RecordChrome />.
Per-header cleanup: when a header's slot and variant restate one status condition, the condition is named once (const isDraft = …) and used for both. Desktop variants do not change. PO's isCompact variant branch is deleted, because the bar cell now sets the style.
Deleted:
RecordChromeand its zustand store;RevisionSubtitle: Quote and PO build theid+RevisionSuffixnode once and pass it astitleand, when the revision is above 0, assubtitle. The phone shows the same subtitle as before.WorkflowTitlekeeps itsinHerostyling, because the hero still renders it with hero styles.
B2 — one slot module
apps/erp/app/components/Layout/Mobile/slots.tsx exports two primitives.
// Content that renders inside the shell: React context is preserved by a portal.
createPortalSlot(): {
Target: (props: ComponentProps<"div">) => JSX.Element; // stable ref, one target
Fill: (props: { children: ReactNode }) => ReactPortal | null; // compact only, counted
useFilled: () => boolean;
}
// Data a page hands the shell; newest provider wins, unmount removes only its own.
createValueSlot<T>(): {
useProvide: (value: T | null) => void; // caller memoizes `value`
useValue: () => T | null;
}
Portal slots:
appBarActionsreplacesAppBarActionsandChromeSlotsProvider. Its consumers:New,CompactToolbar, ChartOfAccounts filters and WorkflowBuilder.bottomBar: the tab bar hides while it is filled.- The record slots:
recordPrimary,recordSecondary,recordOverflow,recordHero. - Deleted:
ChromeSlotsProvider,useChromeSlotTargets, the BottomBar count store, RecordChrome's store and its module-level ref callbacks.
Value slots:
appBar: the override, typed asPartial<AppBarState> & { trailing?: ReactNode }.AppBarState.kindgains"selection"for list selection mode, which hides the page actions, the section switcher and the subtitle.MobileAppBarmerges the override overuseAppBar()and always renders Back from the mergedkind: "pushed"+backTo.- Deleted:
leading, both copied Back buttons, and theuseAppBar/newpathname rule.
NewRecordPageprovides{ kind: "pushed", backTo: <last crumb's to> }. The plan audits every full-page/newroute and moves any that does not renderNewRecordPageonto it, so none loses its Back button.recordTabs:DetailsTopbarprovides plain tab data{ name, to, count, active }, withactivecomputed from the location it already reads, so no closures are stored.CompactRecordTabsreads it, and also provides arecordFramevalue (true) thatDetailsTopbarreads to decide whether to render its own row.- This removes
recordTabs/setRecordTabsfromPanelContext,CompactPanelProvider,PanelProvider'sinert, and thelinksKeyeffect. The item routes go back to theirHEADproviders.
Design Decisions
| Decision | Choice | Rationale |
|---|---|---|
| Breakpoint unit | (width < 48rem) in JS |
Matches Tailwind/theme.css exactly; rem follows the user's default font size like the CSS already does. Range syntax needs Safari 16.4+, which the Tailwind v4 CSS already requires |
useIsMobile semantics |
viewport only, no opt-in, false before hydration without a provider |
The old hook returned !!isMobile; keeps MES/starter/Sidebar/FunnelChart behaviour; ERP gets the seeded first frame as today |
| JS opt-in | provider presence | One flag fewer; the enabled={false} case has no caller |
| Header actions API | JSX + RecordAction slot + presentation context |
User choice: keeps Suspense/Await, forms, PrintButton working; removes CSS reach-in and native listener |
| Slot vs desktop variant | slot stays explicit; phone bar cell decides style; desktop variants untouched | User choice; no desktop change; the 14 mismatches stop showing on phones |
| Desktop element order | title · Copy · ⋯ · status (fixed) | One shell instead of 8 orderings; the reordering is small and visible only on desktop (see Risks) |
| Card forms | DocumentHeader + RecordHeroTarget placement |
Keeps the phone hero full-bleed above the Card and the desktop CardHeader inside it, with data passed once |
| Popup scope | Modal, Drawer, BottomSheet, Popover, HoverCard, DropdownMenu and ContextMenu contents reset the presentation | React context crosses portals: without the reset, a dialog an action opens (PrintButton) would render its buttons as sheet rows. The old CSS selectors never reached portalled content |
| Overflow sheet mount | each portal slot owns its DOM element; Target only shows it |
Radix cannot keep a closed modal sheet mounted (hideOthers and disableOutsidePointerEvents: true would block the app, @radix-ui/react-dialog 1.1.15 index.mjs:137,145). An owned element keeps PrintButton's Modal alive when the sheet closes, with no per-action rules |
| Slot primitives | portal slot + value slot | Portals keep the filler's React context (forms, menus); data slots need no DOM |
| Create pages' Back | NewRecordPage declares it |
User choice; replaces the /new URL rule |
| CSS height vars | unchanged | Moving to pure flex layout is review section C, out of scope |
Data Model Changes
N/A: this is a UI-only refactor with no tables, columns or migrations.
API / Service Changes
N/A: no loaders, actions or services change. These public package APIs do change:
@carbon/react:CompactProviderlosesenabled;useCompactSeedis removed;useIsMobilenow comes fromCompact.tsx, with the same export name;- Button and SplitButton read an optional presentation context, so behaviour is unchanged without a provider.
@carbon/utils:COMPACT_MAX_WIDTHis removed.
UI Changes
- Desktop: every topbar record header renders the same elements, with one change: in 11 headers the order becomes title · Copy · ⋯ · status. Those headers are the 5 item headers, ChangeNotice, Issue, Maintenance, Procedure, Training and QualityDocument. Variants, actions and modals are unchanged.
- Phones:
- The bar's main cell is always filled and the second cell always outline.
- Sheet rows look as they do today.
- The sheet keeps PrintButton's dialog alive.
- Quote and PO keep
id+ revision as the hero subtitle. - Create pages and the quantities/issue-workflow screens keep their Back button.
Acceptance Criteria
-
rg "RecordChrome|ChromeSlotsProvider|useChromeSlotTargets|useCompactSeed|CompactPanelProvider|COMPACT_MAX_WIDTH|RevisionSubtitle" apps packagesreturns nothing (code only; docs excluded). -
rg 'endsWith\("/new"\)' apps/erp/app/components/Layoutreturns nothing, anduseAppBar.tshas no pathname rule. -
rg "\[&_button\]|\[&_\.bg-destructive\]" apps/erp/app/components/Layoutreturns nothing. -
rg "useIsMobile" apps/erpreturns nothing. - At 390px on a Sales Order in "To Ship and Invoice", the bar shows Ship filled, Invoice outline and ⋯. On desktop the same order shows both Ship and Invoice as primary, as before.
- At 390px on a Receipt, ⋯ → Print → the print dialog stays open after the sheet closes.
- At 390px on a Purchase Order, tapping ⋯ → Cancel Order closes the sheet and opens the cancel dialog. Tapping ⋯ → Preview opens its menu and keeps the sheet.
- At 390px,
/x/customer/newshows Back to Customers, and a list in selection mode shows "N selected" with Cancel and no page actions. - At 390px on a Part, the record tab row shows Details/Purchasing/… plus Properties. At desktop width, the Part's DetailsTopbar renders as before.
- At 390px an Assembly Instruction's name input appears once (in the hero) and saves on blur.
-
pnpm exec turbo run typecheck --filter=erp --filter=@carbon/react --filter=@carbon/utilspasses. Biome is clean on the changed files. The erpLayout/Tabletests, the react tests andviewport.test.tspass.appBar.test.tscovers the merged override and theselectionkind. - Every new user-facing string uses Lingui, and
pnpm lingui:extracthas been run.
Risks
| Risk | Severity | Mitigation |
|---|---|---|
| Desktop order change in 11 headers is unwanted | Low | Called out here for review at the spec gate. If it is rejected, a statusPlacement prop is the fallback |
A Button-like control in the sheet that is not a Button (Assignee) doesn't close the sheet |
Low | It is a popup trigger, which keeps the sheet open today too; listed in the plan's browser checks |
| Range-syntax media query on old iOS (< 16.4) | Low | The compact CSS already uses range syntax; JS now fails the same way the CSS does, rather than differently |
A full-page /new route without NewRecordPage loses its Back button |
Med | The plan audits every routes/**/new.tsx and its siblings; acceptance check at /x/customer/new |
| 38 call sites migrated in one pass | Med | Migrate in batches by shell kind, with typecheck after each; desktop and 390px screenshots of one header per batch (needs the user's go-ahead to drive the browser) |
Open Questions
- Does "all" cover the C/D review sections too? — Answer: No. B1–B3 now, and C/D in a later pass, because several depend on B.
- How are header actions written? — Answer: As JSX with a presentation context: one
RecordHeaderowns both layouts, and Button reads the context to render as a bar cell or a sheet row. - How does a create page declare that it shows Back? — Answer:
NewRecordPagedeclares it, and the/newURL rule is deleted. Full-page create routes are audited and moved onto it. - Phone slot and desktop variant disagree in about 14 actions: which wins? — Answer: Phone styling only. The slot stays, the bar cell decides the phone style, and desktop variants don't change.
Changelog
- 2026-10-07: Draft written after the four questions above were resolved.
- 2026-10-07: Implemented (uncommitted). Changes from the draft:
useIsMobilereturnsfalsebefore hydration, as the old hook did.- Portal slots own their DOM element, in place of Radix
forceMount(see Design Decisions). - Popup contents reset the action presentation.
- The hero title is opt-in (
titleInHero). - Selection mode shows no Back button.
- A create page whose app bar was already pushed now goes Back to its list (its last crumb), not to the module.
- The
/newaudit found no full-page route outsideNewRecordPage(.ai/runs/2026-10-07-new-route-audit.txt).
- 2026-10-07: The inline
<head>cookie script is removed.CompactProviderwrites the compact hint cookie on mount and on each breakpoint crossing (compactHintCookieinviewport.ts), so one place watches the width per app.