Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(agents): dress every agent in an office look by default

rubenluetke10-beep4becff724b1f
diff --git a/jarvis/ui/web/frontend/src/components/society/companion/AgentAppearanceDialog.tsx b/jarvis/ui/web/frontend/src/components/society/companion/AgentAppearanceDialog.tsx
index 445e351d78..4c71f42134 100644
--- a/jarvis/ui/web/frontend/src/components/society/companion/AgentAppearanceDialog.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/companion/AgentAppearanceDialog.tsx
@@ -11,6 +11,7 @@ import { AgentSwatch } from "../AgentSwatch";
import { defaultRecipe, EDITABLE_CELLS, resolvePalette, type FigureRecipe } from "../figures/figureRecipe";
import { HAIR_STYLES } from "../office/playerProfile";
import { toyLookFor } from "../office/toyFigureModel";
+import { pinLook, withHair } from "../office/wardrobe";
import { CompanionEditor } from "./CompanionEditor";
import { resolveCompanion } from "./appearance";
@@ -19,20 +20,24 @@ const AgentFigureViewer = lazy(() => import("../figures/AgentFigureViewer").then
/** The toy figure's look: hair or hat, and the six colours it wears. */
function CharacterEditor({ value, onChange, disabled }: { value: FigureRecipe; onChange: (r: FigureRecipe) => void; disabled: boolean }) {
const t = useT();
- const colors = resolvePalette(value);
- const hair = toyLookFor(value, "").hairStyle;
+ // The colours the figure actually wears: an undressed recipe shows its default office outfit.
+ const look = toyLookFor(value, "");
+ const colors = { ...resolvePalette(value), skin: look.skin, hair: look.hair, primary: look.shirt, secondary: look.pants, accent: look.shirtAccent, shoes: look.shoes };
+ const hair = look.hairStyle;
+ // Pin the shown look first, so changing one colour never swaps the whole outfit.
+ const setCell = (cell: string, color: string) => { const pinned = pinLook(value); onChange({ ...pinned, palette: { ...pinned.palette, [cell]: color } }); };
return <fieldset disabled={disabled} className="grid gap-4 p-4" data-testid="character-editor">
<div className="h-60"><Suspense fallback={null}><AgentFigureViewer recipe={value} quiet /></Suspense></div>
<div className="grid gap-2 text-sm">
<span>{t("society.office.hair_label")}</span>
<div className="flex flex-wrap gap-1.5" role="group" aria-label={t("society.office.hair_label")}>
- {HAIR_STYLES.map(style => <button key={style} type="button" aria-pressed={hair === style} onClick={() => onChange({ ...value, hairStyle: style })}
+ {HAIR_STYLES.map(style => <button key={style} type="button" aria-pressed={hair === style} onClick={() => onChange(withHair(value, style))}
className={`rounded-full border px-2.5 py-1 text-xs ${hair === style ? "border-transparent bg-primary text-primary-foreground" : "border-border bg-background text-foreground hover:bg-secondary"}`}>
{t(`society.office.hair_${style}`)}
</button>)}
</div>
</div>
- <div className="grid grid-cols-2 gap-3">{EDITABLE_CELLS.map(cell => <label key={cell} className="flex items-center justify-between gap-2 text-sm">{t(`society.cell.${cell}`)}<input type="color" value={colors[cell]} onChange={e => onChange({ ...value, palette: { ...value.palette, [cell]: e.target.value } })} className="h-8 w-10 rounded border border-border bg-background" /></label>)}</div>
+ <div className="grid grid-cols-2 gap-3">{EDITABLE_CELLS.map(cell => <label key={cell} className="flex items-center justify-between gap-2 text-sm">{t(`society.cell.${cell}`)}<input type="color" value={colors[cell]} onChange={e => setCell(cell, e.target.value)} className="h-8 w-10 rounded border border-border bg-background" /></label>)}</div>
</fieldset>;
}
diff --git a/jarvis/ui/web/frontend/src/components/society/office/WardrobePanel.tsx b/jarvis/ui/web/frontend/src/components/society/office/WardrobePanel.tsx
index af4c15a212..be59e83e49 100644
--- a/jarvis/ui/web/frontend/src/components/society/office/WardrobePanel.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/office/WardrobePanel.tsx
@@ -10,7 +10,7 @@ import { useQueryClient } from "@tanstack/react-query";
import { useT } from "@/i18n";
import type { SocietyAgent } from "../data";
import type { FigureRecipe } from "../figures/figureRecipe";
-import { playerLook, type PlayerProfile } from "./playerProfile";
+import { playerLook, playerRecipe, type PlayerProfile } from "./playerProfile";
import { EYEWEAR, HAIR_STYLES, toyLookFor, type OutfitId } from "./toyFigureModel";
import {
colourwayIndexOf, dressIn, HAIR_COLOURS, OUTFITS, outfitById, randomLook, SKIN_TONES,
@@ -112,8 +112,8 @@ export function WardrobePanel({ profile, onProfile, agents, sample }: {
const people = useMemo(() => dressable(agents), [agents]);
const agent = people.find((a) => a.agentId === target) ?? null;
- const playerRecipe: FigureRecipe = { ...profile.recipe, hairStyle: playerLook(profile).hairStyle };
- const recipe = agent ? drafts[agent.agentId] ?? agent.figure! : playerRecipe;
+ const yours: FigureRecipe = { ...playerRecipe(profile), hairStyle: playerLook(profile).hairStyle };
+ const recipe = agent ? drafts[agent.agentId] ?? agent.figure! : yours;
const dirty = agent ? Boolean(drafts[agent.agentId]) && JSON.stringify(drafts[agent.agentId]) !== JSON.stringify(agent.figure) : false;
const change = (next: FigureRecipe) => {
diff --git a/jarvis/ui/web/frontend/src/components/society/office/outfitCatalog.ts b/jarvis/ui/web/frontend/src/components/society/office/outfitCatalog.ts
new file mode 100644
index 0000000000..385761e323
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/society/office/outfitCatalog.ts
@@ -0,0 +1,92 @@
+/**
+ * The office outfits and their curated colourways, as plain data. Kept free of
+ * runtime imports so both the figure model (default looks) and the wardrobe
+ * (dressing) can read it.
+ */
+import type { OutfitId } from "./toyFigureModel";
+
+export interface Colourway {
+ /** Stable id, also the i18n key suffix (`society.office.colourway_<id>`). */
+ id: string;
+ primary: string;
+ secondary: string;
+ accent: string;
+ inner: string;
+ shoes: string;
+}
+
+export interface Outfit {
+ id: OutfitId;
+ colourways: readonly Colourway[];
+}
+
+/** The office outfits, casual to formal; the first colourway is the signature one. */
+export const OUTFITS: readonly Outfit[] = [
+ {
+ id: "leather",
+ colourways: [
+ { id: "black", primary: "#131316", secondary: "#1d2029", accent: "#9aa0a8", inner: "#1b1b1e", shoes: "#101012" },
+ { id: "cognac", primary: "#5c3622", secondary: "#2a3346", accent: "#c9a227", inner: "#efe8dc", shoes: "#3b2418" },
+ { id: "oxblood", primary: "#4a1a1f", secondary: "#1d2029", accent: "#9aa0a8", inner: "#1b1b1e", shoes: "#101012" },
+ ],
+ },
+ {
+ id: "suit",
+ colourways: [
+ { id: "charcoal", primary: "#3a3d44", secondary: "#3a3d44", accent: "#8b1e2d", inner: "#f4f4f0", shoes: "#1a1414" },
+ { id: "navy", primary: "#1f2a44", secondary: "#1f2a44", accent: "#c9a227", inner: "#eaf1fb", shoes: "#3b2418" },
+ { id: "tuxedo", primary: "#141418", secondary: "#141418", accent: "#141418", inner: "#ffffff", shoes: "#0d0d0d" },
+ { id: "linen", primary: "#cbb795", secondary: "#cbb795", accent: "#2f4a7a", inner: "#ffffff", shoes: "#6b4226" },
+ ],
+ },
+ {
+ id: "blazer",
+ colourways: [
+ { id: "old_money", primary: "#23304f", secondary: "#dccfb3", accent: "#b8943e", inner: "#f2efe6", shoes: "#6b4226" },
+ { id: "camel", primary: "#b08a5a", secondary: "#3b3f4a", accent: "#f2efe6", inner: "#ffffff", shoes: "#2a1d15" },
+ { id: "forest", primary: "#2f4a3a", secondary: "#e3dccb", accent: "#c9a227", inner: "#f2efe6", shoes: "#4a2e22" },
+ ],
+ },
+ {
+ id: "quarterzip",
+ colourways: [
+ { id: "oat", primary: "#d8cbb4", secondary: "#3b3f4a", accent: "#c7c9cc", inner: "#ffffff", shoes: "#f4f4f2" },
+ { id: "navy", primary: "#1f2a44", secondary: "#c8b28e", accent: "#c7c9cc", inner: "#cfe0f5", shoes: "#3b2418" },
+ { id: "forest", primary: "#2f4a3a", secondary: "#e3dccb", accent: "#c7c9cc", inner: "#ffffff", shoes: "#f4f4f2" },
+ ],
+ },
+ {
+ id: "vest",
+ colourways: [
+ { id: "navy", primary: "#1f2a44", secondary: "#b9a27f", accent: "#e5674f", inner: "#cfe0f5", shoes: "#3b2418" },
+ { id: "charcoal", primary: "#3b3f4a", secondary: "#2b2f38", accent: "#6fbf5a", inner: "#ffffff", shoes: "#f4f4f2" },
+ { id: "black", primary: "#18181c", secondary: "#c8b28e", accent: "#f2c14e", inner: "#eaf1fb", shoes: "#2a1d15" },
+ ],
+ },
+ {
+ id: "turtleneck",
+ colourways: [
+ { id: "black", primary: "#141416", secondary: "#3d5a80", accent: "#141416", inner: "#141416", shoes: "#9a9aa0" },
+ { id: "camel", primary: "#b08a5a", secondary: "#2b2b33", accent: "#b08a5a", inner: "#b08a5a", shoes: "#3b2418" },
+ { id: "cream", primary: "#eee6d6", secondary: "#3b3f4a", accent: "#eee6d6", inner: "#eee6d6", shoes: "#2a1d15" },
+ ],
+ },
+ {
+ id: "hoodie",
+ colourways: [
+ { id: "grey", primary: "#8a8d93", secondary: "#2b2f38", accent: "#f2f2ee", inner: "#f2f2ee", shoes: "#f4f4f2" },
+ { id: "black", primary: "#1c1c20", secondary: "#1c1c20", accent: "#d9d9d9", inner: "#1c1c20", shoes: "#f4f4f2" },
+ { id: "navy", primary: "#23304f", secondary: "#8a8d93", accent: "#f2f2ee", inner: "#23304f", shoes: "#f4f4f2" },
+ { id: "sage", primary: "#8fa58a", secondary: "#e3dccb", accent: "#f2f2ee", inner: "#8fa58a", shoes: "#f4f4f2" },
+ ],
+ },
+ {
+ id: "tee",
+ colourways: [
+ { id: "white", primary: "#f2f2ee", secondary: "#3d5a80", accent: "#2b2b33", inner: "#f2f2ee", shoes: "#f4f4f2" },
+ { id: "black", primary: "#1c1c20", secondary: "#2b2f38", accent: "#f2f2ee", inner: "#1c1c20", shoes: "#f4f4f2" },
+ { id: "green", primary: "#3f9d5a", secondary: "#2b4a8b", accent: "#f2c14e", inner: "#3f9d5a", shoes: "#f2f2ee" },
+ { id: "coral", primary: "#e5674f", secondary: "#2b2f38", accent: "#f2f2ee", inner: "#e5674f", shoes: "#f4f4f2" },
+ ],
+ },
+];
diff --git a/jarvis/ui/web/frontend/src/components/society/office/playerProfile.ts b/jarvis/ui/web/frontend/src/components/society/office/playerProfile.ts
index a6b5a3fe2e..27bdb8e673 100644
--- a/jarvis/ui/web/frontend/src/components/society/office/playerProfile.ts
+++ b/jarvis/ui/web/frontend/src/components/society/office/playerProfile.ts
@@ -20,10 +20,16 @@ export interface PlayerProfile {
export { HAIR_STYLES };
+/** The person's recipe as the wardrobe edits it: an undressed character wears the T-shirt. */
+export function playerRecipe(profile: PlayerProfile): FigureRecipe {
+ const recipe = { ...profile.recipe, outfit: profile.recipe.outfit ?? "tee" };
+ return profile.hairStyle ? { ...recipe, hairStyle: profile.hairStyle } : recipe;
+}
+
/** The look the office draws for the person. */
export function playerLook(profile: PlayerProfile): ToyLook {
- const look = toyLookFor(profile.recipe, "office-player");
- return profile.hairStyle ? { ...look, hairStyle: profile.hairStyle } : look;
+ // Agents get a default office outfit; the person keeps the T-shirt until they pick one.
+ return toyLookFor(playerRecipe(profile), "office-player");
}
/** Bodies offered in the wardrobe: two-legged, first-party, not reserved. */
diff --git a/jarvis/ui/web/frontend/src/components/society/office/toyFigureModel.test.ts b/jarvis/ui/web/frontend/src/components/society/office/toyFigureModel.test.ts
index 95d8c16161..8df52d0057 100644
--- a/jarvis/ui/web/frontend/src/components/society/office/toyFigureModel.test.ts
+++ b/jarvis/ui/web/frontend/src/components/society/office/toyFigureModel.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, it } from "vitest";
import type { FigureRecipe } from "../figures/figureRecipe";
+import { OUTFITS } from "./outfitCatalog";
import {
blendPose, createPose, isNaturalSkin, KEYBOARD, lowestSoleY, poseFor, SEAT_BACK_CLEARANCE, SEAT_HEIGHT,
TOY_HEIGHT, toyLookFor, toyPoints, type ToyMode,
@@ -112,9 +113,24 @@ describe("toyLookFor", () => {
expect(toyLookFor(null, "agent-7")).toEqual(toyLookFor(null, "agent-7"));
});
- it("uses the recipe colours", () => {
+ it("wears a chosen outfit in the recipe colours", () => {
+ const look = toyLookFor({ ...recipe, outfit: "suit" }, "agent-7");
+ expect(look).toMatchObject({ outfit: "suit", skin: "#d8a37c", hair: "#123456", shirt: "#6fbf5a", pants: "#2f4a7a", shirtAccent: "#f2c14e", shoes: "#ffffff" });
+ });
+
+ it("dresses an undressed recipe in an office outfit and colourway, keeping skin and hair", () => {
const look = toyLookFor(recipe, "agent-7");
- expect(look).toMatchObject({ skin: "#d8a37c", hair: "#123456", shirt: "#6fbf5a", pants: "#2f4a7a", shirtAccent: "#f2c14e", shoes: "#ffffff" });
+ expect(look).toMatchObject({ skin: "#d8a37c", hair: "#123456" });
+ const way = OUTFITS.find((o) => o.id === look.outfit)!.colourways.find((w) => w.primary === look.shirt);
+ expect(way).toMatchObject({ secondary: look.pants, accent: look.shirtAccent, inner: look.inner, shoes: look.shoes });
+ // The same recipe looks the same everywhere, whoever asks.
+ expect(toyLookFor(recipe, "")).toMatchObject({ outfit: look.outfit, shirt: look.shirt });
+ });
+
+ it("gives a crowd of agents varied office outfits", () => {
+ const outfits = new Set(Array.from({ length: 60 }, (_, i) =>
+ toyLookFor({ ...recipe, palette: { ...recipe.palette, primary: `#${(i * 40503).toString(16).padStart(6, "0").slice(-6)}` } }, "").outfit));
+ expect(outfits.size).toBeGreaterThanOrEqual(5);
});
it("keeps skin natural and varies hair styles across identities", () => {
diff --git a/jarvis/ui/web/frontend/src/components/society/office/toyFigureModel.ts b/jarvis/ui/web/frontend/src/components/society/office/toyFigureModel.ts
index 33f8386fb0..6779de9317 100644
--- a/jarvis/ui/web/frontend/src/components/society/office/toyFigureModel.ts
+++ b/jarvis/ui/web/frontend/src/components/society/office/toyFigureModel.ts
@@ -19,6 +19,7 @@
import { recipeKey, type FigureRecipe, type Palette } from "../figures/figureRecipe";
import type { FigureMode } from "../figures/FigureRig";
+import { OUTFITS, type Colourway } from "./outfitCatalog";
// ---------------------------------------------------------------------------
// Look
@@ -130,11 +131,6 @@ function naturalSkinFor(hex: string): string {
return best;
}
-/**
- * The toy look for one agent: colours from the recipe palette (skin, hair,
- * primary → shirt, accent → shirt accent, secondary → trousers, shoes), with a
- * stable hash of `identity` choosing the hair style, blush and any missing colour.
- */
/** Every hair style the figure can draw; the hash wheel above only picks from the original eight. */
export const HAIR_STYLES: readonly HairStyle[] = [
"short", "slick", "sidepart", "buzz", "spiky", "curly", "long", "ponytail", "bun", "beanie", "cap", "bald",
@@ -146,9 +142,21 @@ function chosenHair(recipe: FigureRecipe | null): HairStyle | null {
return typeof value === "string" && (HAIR_STYLES as readonly string[]).includes(value) ? (value as HairStyle) : null;
}
-function chosenOutfit(recipe: FigureRecipe | null): OutfitId {
+function chosenOutfit(recipe: FigureRecipe | null): OutfitId | null {
const value = recipe?.outfit;
- return typeof value === "string" && (OUTFIT_IDS as readonly string[]).includes(value) ? (value as OutfitId) : "tee";
+ return typeof value === "string" && (OUTFIT_IDS as readonly string[]).includes(value) ? (value as OutfitId) : null;
+}
+
+/** Office styles for a figure nobody dressed yet; weighted so a plain T-shirt stays rare. */
+const OFFICE_OUTFIT_WHEEL: readonly OutfitId[] = [
+ "suit", "suit", "blazer", "blazer", "vest", "vest", "quarterzip", "quarterzip", "turtleneck", "leather", "hoodie", "tee",
+];
+
+/** The default office look for an undressed recipe: an outfit and one of its colourways. */
+function officeLook(seed: number): { outfit: OutfitId; way: Colourway } {
+ const outfit = pick(OFFICE_OUTFIT_WHEEL, seed, 0x5e);
+ const ways = OUTFITS.find((o) => o.id === outfit)!.colourways;
+ return { outfit, way: pick(ways, seed, 0x6f) };
}
function chosenEyewear(recipe: FigureRecipe | null): Eyewear {
@@ -160,26 +168,33 @@ function chosenEyewear(recipe: FigureRecipe | null): Eyewear {
const DEFAULT_INNER = "#f2f2ee";
/**
- * The toy look for a stored figure. Hair comes from the recipe itself (its own
- * field, else a hash of the recipe), never from the agent id, so the creator's
- * preview and the office always draw the same person.
+ * The toy look for a stored figure. Hair and the default office outfit come
+ * from the recipe itself (its own fields, else a hash of the recipe), never
+ * from the agent id, so the creator's preview and the office always draw the
+ * same person. A recipe that names an outfit wears it in its palette colours
+ * (primary → garment, accent → tie / trim, secondary → trousers, shoes); one
+ * that names none wears an office outfit in a curated colourway. `identity`
+ * only fills blush and colours a missing recipe leaves open.
*/
export function toyLookFor(recipe: FigureRecipe | null, identity: string): ToyLook {
const hash = hashString(identity || "toy");
const palette: Partial<Palette> = recipe?.palette ?? {};
const rawSkin = validColour(palette.skin);
const skin = rawSkin ? (isNaturalSkin(rawSkin) ? rawSkin : naturalSkinFor(rawSkin)) : pick(SKIN_TONES, hash, 0x51);
+ const seed = recipe ? hashString(recipeKey({ ...recipe, hairStyle: undefined, outfit: undefined, inner: undefined, eyewear: undefined })) : hash;
+ const explicit = chosenOutfit(recipe);
+ const office = explicit ? null : officeLook(seed);
return {
skin,
hair: validColour(palette.hair) ?? pick(HAIR_COLOURS, hash, 0x7a),
- hairStyle: chosenHair(recipe) ?? pick(HAIR_STYLE_WHEEL, recipe ? hashString(recipeKey({ ...recipe, hairStyle: undefined, outfit: undefined, inner: undefined, eyewear: undefined })) : hash, 0x3c),
- shirt: validColour(palette.primary) ?? pick(SHIRT_COLOURS, hash, 0x19),
- shirtAccent: validColour(palette.accent) ?? pick(SHIRT_COLOURS, hash, 0x2d),
- pants: validColour(palette.secondary) ?? pick(PANTS_COLOURS, hash, 0x44),
- inner: validColour(recipe?.inner) ?? DEFAULT_INNER,
- shoes: validColour(palette.shoes) ?? DEFAULT_SHOES,
+ hairStyle: chosenHair(recipe) ?? pick(HAIR_STYLE_WHEEL, seed, 0x3c),
+ shirt: office?.way.primary ?? validColour(palette.primary) ?? pick(SHIRT_COLOURS, hash, 0x19),
+ shirtAccent: office?.way.accent ?? validColour(palette.accent) ?? pick(SHIRT_COLOURS, hash, 0x2d),
+ pants: office?.way.secondary ?? validColour(palette.secondary) ?? pick(PANTS_COLOURS, hash, 0x44),
+ inner: office?.way.inner ?? validColour(recipe?.inner) ?? DEFAULT_INNER,
+ shoes: office?.way.shoes ?? validColour(palette.shoes) ?? DEFAULT_SHOES,
blush: (hash & 0x3) !== 0,
- outfit: chosenOutfit(recipe),
+ outfit: explicit ?? office!.outfit,
eyewear: chosenEyewear(recipe),
};
}
diff --git a/jarvis/ui/web/frontend/src/components/society/office/wardrobe.test.ts b/jarvis/ui/web/frontend/src/components/society/office/wardrobe.test.ts
index d267b3145f..efaa1b0ea7 100644
--- a/jarvis/ui/web/frontend/src/components/society/office/wardrobe.test.ts
+++ b/jarvis/ui/web/frontend/src/components/society/office/wardrobe.test.ts
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
import { recipeKey, type FigureRecipe } from "../figures/figureRecipe";
import { HAIR_STYLES, OUTFIT_IDS, toyLookFor } from "./toyFigureModel";
-import { colourwayIndexOf, dressIn, OUTFITS, randomLook, withEyewear, withHairColour, withSkin } from "./wardrobe";
+import { colourwayIndexOf, dressIn, OUTFITS, pinLook, randomLook, withEyewear, withHair, withHairColour, withSkin } from "./wardrobe";
const BASE: FigureRecipe = { contract: 1, archetype: "biped", base: "toon", parts: {}, palette: { primary: "#3f9d5a", secondary: "#2b4a8b" } };
const HEX = /^#[0-9a-f]{6}$/i;
@@ -41,7 +41,17 @@ describe("dressing a recipe", () => {
it("reads eyewear and falls back safely on unknown values", () => {
expect(toyLookFor(withEyewear(BASE, "shades"), "").eyewear).toBe("shades");
- expect(toyLookFor({ ...BASE, eyewear: "monocle", outfit: "cape" }, "")).toMatchObject({ eyewear: "none", outfit: "tee" });
+ const unknown = toyLookFor({ ...BASE, eyewear: "monocle", outfit: "cape" }, "");
+ expect(unknown.eyewear).toBe("none");
+ expect(unknown.outfit).toBe(toyLookFor(BASE, "").outfit);
+ });
+
+ it("keeps an undressed agent's default outfit when only skin, hair or glasses change", () => {
+ const before = toyLookFor(BASE, "");
+ for (const edited of [withSkin(BASE, "#6b4430"), withHairColour(BASE, "#c0392b"), withHair(BASE, "buzz"), withEyewear(BASE, "glasses")]) {
+ expect(toyLookFor(edited, "")).toMatchObject({ outfit: before.outfit, shirt: before.shirt, pants: before.pants, inner: before.inner });
+ }
+ expect(pinLook(BASE).outfit).toBe(before.outfit);
});
it("produces complete random looks from the catalogue", () => {
diff --git a/jarvis/ui/web/frontend/src/components/society/office/wardrobe.ts b/jarvis/ui/web/frontend/src/components/society/office/wardrobe.ts
index 6c1e227874..47a8e738e5 100644
--- a/jarvis/ui/web/frontend/src/components/society/office/wardrobe.ts
+++ b/jarvis/ui/web/frontend/src/components/society/office/wardrobe.ts
@@ -8,93 +8,11 @@
* the creator preview and the appearance editor.
*/
import type { FigureRecipe } from "../figures/figureRecipe";
+import { OUTFITS, type Outfit } from "./outfitCatalog";
import { hashString, SKIN_TONES, toyLookFor, type Eyewear, type HairStyle, type OutfitId } from "./toyFigureModel";
-export interface Colourway {
- /** Stable id, also the i18n key suffix (`society.office.colourway_<id>`). */
- id: string;
- primary: string;
- secondary: string;
- accent: string;
- inner: string;
- shoes: string;
-}
-
-export interface Outfit {
- id: OutfitId;
- colourways: readonly Colourway[];
-}
-
-/** The office outfits, casual to formal; the first colourway is the signature one. */
-export const OUTFITS: readonly Outfit[] = [
- {
- id: "leather",
- colourways: [
- { id: "black", primary: "#131316", secondary: "#1d2029", accent: "#9aa0a8", inner: "#1b1b1e", shoes: "#101012" },
- { id: "cognac", primary: "#5c3622", secondary: "#2a3346", accent: "#c9a227", inner: "#efe8dc", shoes: "#3b2418" },
- { id: "oxblood", primary: "#4a1a1f", secondary: "#1d2029", accent: "#9aa0a8", inner: "#1b1b1e", shoes: "#101012" },
- ],
- },
- {
- id: "suit",
- colourways: [
- { id: "charcoal", primary: "#3a3d44", secondary: "#3a3d44", accent: "#8b1e2d", inner: "#f4f4f0", shoes: "#1a1414" },
- { id: "navy", primary: "#1f2a44", secondary: "#1f2a44", accent: "#c9a227", inner: "#eaf1fb", shoes: "#3b2418" },
- { id: "tuxedo", primary: "#141418", secondary: "#141418", accent: "#141418", inner: "#ffffff", shoes: "#0d0d0d" },
- { id: "linen", primary: "#cbb795", secondary: "#cbb795", accent: "#2f4a7a", inner: "#ffffff", shoes: "#6b4226" },
- ],
- },
- {
- id: "blazer",
- colourways: [
- { id: "old_money", primary: "#23304f", secondary: "#dccfb3", accent: "#b8943e", inner: "#f2efe6", shoes: "#6b4226" },
- { id: "camel", primary: "#b08a5a", secondary: "#3b3f4a", accent: "#f2efe6", inner: "#ffffff", shoes: "#2a1d15" },
- { id: "forest", primary: "#2f4a3a", secondary: "#e3dccb", accent: "#c9a227", inner: "#f2efe6", shoes: "#4a2e22" },
- ],
- },
- {
- id: "quarterzip",
- colourways: [
- { id: "oat", primary: "#d8cbb4", secondary: "#3b3f4a", accent: "#c7c9cc", inner: "#ffffff", shoes: "#f4f4f2" },
- { id: "navy", primary: "#1f2a44", secondary: "#c8b28e", accent: "#c7c9cc", inner: "#cfe0f5", shoes: "#3b2418" },
- { id: "forest", primary: "#2f4a3a", secondary: "#e3dccb", accent: "#c7c9cc", inner: "#ffffff", shoes: "#f4f4f2" },
- ],
- },
- {
- id: "vest",
- colourways: [
- { id: "navy", primary: "#1f2a44", secondary: "#b9a27f", accent: "#e5674f", inner: "#cfe0f5", shoes: "#3b2418" },
- { id: "charcoal", primary: "#3b3f4a", secondary: "#2b2f38", accent: "#6fbf5a", inner: "#ffffff", shoes: "#f4f4f2" },
- { id: "black", primary: "#18181c", secondary: "#c8b28e", accent: "#f2c14e", inner: "#eaf1fb", shoes: "#2a1d15" },
- ],
- },
- {
- id: "turtleneck",
- colourways: [
- { id: "black", primary: "#141416", secondary: "#3d5a80", accent: "#141416", inner: "#141416", shoes: "#9a9aa0" },
- { id: "camel", primary: "#b08a5a", secondary: "#2b2b33", accent: "#b08a5a", inner: "#b08a5a", shoes: "#3b2418" },
- { id: "cream", primary: "#eee6d6", secondary: "#3b3f4a", accent: "#eee6d6", inner: "#eee6d6", shoes: "#2a1d15" },
- ],
- },
- {
- id: "hoodie",
- colourways: [
- { id: "grey", primary: "#8a8d93", secondary: "#2b2f38", accent: "#f2f2ee", inner: "#f2f2ee", shoes: "#f4f4f2" },
- { id: "black", primary: "#1c1c20", secondary: "#1c1c20", accent: "#d9d9d9", inner: "#1c1c20", shoes: "#f4f4f2" },
- { id: "navy", primary: "#23304f", secondary: "#8a8d93", accent: "#f2f2ee", inner: "#23304f", shoes: "#f4f4f2" },
- { id: "sage", primary: "#8fa58a", secondary: "#e3dccb", accent: "#f2f2ee", inner: "#8fa58a", shoes: "#f4f4f2" },
- ],
- },
- {
- id: "tee",
- colourways: [
- { id: "white", primary: "#f2f2ee", secondary: "#3d5a80", accent: "#2b2b33", inner: "#f2f2ee", shoes: "#f4f4f2" },
- { id: "black", primary: "#1c1c20", secondary: "#2b2f38", accent: "#f2f2ee", inner: "#1c1c20", shoes: "#f4f4f2" },
- { id: "green", primary: "#3f9d5a", secondary: "#2b4a8b", accent: "#f2c14e", inner: "#3f9d5a", shoes: "#f2f2ee" },
- { id: "coral", primary: "#e5674f", secondary: "#2b2f38", accent: "#f2f2ee", inner: "#e5674f", shoes: "#f4f4f2" },
- ],
- },
-];
+export { OUTFITS };
+export type { Colourway, Outfit } from "./outfitCatalog";
export const HAIR_COLOURS = ["#1d1d24", "#2a1d15", "#4a3020", "#6b4226", "#9e5d47", "#c0392b", "#d9b36c", "#e8dcc0", "#8a8d93", "#d6d6d6"] as const;
@@ -131,16 +49,37 @@ export function colourwayIndexOf(recipe: FigureRecipe): number {
&& same(w.inner, look.inner) && same(w.shoes, look.shoes));
}
+/**
+ * Write the look a recipe currently shows into its own fields (outfit,
+ * colours, hair), so a later edit changes only what was edited. Without this
+ * an undressed recipe's default office outfit — derived from the palette —
+ * would change the moment someone picks a new skin tone.
+ */
+export function pinLook(recipe: FigureRecipe): FigureRecipe {
+ const look = toyLookFor(recipe, "");
+ if (recipe.outfit === look.outfit) return { ...recipe, hairStyle: look.hairStyle };
+ return {
+ ...recipe,
+ outfit: look.outfit,
+ inner: look.inner,
+ hairStyle: look.hairStyle,
+ palette: { ...recipe.palette, primary: look.shirt, secondary: look.pants, accent: look.shirtAccent, shoes: look.shoes },
+ };
+}
+
+// Hair style and eyewear do not feed the default outfit's hash, so they need no pinning.
export function withHair(recipe: FigureRecipe, hairStyle: HairStyle): FigureRecipe {
return { ...recipe, hairStyle };
}
export function withHairColour(recipe: FigureRecipe, hair: string): FigureRecipe {
- return { ...recipe, hairStyle: toyLookFor(recipe, "").hairStyle, palette: { ...recipe.palette, hair } };
+ const pinned = pinLook(recipe);
+ return { ...pinned, palette: { ...pinned.palette, hair } };
}
export function withSkin(recipe: FigureRecipe, skin: string): FigureRecipe {
- return { ...recipe, hairStyle: toyLookFor(recipe, "").hairStyle, palette: { ...recipe.palette, skin } };
+ const pinned = pinLook(recipe);
+ return { ...pinned, palette: { ...pinned.palette, skin } };
}
export function withEyewear(recipe: FigureRecipe, eyewear: Eyewear): FigureRecipe {