impr: enable spaces in preset names to unify naming logic (@byseif21)#7702
Open
byseif21 wants to merge 10 commits intomonkeytypegame:masterfrom
Open
impr: enable spaces in preset names to unify naming logic (@byseif21)#7702byseif21 wants to merge 10 commits intomonkeytypegame:masterfrom
byseif21 wants to merge 10 commits intomonkeytypegame:masterfrom
Conversation
trim() to clean bad useless whitespaces
Contributor
There was a problem hiding this comment.
Pull request overview
Enables spaces in preset/tag/result-filter preset names by normalizing user input (trim + whitespace → underscores) at the schema level and updating frontend modals to rely on schema parsing while continuing to display names with spaces.
Changes:
- Add whitespace-normalizing transforms to
ResultFiltersSchema.name,TagNameSchema, andPresetNameSchema. - Update tag/preset creation & edit flows to parse/validate via the shared schemas and derive
displayfrom underscore-stored names. - Remove ad-hoc space→underscore replacement in
createFilterPreset.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/schemas/src/users.ts | Normalize ResultFiltersSchema.name + TagNameSchema to allow spaces (stored as _). |
| packages/schemas/src/presets.ts | Normalize PresetNameSchema to allow spaces (stored as _). |
| frontend/src/ts/modals/new-filter-preset.ts | Parse/clean filter preset names via schema before API call. |
| frontend/src/ts/modals/edit-tag.ts | Remove manual cleaning; parse via schema; set display from normalized name. |
| frontend/src/ts/modals/edit-preset.ts | Validate preset names via schema and display space-form names; store underscore-form. |
Comments suppressed due to low confidence (2)
frontend/src/ts/modals/edit-preset.ts:270
- Avoid
PresetNameSchema.safeParse(...).data ?? ""here; it redundantly re-parses and the fallback can silently send an empty name if this code is refactored later. Prefer using the already-validated parsed value from the earliersafeParse(orparse) call.
if (action === "add") {
const configChanges = getConfigChanges();
const activeSettingGroups = getActiveSettingGroupsFromState();
const presetName = PresetNameSchema.safeParse(propPresetName).data ?? "";
const response = await Ape.presets.add({
body: {
name: presetName,
config: configChanges,
frontend/src/ts/modals/edit-preset.ts:307
- Same as the add branch: this re-parses
propPresetNameand falls back to"". Reuse the earlier validated/normalized preset name to avoid duplicate schema work and avoid any possibility of an empty name being sent.
const configChanges = getConfigChanges();
const activeSettingGroups: ConfigGroupName[] | null =
state.presetType === "partial" ? getActiveSettingGroupsFromState() : null;
const presetName = PresetNameSchema.safeParse(propPresetName).data ?? "";
const response = await Ape.presets.save({
body: {
_id: presetId,
name: presetName,
...(updateConfig && {
fehmer
reviewed
Mar 23, 2026
keep name normalization in frontend, restore strict schema validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.