Skip to content

fix: 不再强制填写后端会自动补齐的 Profile 名称 - #8

Merged
Paulkm2006 merged 1 commit into
refactor/walisfrom
fix/optional-profile-label
Aug 4, 2026
Merged

fix: 不再强制填写后端会自动补齐的 Profile 名称#8
Paulkm2006 merged 1 commit into
refactor/walisfrom
fix/optional-profile-label

Conversation

@yujiezhang-ops

Copy link
Copy Markdown
Collaborator

Closes #7

改动

ProfilesPage 的名称输入去掉 requiredcanSave 门禁去掉 label 条件。

后端 Store.Save 本来就把 label 当可选:留空则沿用已存的 label,再退到 Profile ID(internal/profile/write.go:71-74)。前端却拦着不让保存,导致「把某个 Profile 的名字清空」这个操作根本做不到——尽管真正走到写入会成功。

补了一行提示说明留空的后果,否则用户保存后看到名字变成了 ID,会以为是丢了数据。

未改动的部分

model 保留 required。它在后端没有 fallback,空值直接被拒(write.go:50-53),放开会把前端拦截变成后端报错,体验更差。

ProvidersPage 的三个必填项(id / name / base_url)全部保留。核对后确认它们在 internal/provider/store.go:208-216 是真必填,放开会导致写入失败——那是回归而非改进。#7 里有完整的逐字段核对表。

验证

  • 前端 119 个测试通过,tsc --noEmit 与生产构建通过
  • go test ./internal/profile/... 通过
  • 新增两个测试:名称留空可保存、缺 model 仍然拦住

后端的 label fallback 已有测试覆盖(internal/profile/write_test.go:205),没有重复添加。

🤖 Generated with Claude Code

The label input was marked required and canSave demanded it, but the write
path treats it as optional: an empty label falls back to the existing one,
then to the Profile ID (internal/profile/write.go:71-74). Editing a Profile
to clear its name was therefore impossible even though saving it would have
worked.

The hint spells the fallback out, otherwise a Profile saved without a name
looks like it lost one.

model keeps its required attribute: Store.Save has no fallback for it and
rejects an empty value outright (write.go:50-53).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Paulkm2006
Paulkm2006 merged commit eea760c into refactor/walis Aug 4, 2026
@Paulkm2006
Paulkm2006 deleted the fix/optional-profile-label branch August 5, 2026 10:04
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.

fix: 配置表单里前端比后端更严的必填项

2 participants