Skip to content

fix: custom setting of default failed caused by default.custom.yaml nonexistence#1126

Merged
lotem merged 2 commits intorime:masterfrom
fxliang:fix_default_custom
Jan 18, 2026
Merged

fix: custom setting of default failed caused by default.custom.yaml nonexistence#1126
lotem merged 2 commits intorime:masterfrom
fxliang:fix_default_custom

Conversation

@fxliang
Copy link
Contributor

@fxliang fxliang commented Jan 17, 2026

Pull request

Issue tracker

Fixes will automatically close the related issue

Fixes #
fix: custom setting of default failed caused by default.custom.yaml nonexistence

Feature

Describe feature of pull request

Unit test

  • Done

Manual test

  • Done

Code Review

  1. Unit and manual test pass
  2. GitHub Action CI pass
  3. At least one contributor reviews and votes
  4. Can be merged clean without conflicts
  5. PR will be merged by rebase upstream base

Additional Info

@fxliang fxliang requested a review from a team January 17, 2026 01:49
@fxliang fxliang force-pushed the fix_default_custom branch from 48d331f to 43947f1 Compare January 17, 2026 03:03
@fxliang fxliang force-pushed the fix_default_custom branch from 43947f1 to 3eb7d2e Compare January 17, 2026 04:30
@lotem
Copy link
Member

lotem commented Jan 18, 2026

詳細講講……

得弄懂小狼毫是怎麼用的

@fxliang
Copy link
Contributor Author

fxliang commented Jan 18, 2026

詳細講講……

得弄懂小狼毫是怎麼用的

小狼毫之前是 自行保证用户目录一定有default.custom.yaml来避开这个坑
https://github.com/rime/weasel/blob/master/WeaselDeployer/Configurator.cpp#L20-L33
然后如果没有default.custom.yaml应该是会让
https://github.com/rime/weasel/blob/master/WeaselDeployer/Configurator.cpp#L85-L114
这里的skip可能为true,从而就没有办法弹出WeaselDeployer的对话框(当然弹出了也没有方案显示)

@lotem
Copy link
Member

lotem commented Jan 18, 2026

小狼毫之前是

這代碼好爛!能不能給他改正。

@fxliang
Copy link
Contributor Author

fxliang commented Jan 18, 2026

小狼毫之前是

這代碼好爛!能不能給他改正。

好吧

@lotem
Copy link
Member

lotem commented Jan 18, 2026

我感到很矛盾。

CustomSettings::Load 返回值究竟應該是什麼含義?

首先他檢查原始文件配置編譯結果文件,即使目標配置的原始版本不存在,也不認爲是錯誤——也就是說允許通過打補丁創建一個新的配置文件?
因爲 CustomSettings 的重點是操作補丁文件 *.custom.yaml,所以原始文件不是必須的。

這個返回值,看起來作用就是返回有沒有加載到補丁文件,不然就一律返回 true 了。

到這一步,也就理解了,用戶應該處理 Load 返回 false 也就是不存在補丁文件的情況。小狼毫沒有認真做。

而 SwitcherSettings 呢,他既然是 CustomSettings 的子類,SwitcherSettings::Load 的語義也應該是打過補丁返回 true,沒打過補丁返回 false,才叫繼承了父的特徵,才是合法繼承人。你說是不是這個理?

分析到這裏我覺得用家,也就是 weasel/WeaselDeployer/Configurator.cpp:configure_switcher 很有問題。

@fxliang
Copy link
Contributor Author

fxliang commented Jan 18, 2026

分析到這裏我覺得用家,也就是 weasel/WeaselDeployer/Configurator.cpp:configure_switcher 很有問題。

这段我也不知道是谁写的

load_settings来判断一个custom.yaml是不是存在,因此前端应该检测不存在的时候创建一个?

但是换一个角度思考是,其他的CustomSettings是可以不依赖这个返回值依然正常工作可以继续定义内容,但是SwitcherSettings这个是返回false之后就后面有获取可用方案列表和已选方案列表的API跪了。要不然就是那两个API写得不行要修

@lotem
Copy link
Member

lotem commented Jan 18, 2026

那這個 SwitcherSettings::Load 邏輯也有問題,那些 Get* 也應該調,

上一條回覆我說錯了啊,不是加載原始文件而是編譯結果文件也就是已經生效的配置,(這裏的風險:如果此前部署失敗呢?staging 版本已過時?先忽略吧)

Get* 是對 config_ 的進一步提煉。因此無論 custom_config_ 加載到沒有,都得調用。

Copy link
Member

@lotem lotem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本當如此

@fxliang
Copy link
Contributor Author

fxliang commented Jan 18, 2026

最好合成一个commit,最后那条随手写的msg

@lotem lotem merged commit 58e51c5 into rime:master Jan 18, 2026
10 checks passed
@fxliang fxliang deleted the fix_default_custom branch January 19, 2026 00:59
@fxliang
Copy link
Contributor Author

fxliang commented Jan 19, 2026

那這個 SwitcherSettings::Load 邏輯也有問題,那些 Get* 也應該調,

上一條回覆我說錯了啊,不是加載原始文件而是編譯結果文件也就是已經生效的配置,(這裏的風險:如果此前部署失敗呢?staging 版本已過時?先忽略吧)

Get* 是對 config_ 的進一步提煉。因此無論 custom_config_ 加載到沒有,都得調用。

Selected会受是不是过时的影响(但是这个也是合理的),可用的方案是遍历两个目录找.schema.yaml文件,这个应该问题不大

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.

2 participants