Skip to content

fix(styles): repair preset naming, saving and editing in the Styles tab - #311

Merged
hydropix merged 1 commit into
mainfrom
fix/styles-section-regressions
Oct 23, 2026
Merged

hydropix merged 1 commit into
mainfrom
fix/styles-section-regressions

Conversation

@hydropix

Copy link
Copy Markdown
Owner

Summary

Fixes the Styles tab regressions reported against 1.5.15.

  • Non-ASCII names (风格无法编辑 #296). slugify_preset_name kept 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.
  • Hand-renamed files disappeared (Regression and inconvenience regarding the styles section (TBL 1.5.15) #293.1). SAFE_FILENAME_RE rejected spaces, parentheses and accented/CJK letters, so Web Novel (v2).txt was silently skipped by the listing. Those are now accepted. Path separators, Windows-forbidden characters and leading dots or spaces stay rejected, and resolve_inside still guards containment.
  • No way to name a preset, and a second blank style failed (Regression and inconvenience regarding the styles section (TBL 1.5.15) #293.2, Regression and inconvenience regarding the styles section (TBL 1.5.15) #293.3). The editor header now has an editable name field. It names new presets, and on an existing preset PUT accepts name to 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.
  • Legacy .txt presets could not be saved or deleted. Both paths were YAML-only and returned 400. A .txt is now written back in place while it keeps a single text for both phases, and converted to .yaml (the .txt removed) once the phases diverge or metadata is added.
  • Textareas could not be enlarged (Regression and inconvenience regarding the styles section (TBL 1.5.15) #293.4). .form-control's fixed single-line geometry pinned all 7 multi-line fields of the app to 44px. textarea.form-control now sizes from rows and resizes vertically.
  • Export of a non-ASCII preset name now sends an RFC 5987 filename* header.

The feature requests in #293 (txt-only workflow, in-app rename/duplicate) are partly covered: .txt presets keep working and are now editable, rename is new, duplicate already existed.

Test plan

  • New endpoint tests: CJK create, hand-named listing, unchanged-name PUT, rename, rename conflict leaves both files untouched, .txt saved in place, .txt converted to .yaml, .txt delete, non-ASCII export header.
  • Updated is_safe_filename / slugify_preset_name unit tests.
  • Full suite: 2604 passed. The 5 tests/characterization/test_progress_baseline.py failures are the goldens that are already stale on main.
  • Browser, zh-CN UI: created "新建空白风格", second default became "新建空白风格 2", rename conflict showed an error and changed nothing, rename to "武侠 风格" worked, Web Novel (v2).txt listed and saved in place, name placeholder updated on switching to FR without reload.

Fixes #296
Refs #293

🤖 Generated with Claude Code

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>
@hydropix
hydropix merged commit 4105f21 into main Oct 23, 2026
1 check passed
@hydropix hydropix mentioned this pull request Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

风格无法编辑

1 participant