Repository navigation
fix(styles): repair preset naming, saving and editing in the Styles tab - #311
Merged
Merged
Conversation
Fixes several regressions in the Styles tab introduced with the YAML
preset editor (1.5.15):
- slugify_preset_name kept only ASCII, so the localized default name of
a new style ("新建空白风格" in zh-CN, same for ja/ko) slugified to empty
and every save failed with "Preset name cannot be empty".
- SAFE_FILENAME_RE rejected spaces, parentheses and non-ASCII letters, so
a preset renamed by hand ("Web Novel (v2).txt") silently vanished from
the list. Letters/digits of any script, spaces and parentheses are now
accepted; path separators, Windows-forbidden characters and leading
dots stay rejected, and resolve_inside still guards containment.
- The editor had no way to name a preset, and the default-name check
compared display names with file stems, so a second blank style hit a
409. The name is now an editable field: it names new presets and
renames existing ones (PUT accepts 'name'). Taking an existing name
asks for confirmation on create and returns 409 on rename, so no
preset is ever overwritten silently.
- Saving or deleting a legacy .txt preset failed with a 400 because the
write/delete paths were YAML-only. A .txt is now saved in place while
it keeps one text for both phases, and converted to .yaml otherwise.
- .form-control's fixed single-line geometry pinned every textarea to
44px with no way to enlarge it. Textareas now size from rows and can
be resized vertically.
- Export of a non-ASCII preset name now uses an RFC 5987 filename*.
Fixes #296
Refs #293
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closed
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.
Summary
Fixes the Styles tab regressions reported against 1.5.15.
slugify_preset_namekept only[A-Za-z0-9_-], so the localized default name of a new style (新建空白风格in zh-CN, likewise ja/ko) slugified to empty and every save failed with "Preset name cannot be empty". Letters and digits of any script are now kept.SAFE_FILENAME_RErejected spaces, parentheses and accented/CJK letters, soWeb Novel (v2).txtwas silently skipped by the listing. Those are now accepted. Path separators, Windows-forbidden characters and leading dots or spaces stay rejected, andresolve_insidestill guards containment.PUTacceptsnameto rename it (the assignment follows if the preset was assigned). The default-name check now compares slugs instead of display names against file stems, which is what made a second "New blank style" hit a 409. Taking an existing name asks for confirmation on create and returns 409 on rename, so a preset is never overwritten silently..txtpresets could not be saved or deleted. Both paths were YAML-only and returned 400. A.txtis now written back in place while it keeps a single text for both phases, and converted to.yaml(the.txtremoved) once the phases diverge or metadata is added..form-control's fixed single-line geometry pinned all 7 multi-line fields of the app to 44px.textarea.form-controlnow sizes fromrowsand resizes vertically.filename*header.The feature requests in #293 (txt-only workflow, in-app rename/duplicate) are partly covered:
.txtpresets keep working and are now editable, rename is new, duplicate already existed.Test plan
.txtsaved in place,.txtconverted to.yaml,.txtdelete, non-ASCII export header.is_safe_filename/slugify_preset_nameunit tests.tests/characterization/test_progress_baseline.pyfailures are the goldens that are already stale onmain.Web Novel (v2).txtlisted and saved in place, name placeholder updated on switching to FR without reload.Fixes #296
Refs #293
🤖 Generated with Claude Code