Skip to content

Commit aeced5b

Browse files
committed
Add informalNameStyle flag.
1 parent b68f49b commit aeced5b

7 files changed

Lines changed: 53 additions & 4 deletions

File tree

docs/assets/api/schemas.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,6 +1450,10 @@
14501450
"type": "string"
14511451
}
14521452
]
1453+
},
1454+
"informalNameStyle": {
1455+
"default": false,
1456+
"type": "boolean"
14531457
}
14541458
}
14551459
},

frontend/src/components/stages/profile_stage_editor.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import '../../pair-components/textarea';
2+
import '@material/web/checkbox/checkbox.js';
23
import '@material/web/radio/radio';
34

45
import {MobxLitElement} from '@adobe/lit-mobx';
@@ -95,6 +96,29 @@ export class ProfileStageEditorComponent extends MobxLitElement {
9596
></md-radio>
9697
<label>🐱 Generate anonymous animal-themed profiles</label>
9798
</div>
99+
${this.stage.profileType === ProfileType.ANONYMOUS_ANIMAL
100+
? html`
101+
<label class="checkbox-wrapper">
102+
<md-checkbox
103+
touch-target="wrapper"
104+
?checked=${this.stage.informalNameStyle}
105+
?disabled=${!this.experimentEditor.canEditStages}
106+
@click=${() => {
107+
if (!this.stage) return;
108+
this.experimentEditor.updateStage({
109+
...this.stage,
110+
informalNameStyle: !this.stage.informalNameStyle,
111+
});
112+
}}
113+
>
114+
</md-checkbox>
115+
<span
116+
>Use informal name style (e.g., bear123 instead of Bear
117+
1002)</span
118+
>
119+
</label>
120+
`
121+
: nothing}
98122
<div class="profile-option">
99123
<md-radio
100124
name="profile-type"

functions/src/participant.endpoints.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,15 @@ export const createParticipant = onCall(async (request) => {
140140
) as ProfileStageConfig | undefined;
141141
const profileType =
142142
profileStage?.profileType || ProfileType.ANONYMOUS_ANIMAL;
143-
144-
setProfile(numParticipants, participantConfig, true, profileType);
143+
const informalNameStyle = profileStage?.informalNameStyle ?? false;
144+
145+
setProfile(
146+
numParticipants,
147+
participantConfig,
148+
true,
149+
profileType,
150+
informalNameStyle,
151+
);
145152
} else {
146153
setProfile(numParticipants, participantConfig, false);
147154
}

scripts/deliberate_lab/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ class ProfileStageConfig(BaseModel):
391391
descriptions: StageTextConfig
392392
progress: StageProgressConfig
393393
profileType: ProfileType
394+
informalNameStyle: bool | None = False
394395

395396

396397
class Strategy(StrEnum):

utils/src/participant.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,17 +191,27 @@ export function setProfile(
191191
config: ParticipantProfileExtended,
192192
setAnonymousProfile = false,
193193
profileType: ProfileType = ProfileType.ANONYMOUS_ANIMAL,
194+
informalNameStyle = false,
194195
) {
195196
const randomNumber = Math.floor(Math.random() * 10000);
196197

198+
// Format name with random number.
199+
// Informal style: "bear123" (lowercase, no space)
200+
// Default style: "Bear 1002"
201+
const formatName = (name: string) => {
202+
if (informalNameStyle) {
203+
return `${name.toLowerCase()}${randomNumber}`;
204+
}
205+
return `${name} ${randomNumber}`;
206+
};
207+
197208
// Create anonymous profile from a named profile set.
198-
// Appends random number to name (e.g., "Bear 1002", "Participant 1002").
199209
const profileFromSet = (
200210
profileSet: {name: string; avatar: string}[],
201211
): AnonymousProfileMetadata => {
202212
const {name, avatar} = profileSet[participantNumber % profileSet.length];
203213
return {
204-
name: `${name} ${randomNumber}`,
214+
name: formatName(name),
205215
avatar,
206216
repeat: Math.floor(participantNumber / profileSet.length),
207217
};

utils/src/stages/profile_stage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export enum ProfileType {
2222
export interface ProfileStageConfig extends BaseStageConfig {
2323
kind: StageKind.PROFILE;
2424
profileType: ProfileType;
25+
informalNameStyle?: boolean; // e.g., "bear123" instead of "Bear 1002"
2526
}
2627

2728
// ************************************************************************* //
@@ -39,5 +40,6 @@ export function createProfileStage(
3940
descriptions: config.descriptions ?? createStageTextConfig(),
4041
progress: config.progress ?? createStageProgressConfig(),
4142
profileType: config.profileType ?? ProfileType.DEFAULT,
43+
informalNameStyle: config.informalNameStyle ?? false,
4244
};
4345
}

utils/src/stages/profile_stage.validation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const ProfileStageConfigData = Type.Composite(
2323
Type.Literal(ProfileType.ANONYMOUS_ANIMAL),
2424
Type.Literal(ProfileType.ANONYMOUS_PARTICIPANT),
2525
]),
26+
informalNameStyle: Type.Optional(Type.Boolean({default: false})),
2627
},
2728
strict,
2829
),

0 commit comments

Comments
 (0)