Add portrait settings support to school creation and update related API and UI components. Enhance error handling for invalid presets and ensure proper cloning of settings. Update tests to validate new functionality.
ci / server (push) Failing after 3m40s
ci / client (push) Failing after 14s

This commit is contained in:
Leonid Pershin
2026-08-20 08:17:58 +03:00
parent db95de0ddf
commit 9d96108516
20 changed files with 293 additions and 40 deletions
+13 -6
View File
@@ -164,7 +164,8 @@ Body:
"map": null,
"countryId": "Russia",
"nativeLanguage": null,
"seed": null
"seed": null,
"portraitSettings": null
}
```
@@ -178,6 +179,10 @@ the same catalog. Omit `map` (or send `null`) to use that pack set's default lay
one from the school seed. An id that is not in the country returns `400` `unknown-native-language`.
`seed` is an optional integer. Send it to reproduce a known school; omit it (or send `null`) and
the server rolls one. Existing saves keep the seed already stored in the people file.
`portraitSettings` is the SwarmUI preset file for **this** school (same shape as
`GET /api/settings/swarmui`). Omit it (or send `null`) to copy the server template at create.
Invalid presets return `400` `invalid-portrait-settings`. Generation later uses this copy, not
the global file, so a guest watching the school draws with the same model.
| Status | Meaning |
| --- | --- |
@@ -191,6 +196,7 @@ the server rolls one. Existing saves keep the seed already stored in the people
| `400` `invalid-catalog` | The selected packs could not be loaded. |
| `400` `unknown-country` | `countryId` is not a placeable `CountryDef` in those packs. |
| `400` `unknown-native-language` | `nativeLanguage` is not in that country's `nativeLanguages`. |
| `400` `invalid-portrait-settings` | `portraitSettings` failed validation (empty presets, bad age rule, out of range). |
| `409` `school-limit-reached` | `maxSchools` schools already exist. |
Failures are RFC 7807 problem details with an extra `code` field — that is what the UI switches on.
@@ -470,14 +476,15 @@ so the client can disable generate buttons and show reachability without trying
### `GET /api/settings/swarmui`
Returns the editable SwarmUI preset file (`swarmui.json`): named presets (model, steps, sampler,
LoRA lists, per-kind sizes/prompts), `activePresetId` and `ageRules` mapping age bands to presets.
Portrait generation resolves the preset from the person's age before building the prompt.
Returns the **default** SwarmUI preset template (`swarmui.json`): named presets (model, steps,
sampler, LoRA lists, per-kind sizes/prompts), `activePresetId` and `ageRules`. A new school copies
this into its save as `portraitSettings`. Living schools generate from that copy, not from this
file.
### `PUT /api/settings/swarmui`
Replaces the preset file after validation. Invalid preset ids, age rules or numeric ranges return
`400` `invalid-body`. Changes apply immediately to new portrait generations.
Replaces the default template after validation. Invalid preset ids, age rules or numeric ranges
return `400` `invalid-body`. Already-created schools keep the copy they were created with.
### `GET /api/settings/swarmui/discovery`