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(account): new users keep their initials, no generated avatar by default
naveenkash02cd106691cb
diff --git a/.ai/runs/2026-10-08-dicebear-avatars.md b/.ai/runs/2026-10-08-dicebear-avatars.mdindex 25eda91c9b..bb52fbedc1 100644--- a/.ai/runs/2026-10-08-dicebear-avatars.md+++ b/.ai/runs/2026-10-08-dicebear-avatars.md@@ -19,6 +19,7 @@- Line-art avatars: black lines on white in both themes, no invert — user request — 2026-10-08- Background color: user picks one per avatar with the ERP `ColorPicker`; stored as an optional `:<rrggbb>` value segment; dark backgrounds switch the neutral line styles to white ink — user request — 2026-10-08- Server-drawn avatars: a public `/file/avatar/:value` route in each app renders the SVG with DiceBear and caches it as immutable; `Avatar` uses it, the picker still draws in the browser — user approved the route after a slow-refresh report — 2026-10-08+- New users: no generated avatar by default; initials as before. the draft migration `20261008113405` is deleted (user: the PR is not merged, so no migration at all); a development database that ran it drops the default and its migration record by hand — user decision — 2026-10-08## Phase log- spec: written at `.ai/specs/2026-10-08-dicebear-avatars.md`. All 4 questions answered by the user before writing. STE-80 pass done.diff --git a/.ai/specs/2026-10-08-dicebear-avatars.md b/.ai/specs/2026-10-08-dicebear-avatars.mdindex 4089b26668..3e3529637e 100644--- a/.ai/specs/2026-10-08-dicebear-avatars.md+++ b/.ai/specs/2026-10-08-dicebear-avatars.md@@ -6,14 +6,12 @@## TLDR-Each new user gets a random generated avatar in the DiceBear "Croodles-Neutral" style. On the profile page, a user can choose one of 10 DiceBear-styles and pick an avatar in it, or upload a photo as before. `user.avatarUrl`-holds either a storage path (an uploaded photo) or a generated-avatar value-(`dicebear:<style>:<seed>`, with an optional `:<rrggbb>` background). A column default creates the value, so-every path that inserts a `user` row gets an avatar with no app code. The-avatar renders in the browser from the bundled DiceBear library. No request-goes to a third party.+A new user starts with no avatar and shows their initials, as before. On the+profile page, a user can choose one of 10 DiceBear styles and pick an avatar+in it, or upload a photo as before. `user.avatarUrl` holds either a storage+path (an uploaded photo) or a generated-avatar value (`dicebear:<style>:<seed>`,+with an optional `:<rrggbb>` background). The app draws a generated avatar on+the server from the bundled DiceBear library. No request goes to a third party.## Overview diagram@@ -26,11 +24,11 @@ flowchart LRB2 --> B5["public storage URL"]endsubgraph After- A1["user row: column default"]:::hot --> A2["Avatar wrapper"]:::hot- A2 --> A3["DiceBear SVG data URI"]:::new- A4["avatarUrl = storage path"] --> A2- A2 --> A5["public storage URL"]- A6["Profile: choose avatar"]:::new --> A1+ A1["user row: avatarUrl null"] --> A2["Avatar wrapper"]:::hot+ A2 --> A0["initials on a color"]+ A7["avatarUrl = dicebear value"]:::new --> A2+ A2 --> A3["server-drawn SVG"]:::new+ A6["Profile: choose avatar"]:::new --> A7endclassDef hot stroke-width:3pxclassDef new stroke-dasharray:4 3@@ -42,10 +40,10 @@ A user without an uploaded photo shows initials on a colored circle. Most usersnever upload a photo, so lists of people look the same and give no visualidentity. The request is:-1. Each new user gets a random avatar automatically.-2. A user can choose a different generated avatar.-3. A user can still upload a photo, as before.-4. New users get DiceBear "Croodles Neutral".+1. A user can choose a generated avatar on their profile.+2. A user can still upload a photo, as before.+3. A new user keeps the old behavior: no avatar, so the initials show.+4. The picker opens on DiceBear "Croodles Neutral".5. The user can choose from 10 styles: Croodles Neutral, Notionists,Notionists Neutral, Lorelei, Lorelei Neutral, Loops, Pixel Art, Voxel Art,Voxel Bot and Planets.@@ -137,8 +135,8 @@ background of its own, so it shows on `bg-muted`.| DiceBear major version | 10, pinned exactly | Loops, Voxel Art, Voxel Bot and Planets exist only in version 10. A new major version can give a different face for the same seed, so the versions are exact, not ranges. `@dicebear/core@10` needs Node 22, which every workflow in the repo uses || Style list | Only ever add to `GENERATED_AVATAR_STYLES` | A removed style makes its existing values unparseable, and those avatars fall back to initials. The `Record` type of `STYLE_LOADERS` makes a style without a loader a type error || Where the value is stored | In `user.avatarUrl` with the `dicebear:` prefix | 26 migrations put `avatarUrl` into views and RPCs. A new column would need a change to each of them. The prefix needs none |-| How a new user gets a value | Column default on `user.avatarUrl` | One place covers all 6 insert paths: the `create_public_user` trigger, invites, console operators, `migrateUserToSso`, seed and bootstrap |-| Seed of the default | `gen_random_uuid()::text` | The request is a random avatar. A random seed does not reveal the user id. The client uses `crypto.randomUUID()` for the same format |+| What a new user gets | No avatar (`avatarUrl` null), so the initials show | User decision: keep the old behavior. A draft migration that set a generated column default was removed before merge, so the schema does not change |+| Seed of a new avatar | `crypto.randomUUID()` | A random seed does not reveal the user id || Existing users | No backfill | User answer. They keep initials until they choose an avatar || Remove photo | Save a new random generated-avatar value | User answer. Every user who touches the profile ends with an avatar || Delete of the replaced photo | The profile action deletes the old upload AFTER it saves the new value. It deletes only a path that `isOwnAvatarUpload` accepts and that differs from the new value | If the save fails, `avatarUrl` still points at a file that exists. A failed delete only leaves an orphan file, so the action logs it. The same step also removes an old upload with a different file extension |@@ -153,16 +151,10 @@ background of its own, so it shows on `bg-muted`.## Data Model Changes-One migration. It changes only the column default. It writes no rows.--```sql-ALTER TABLE "user"- ALTER COLUMN "avatarUrl"- SET DEFAULT 'dicebear:croodles-neutral:' || gen_random_uuid()::text;-```--The generated types do not change, because `avatarUrl` is already nullable and-optional on insert.+None. `user.avatarUrl` keeps its type and stays without a default. A draft+migration (`20261008113405`) that set a generated default was deleted before+merge. A development database that ran the draft needs the default and the+migration record removed by hand.## API / Service Changes@@ -195,8 +187,7 @@ style is under the grid.## Acceptance Criteria-- [ ] After the migration, `INSERT INTO "user" ("id","email","firstName","lastName","about") VALUES (…)` gives a row whose `avatarUrl` starts with `dicebear:croodles-neutral:`.-- [ ] A new user from an employee invite has a `dicebear:croodles-neutral:` value after `createEmployeeAccount` returns.+- [ ] After both migrations, a new user (sign-up or invite) has `avatarUrl` null and shows their initials.- [ ] A user with a generated-avatar value sees a Croodles avatar in the ERP top-right menu, in the people lists and in the MES user menu.- [ ] A user with an uploaded photo still sees the photo in the ERP.- [ ] On the profile page, Choose avatar → select an option → Save shows the new avatar after the redirect.@@ -226,7 +217,8 @@ style is under the grid.## Open Questions- [x] Should the avatar art come from the bundled library or the HTTP API? — **Answer:** the bundled library (user). This approves the 2 new production dependencies.-- [x] Do existing users with no avatar get a generated avatar? — **Answer:** no backfill. Only new users (user).+- [x] Do existing users with no avatar get a generated avatar? — **Answer:** no backfill (user).+- [x] Do new users get a generated avatar automatically? — **Answer:** no. Changed by the user after the first build: new users keep the old initials; the column default is dropped.- [x] What does Remove do on an uploaded photo? — **Answer:** it saves a new random generated avatar (user).- [x] Which pipeline mode? — **Answer:** fully autonomous, spec → plan → execute → self-review, no browser test (user).- [x] Can a user set the background color? — **Answer:** yes, with a color picker; the default stays each style's own background (user).@@ -244,4 +236,5 @@ style is under the grid.- 2026-10-08: Server-drawn avatars (user request, refresh was slow). `Avatar` renders a generated value as `<img src="/file/avatar/:value?v=1">`; each app serves that route with `generatedAvatarLoader` (`@carbon/react/GeneratedAvatar`), which draws the SVG on the server and caches it for a year as immutable. The avatar is in the first HTML instead of waiting for hydration and two client downloads. The picker keeps drawing previews in the browser (`GeneratedAvatarPreview`). `GENERATED_AVATAR_RENDER_VERSION` is in every URL; bump it when the drawing changes.- 2026-10-08: Fix: picker previews stayed grey. The style imports had a JSON import attribute for the server, which the browser rejected. The attribute is gone; each app's `vite.config.ts` bundles `@dicebear/styles` into the server build instead.- 2026-10-08: Self-review 4. `generatedAvatarUrl` and `generatedAvatarClassName` moved to `generatedAvatarImage.ts`, so `Avatar` no longer bundles the renderer. A test guards against JSON import attributes. The spec now describes the route.+- 2026-10-08: New users no longer get a generated avatar (user decision). The draft migration `20261008113405` is deleted (the PR is not merged), so the branch has no schema change; `users.server.ts`, the Swagger schema and the backups manifest are back to `main`. New users show their initials, as before.- 2026-10-08: Implemented (uncommitted). The picker lives in the ERP account module. The account reference doc (`docs/content/docs/reference/account.mdx`) describes the new Photo behavior.diff --git a/apps/erp/app/modules/users/users.server.ts b/apps/erp/app/modules/users/users.server.tsindex 5951bf5bcb..f595090500 100644--- a/apps/erp/app/modules/users/users.server.ts+++ b/apps/erp/app/modules/users/users.server.ts@@ -397,7 +397,8 @@ export async function createCustomerAccount(id: userId,email: email.toLowerCase(),firstName: firstName ?? "",- lastName: lastName ?? ""+ lastName: lastName ?? "",+ avatarUrl: null});if (createCarbonUser.error) {@@ -569,7 +570,8 @@ export async function createEmployeeAccount(id: userId,email: email.toLowerCase(),firstName,- lastName+ lastName,+ avatarUrl: null});if (createCarbonUser.error) {@@ -699,7 +701,8 @@ export async function createSupplierAccount(id: userId,email: email.toLowerCase(),firstName: firstName ?? "",- lastName: lastName ?? ""+ lastName: lastName ?? "",+ avatarUrl: null});if (createCarbonUser.error) {@@ -759,11 +762,9 @@ export async function createSupplierAccount(return { success: true, code, userId, email };}-// `avatarUrl` is left to the column default (a generated avatar). The auth-// trigger has already inserted this row, and the upsert must not null it.async function createUser(client: SupabaseClient<Database>,- user: Omit<User, "fullName" | "avatarUrl">+ user: Omit<User, "fullName">) {const { data, error } = await insertUser(client, user);@@ -973,7 +974,7 @@ async function insertSupplierAccount(async function insertUser(client: SupabaseClient<Database>,- user: Omit<User, "fullName" | "createdAt" | "avatarUrl">+ user: Omit<User, "fullName" | "createdAt">) {return client.from("user").upsert([user]).select("*");}@@ -1020,6 +1021,7 @@ export async function createConsoleOperator(email: syntheticEmail,firstName,lastName,+ avatarUrl: null,active: true,isConsoleOperator: true} as any)diff --git a/docs/content/docs/reference/account.mdx b/docs/content/docs/reference/account.mdxindex c8175334bd..1ecf50610f 100644--- a/docs/content/docs/reference/account.mdx+++ b/docs/content/docs/reference/account.mdx@@ -13,7 +13,7 @@ Profile information is visible to other users. The form warns: *"This informatio<Field name="First name / Last name" required>Your display name across Carbon.</Field><Field name="Phone">Optional.</Field><Field name="About">A short bio, capped at 160 characters.</Field>- <Field name="Photo">Your avatar. Upload a photo, or pick a generated avatar with **Choose avatar**: choose a style (Croodles Neutral, Notionists, Lorelei, Loops, Pixel Art, Voxel Art, Voxel Bot, Planets and their neutral variants), then an avatar, and optionally a **Background** color (Reset returns to the style's own); Shuffle shows new ones. New users start with a random Croodles Neutral avatar, and removing an uploaded photo switches to a new one.</Field>+ <Field name="Photo">Your avatar. Upload a photo, or pick a generated avatar with **Choose avatar**: choose a style (Croodles Neutral, Notionists, Lorelei, Loops, Pixel Art, Voxel Art, Voxel Bot, Planets and their neutral variants), then an avatar, and optionally a **Background** color (Reset returns to the style's own); Shuffle shows new ones. New users start with no avatar and show their initials; removing an uploaded photo switches to a new generated avatar.</Field><Field name="Email">Shown but **read-only**. Your email is your sign-in identity, so changing it is handled outside these self-service settings.</Field></FieldTable>diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.tsindex 01fb6d9e77..9d83f8195c 100644--- a/packages/database/src/swagger-docs-schema.ts+++ b/packages/database/src/swagger-docs-schema.ts@@ -151783,8 +151783,6 @@ export default {type: "string"},avatarUrl: {- default:- "('dicebear:croodles-neutral:'::text || (gen_random_uuid())::text)",format: "text",type: "string"},diff --git a/packages/database/supabase/migrations/20261008113405_user-generated-avatar-default.sql b/packages/database/supabase/migrations/20261008113405_user-generated-avatar-default.sqldeleted file mode 100644index 7337044523..0000000000--- a/packages/database/supabase/migrations/20261008113405_user-generated-avatar-default.sql+++ /dev/null@@ -1,8 +0,0 @@--- New users get a random DiceBear Croodles Neutral avatar. The value is a--- seed, not a storage path: @carbon/react's Avatar renders it in the browser--- (see packages/utils/src/avatar.ts). A column default covers every path that--- inserts a user row (the auth.users trigger, invites, console operators, SSO--- migration, seeds). Existing rows are not changed.-ALTER TABLE "user"- ALTER COLUMN "avatarUrl"- SET DEFAULT 'dicebear:croodles-neutral:' || gen_random_uuid()::text;diff --git a/packages/jobs/manifests/schema.json b/packages/jobs/manifests/schema.jsonindex f074b9fe03..d63c1c8950 100644--- a/packages/jobs/manifests/schema.json+++ b/packages/jobs/manifests/schema.json@@ -1,11 +1,11 @@{"kind": "carbon-company-backup","version": 1,- "schemaVersion": "20261008113405",+ "schemaVersion": "20261007171726","sourceCompanyId": "schema-baseline","sourceCompanyGroupId": null,"sourceCompanyName": null,- "exportedAt": "2026-10-08T16:09:53.200Z",+ "exportedAt": "2026-10-08T17:43:20.314Z","exportedBy": "schema-baseline","label": "schema baseline","includeStorage": "none",diff --git a/packages/react/AGENTS.md b/packages/react/AGENTS.mdindex a2daa108ad..24ddb0e6d3 100644--- a/packages/react/AGENTS.md+++ b/packages/react/AGENTS.md@@ -49,7 +49,7 @@ import { Button, Card, HStack, VStack, IconButton, cn } from "@carbon/react";- **Data**: `Table` (TanStack), chart components via sub-exports (`@carbon/react/Chart`)- **Rich text**: `@carbon/react/Editor` and `@carbon/react/RichText` (wraps `@carbon/tiptap`)- **Error boundary**: `@carbon/react/ErrorBoundary` — `RouteErrorBoundary` (exported as `ErrorBoundary` from a module layout so a failed loader shows inside the app shell; it shows the status code and, for a 4xx, the message the server threw — `routeErrorCopy` — so throw a `Response` whose body says what was wrong. A 5xx or thrown `Error` gets generic copy) and `RootErrorBoundary` (drop-in root `ErrorBoundary` for RR v7 that maps 404 / other HTTP / thrown `Error` to a styled screen) plus its parts (`ErrorScreen`, `GlitchHeading`, `StatusReadout`, `MagneticLink`, `NoiseOverlay`). Wrap it in the app's `Document` and pass `env` so `window.env` is set (the client crashes hydration otherwise). Copy is intentionally hardcoded English, not i18n.-- **Avatar**: `src` may be a URL or a generated-avatar value from `user.avatarUrl` (`dicebear:<style>:<seed>[:<rrggbb>]`; the styles and value helpers are in `@carbon/utils` `avatar.ts`). A generated value renders as a plain `<img>` of `generatedAvatarUrl(value)` (`utils/generatedAvatarImage.ts`, which `Avatar` imports instead of the renderer so no bundle that shows an avatar carries DiceBear) — `/file/avatar/:value?v=<GENERATED_AVATAR_RENDER_VERSION>` — so it is in the server-rendered HTML and needs no client JavaScript. Every app (ERP, MES, academy) serves that path with a one-line route re-exporting `generatedAvatarLoader` from `@carbon/react/GeneratedAvatar`: it draws the SVG on the server with DiceBear 10 and answers `Cache-Control: public, max-age=31536000, immutable`, so a refresh reads it from the browser cache. **Bump `GENERATED_AVATAR_RENDER_VERSION` whenever the same value would draw differently** (a DiceBear upgrade, a change to the rendering options), or browsers keep the old image. The avatar picker draws in the browser instead (`GeneratedAvatarPreview`, `useGeneratedAvatar`), because a color drag makes a new value per step; there the DiceBear core and each style's JSON load with `import()` (`STYLE_LOADERS`, typed `Record<GeneratedAvatarStyle, …>`), never with a `with: { type: "json" }` attribute (Vite passes it to the browser, which rejects the JSON Vite serves as JavaScript, and the picker stays grey); the server side instead bundles `@dicebear/styles` through `ssrNoExternal` in each app's `vite.config.ts`, because Node refuses a package's JSON without the attribute. `generatedAvatarClassName(style)` picks the image classes: line-art styles on white (`bg-white`) in both themes, color styles on `bg-muted`. A value's optional background goes to DiceBear as `backgroundColor`; on a dark one (`isDarkBackground`, WCAG contrast) the styles that draw lines straight onto the background (`INK_OPTIONS`) get white ink. The app `Avatar` wrappers turn a stored value into `src` with `avatarSrc` (`@carbon/utils`); new users get a Croodles Neutral avatar from the column default+- **Avatar**: `src` may be a URL or a generated-avatar value from `user.avatarUrl` (`dicebear:<style>:<seed>[:<rrggbb>]`; the styles and value helpers are in `@carbon/utils` `avatar.ts`). A generated value renders as a plain `<img>` of `generatedAvatarUrl(value)` (`utils/generatedAvatarImage.ts`, which `Avatar` imports instead of the renderer so no bundle that shows an avatar carries DiceBear) — `/file/avatar/:value?v=<GENERATED_AVATAR_RENDER_VERSION>` — so it is in the server-rendered HTML and needs no client JavaScript. Every app (ERP, MES, academy) serves that path with a one-line route re-exporting `generatedAvatarLoader` from `@carbon/react/GeneratedAvatar`: it draws the SVG on the server with DiceBear 10 and answers `Cache-Control: public, max-age=31536000, immutable`, so a refresh reads it from the browser cache. **Bump `GENERATED_AVATAR_RENDER_VERSION` whenever the same value would draw differently** (a DiceBear upgrade, a change to the rendering options), or browsers keep the old image. The avatar picker draws in the browser instead (`GeneratedAvatarPreview`, `useGeneratedAvatar`), because a color drag makes a new value per step; there the DiceBear core and each style's JSON load with `import()` (`STYLE_LOADERS`, typed `Record<GeneratedAvatarStyle, …>`), never with a `with: { type: "json" }` attribute (Vite passes it to the browser, which rejects the JSON Vite serves as JavaScript, and the picker stays grey); the server side instead bundles `@dicebear/styles` through `ssrNoExternal` in each app's `vite.config.ts`, because Node refuses a package's JSON without the attribute. `generatedAvatarClassName(style)` picks the image classes: line-art styles on white (`bg-white`) in both themes, color styles on `bg-muted`. A value's optional background goes to DiceBear as `backgroundColor`; on a dark one (`isDarkBackground`, WCAG contrast) the styles that draw lines straight onto the background (`INK_OPTIONS`) get white ink. The app `Avatar` wrappers turn a stored value into `src` with `avatarSrc` (`@carbon/utils`); a new user has no avatar (initials) until they choose one- **Polish**: shadows over borders, `tabular-nums` for dynamic numbers, `active:scale-[0.98]` on pressables, `text-balance`/`text-pretty` for text wrapping## Cross-Referencesdiff --git a/packages/utils/src/avatar.test.ts b/packages/utils/src/avatar.test.tsindex 446bec3dcb..3111535c98 100644--- a/packages/utils/src/avatar.test.ts+++ b/packages/utils/src/avatar.test.ts@@ -71,8 +71,9 @@ describe("generated avatars", () => {expect(first).not.toBe(second);});- it("accepts the format the column default writes", () => {- // 'dicebear:croodles-neutral:' || gen_random_uuid()::text+ it("accepts values with a UUID seed", () => {+ // The format a draft column default wrote during development; rows+ // created then still hold it.expect(isGeneratedAvatar("dicebear:croodles-neutral:3f2b8c4e-6a1d-4f7e-9b2c-5d8e1a0f7c63"diff --git a/packages/utils/src/avatar.ts b/packages/utils/src/avatar.tsindex b49cadfef6..74928e51d8 100644--- a/packages/utils/src/avatar.ts+++ b/packages/utils/src/avatar.ts@@ -6,9 +6,9 @@* `user.avatarUrl` holds either a path in the public `avatars` bucket (an* uploaded photo) or a generated-avatar value: `dicebear:<style>:<seed>`, with* an optional `:<rrggbb>` background (none = the style's own). The- * `@carbon/react` Avatar renders a generated value with DiceBear in the- * browser. The column default (migration `20261008113405`) writes the default- * style in the same format, so the two must change together.+ * `@carbon/react` Avatar shows a generated value as an image the app draws on+ * the server (`/file/avatar/:value`). A user only gets one by choosing it on+ * their profile: a new user starts with no avatar and shows their initials.** Every style here needs a loader in `@carbon/react`'s `generatedAvatar.ts`.* Removing a style stops existing values in it from rendering (they fall back@@ -71,7 +71,7 @@ export function normalizeAvatarBackground(/*** Parses `dicebear:<style>:<seed>` or `dicebear:<style>:<seed>:<rrggbb>`. The* background segment is optional, so every value written before it existed- * (and the column default) still parses.+ * still parses.*/export function parseGeneratedAvatar(value: string | null | undefined