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.
Generated avatars (DiceBear Croodles Neutral) — implementation plan
Spec: .ai/specs/2026-10-08-dicebear-avatars.md Research: N/A — skipped (not ERP-domain logic, clear request) Branch: naveenkash/75pu7
Progress
- Task 1: Add the column default migration
- Task 2: Add the generated-avatar string helpers to
@carbon/utils - Task 3: Render generated avatars in the
@carbon/reactAvatar - Task 4: Pass generated values through the app
Avatarwrappers - Task 5: Stop the invite flows from overwriting the default
- Task 6: Check the avatar value in the profile action
- Task 7: Add the picker and the new Remove behavior to the profile page
- Task 8: Update docs and run the final gates
Dependencies
Task 3 needs Task 2. Task 4 needs Task 2. Task 6 needs Task 2. Task 7 needs Tasks 2, 3 and 6. Tasks 1 and 5 are independent. Task 8 runs last.
Execution notes (autonomous run)
- Do not commit. The user commits by hand.
- Do not apply the migration to the local database. The user applies it.
Task 1: Add the column default migration
Depends on: none Files:
- Create:
packages/database/supabase/migrations/{timestamp}_user-generated-avatar-default.sql
Steps:
- Run
pnpm db:migrate:new user-generated-avatar-default. - Write this SQL into the new file:
-- New users get a random DiceBear Croodles Neutral avatar. The value is -- rendered by @carbon/react Avatar (see packages/utils/src/avatar.ts). -- Existing rows are not changed. ALTER TABLE "user" ALTER COLUMN "avatarUrl" SET DEFAULT 'dicebear:croodles-neutral:' || gen_random_uuid()::text;
Verify:
ls packages/database/supabase/migrations | grep user-generated-avatar-default
# Expected: one file name
Out of scope: applying the migration; a backfill of existing rows.
Task 2: Add the generated-avatar string helpers to @carbon/utils
Depends on: none Files:
- Create:
packages/utils/src/avatar.ts,packages/utils/src/avatar.test.ts - Modify:
packages/utils/src/index.ts— addexport * from "./avatar";
Steps:
- Export
GENERATED_AVATAR_STYLE = "croodles-neutral". - Export
GENERATED_AVATAR_PREFIX = "dicebear:croodles-neutral:". - Export
isGeneratedAvatar(value: string | null | undefined): value is string. It is true when the value starts with the prefix and the seed matches/^[A-Za-z0-9-]{1,64}$/. - Export
parseGeneratedAvatar(value), which returns{ style, seed }ornull. - Export
newGeneratedAvatar(), which returns the prefix pluscrypto.randomUUID(). - Write tests for a valid value, a storage path,
null, an empty seed and a seed with/. - Run the license header fixer.
Verify:
pnpm --filter @carbon/utils exec vitest run src/avatar.test.ts
# Expected: all tests pass
Task 3: Render generated avatars in the @carbon/react Avatar
Depends on: Task 2 Files:
- Modify:
packages/react/package.json— add@dicebear/core9.4.2and@dicebear/croodles-neutral9.4.2todependencies - Create:
packages/react/src/utils/generatedAvatar.ts,packages/react/src/__tests__/generatedAvatar.test.ts - Modify:
packages/react/src/Avatar.tsx
Steps:
- Run
pnpm --filter @carbon/react add @dicebear/[email protected] @dicebear/[email protected]. - In
generatedAvatar.ts, exportgeneratedAvatarDataUri(value: string): string | undefined. - Return
undefinedwhenparseGeneratedAvatar(value)isnull. - Else call
createAvatar(croodlesNeutral, { seed, radius: 0 }).toDataUri(). The SVG has no background. - Cache each result in a module-level
Map, keyed by the value. - In
Avatar.tsx, computeimageSrcwithuseMemo: the data URI for a generated value, elsesrc. - Use
imageSrcfor the<img>. Keep theonErrorfallback. For a line-art avatar, add the classesbg-white border-black/10. For a color style, addbg-muted border-transparent. - Test: the same value gives the same string, the string starts with
data:image/svg+xml, and a storage path givesundefined.
Verify:
pnpm --filter @carbon/react exec vitest run src/__tests__/generatedAvatar.test.ts
# Expected: all tests pass
Out of scope: the @carbon/react barrel (src/index.tsx).
Task 4: Pass generated values through the app Avatar wrappers
Depends on: Task 2 Files:
- Modify:
apps/erp/app/components/Avatar.tsx,apps/mes/app/components/Avatar.tsx,apps/academy/app/components/Avatar.tsx
Steps:
- In each wrapper, if
isGeneratedAvatar(path)is true, passpathassrc. - Else keep the current
getStoragePath(bucket, path)behavior. - In the ERP wrapper, keep
imageUrlfirst.
Verify: Task 8 typechecks.
Task 5: Stop the invite flows from overwriting the default
Depends on: none Files:
- Modify:
apps/erp/app/modules/users/users.server.ts
Steps:
- Change the
createUserparameter toOmit<User, "fullName" | "avatarUrl">. - Change the
insertUserparameter toOmit<User, "fullName" | "createdAt" | "avatarUrl">. - Delete
avatarUrl: nullfrom the 3createUsercalls. - Delete
avatarUrl: nullfrom thecreateConsoleOperatorinsert.
Verify:
grep -n "avatarUrl: null" apps/erp/app/modules/users/users.server.ts
# Expected: no output
Task 6: Check the avatar value in the profile action
Depends on: Task 2 Files:
- Modify:
apps/erp/app/routes/x+/account+/profile.tsx
Steps:
- In the
photointent, readpathfrom the form. - If
isAllowedAvatarValue(userId, path)is false, redirect with the flash "Invalid avatar path". - Read the current value with
getAccount. Log a read error. - Save the new value with
updateAvatar. - If the old value passes
isOwnAvatarUploadand differs from the new one, delete it from theavatarsbucket. - If the delete fails, log it and continue.
- Remove the
nullbranch and the "Removed avatar" message.
Verify: Task 8 typechecks.
Task 7: Add the picker and the new Remove behavior to the profile page
Depends on: Tasks 2, 3, 6 Files:
- Create:
apps/erp/app/modules/account/ui/Profile/GeneratedAvatarPicker.tsx - Modify:
apps/erp/app/modules/account/ui/Profile/ProfilePhotoForm.tsx - Copy from (precedent):
apps/erp/app/modules/users/ui/components/RevokeInviteModal.tsx(Modal shape)
Steps:
- Build
GeneratedAvatarPickerwith propsisOpen,current,onClose,onSave(value). - Keep 12 options in state. The first is
currentwhen it is a generated value. - Shuffle replaces the other 11 with
newGeneratedAvatar()values. - Render each option as a
buttonwith anAvatar(size="lg",src={value}) in a 4-column grid. - Give the selected option a ring. Give each button an
aria-labelandaria-pressed. - Show the credit line with links to the Figma source and CC BY 4.0.
- In
ProfilePhotoForm, add a "Choose avatar" button that opens the picker. - On save, submit the value. The action deletes a replaced upload (Task 6).
- Show Remove only for an uploaded photo. Remove submits
newGeneratedAvatar(). - Show "Change" on the upload button when an uploaded photo exists, else "Upload".
Verify: Task 8 typechecks and lints.
Task 8: Update docs and run the final gates
Depends on: Tasks 1–7 Files:
- Modify:
packages/react/AGENTS.md— one line on generated avatar values
Steps:
- Add the
Avatarnote topackages/react/AGENTS.md. - Run the gates below.
Verify:
pnpm --filter @carbon/checks license-headers
pnpm exec biome check packages/utils/src/avatar.ts packages/utils/src/avatar.test.ts packages/react/src/Avatar.tsx packages/react/src/utils/generatedAvatar.ts packages/react/src/__tests__/generatedAvatar.test.ts apps/erp/app/components/Avatar.tsx apps/mes/app/components/Avatar.tsx apps/academy/app/components/Avatar.tsx apps/erp/app/modules/users/users.server.ts apps/erp/app/routes/x+/account+/profile.tsx apps/erp/app/modules/account/ui/Profile
# Expected: no errors
pnpm exec turbo run typecheck --filter=@carbon/utils --filter=@carbon/react --filter=erp --filter=mes --filter=academy
# Expected: all tasks successful