Repository navigation
[1339] gf pi config 空格启停保留内联自定义模型 - #14
Merged
Merged
Conversation
撤销原方案(inline-spec 内联对象转存),改为递归扫描子目录模型文件。 真实根因:用户的 google.json 的 models 全是字符串 id 且含斜杠 (zai-org/glm-5.2-maas 等),对应模型文件落在 models/<provider>/<org>/<model>.json 子目录里。model-files.scm 的 %directory-model-ids 只列 models/<provider>/ 顶层 .json,不递归子目录, 导致禁用后该模型既不在白名单、又不被目录枚举发现,从配置视图永久消失。 %non-whitelist-models 与 %full-models 均受影响。 修复:%directory-model-ids 递归扫描 models/<provider>/ 下所有子目录的 .json,以相对路径去 .json 后缀作为模型 id,使含斜杠 id 的模型也能被目录 枚举发现。%find-model-file-by-id 同步改为递归。其余读取链路 (%model-file、pi-user-model-exists?)已按 id 直接拼路径,无需改动。 回归测试: - 新增 slash-ids / slash-ids-disabled 夹具(模型文件在子目录) - pi-user-provider-model-list-test 覆盖禁用后灰显保留与字段完整 - 新增 pi-config-plan-toggle-slash-test 覆盖禁用→重载→重新启用往返
PinkMagicFly
force-pushed
the
pigmagicfly/1339/preserve-inline-models
branch
from
November 24, 2026 02:21
00903c2 to
55fa6a9
Compare
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.
背景
gf pi config的模型列按空格启用/禁用模型时,供应商文件models/<provider>.json的models数组允许字符串模型 id 与内联模型对象混用,但既有%toggle-model/%disable-model把数组当成纯字符串白名单处理:禁用时用string=?过滤(遇内联对象直接抛 type-error),启用时只追加字符串并整体重写models。结果是用户对任一模型按空格都会丢失数组里其他未参与操作的内联对象定义,目标内联对象自身也没有独立文件承接,写盘重载后这些自定义模型从供应商文件中消失,只能手工补回。改动
tui/liii/pi/tui/config/files.scm:新增内联模型规格匹配与禁用逻辑。id字段),不再对全部元素调用string=?,也不以字符串过滤结果重建整个数组。models/<provider>/<model>.json独立模型文件,再从激活数组移除目标项;非目标字符串项与内联对象的内容、顺序均保留。tui/liii/pi/tui/config/inline-spec.scm(新模块):抽取按 id 匹配、安全移除、键序无关规范化比较的纯函数,供 files 层复用,并配套单元测试。inline-models、inline-models-disabled隔离夹具(字符串 id + 内联对象混合数组)。pi-config-inline-toggle-test.scm:覆盖禁用/启用、非目标内联对象保留、重复启停回归、目标文件冲突拒绝、默认模型回退、字符串 id 不回归。pi-config-inline-run-test.scm:真实按键→计划→原子落盘→重载全链路集成回归。pi-user-provider-model-list-test.scm:内联模型禁用后仍以未激活项显示,字段不丢失。pi-provider-file-with-models-test.scm:混合 models 数组重写与 JSON 往返。验收
gf fmt --check/gf check全绿。gf test tui/tests/liii/pi/tui/config/files/、tui/tests/liii/pi/tui/config/app/、code/tests/liii/pi/code/config/全部通过。