Skip to content

fix(setup): diagnose invalid config and roll back failed applies - #557

Open
6iKUN6 wants to merge 2 commits into
openpi-dev:mainfrom
6iKUN6:codex/issue-498-setup-config
Open

6iKUN6 wants to merge 2 commits into
openpi-dev:mainfrom
6iKUN6:codex/issue-498-setup-config

Conversation

@6iKUN6

@6iKUN6 6iKUN6 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Problem

配置加载失败会静默回退默认值,用户难以区分缺文件、损坏文件及不支持的配置;保存也缺少未知字段保留和当前 Session 应用失败后的恢复保障。

Closes #498

Value

让用户看见配置加载问题,避免普通 setup 操作覆盖无效配置或丢失未知字段。当前 Session 的配置消费者确认应用成功后才报告成功;失败时尝试恢复原文件和配置,并明确报告恢复不完整。

Approach

  • 引入 configVersion: 1 和字段校验。缺文件使用默认值;无版本配置仅在明确保存时迁移;JSON、IO、版本或已知字段错误阻止写入。未知字段告警并保留,会导致未知字段丢失的修改被拒绝。
  • /openpi-setup 显示来源、版本、字段诊断和写入状态。有 UI 的 Session 启动或重载时主动提示加载错误或警告,详情仍留在原入口;不自动写文件或调用模型。
  • 沿用跨进程锁、0600 权限及临时文件 rename。通过 Pi EventBus 的显式应用回执等待消费者完成,避免监听器异常被吞掉后误报成功;失败或取消时有条件恢复原文件字节和配置,检测到外部替换则拒绝覆盖。
  • 保存回执区分落盘与有效配置变化。明确区分 compact 预设和 footerStyle 枚举;提示词要求显式非法字段值先说明合法范围并等待用户选择,禁止擅自替换。运行时拒绝非法 Footer 样式或预设。
  • 已 rebase 到 f991f9e,解决 setup 导入冲突,并将 feat(web): complete session workbar and settings experience #561 的三个 Web 字段纳入 schema:ui.webChatWidth(820–2000 的整数)、ui.webChatFontSize(12–24 的整数)、ui.webExpandThinking(布尔值)。复用上游范围常量,避免把合法字段当作未知字段、保存时被旧值覆盖。
  • 更新 README、SETUP 和回归测试。沿用唯一配置入口、episode-scoped parent-only writer 及既有消息投递机制。

Validation

  • 本次验证基于 d45443f,上游基线为 f991f9ebun run check 全部通过(配置/文档合同、构建、格式、lint、类型检查);git diff --check upstream/main 通过。
  • 配置、应用回执、setup 工具及真实 Pi 集成专项:node --test --experimental-strip-types tests/extensions/shared/setup-config.test.ts tests/extensions/shared/setup-apply.test.ts tests/extensions/setup/index.test.ts tests/extensions/setup/integration.test.ts,65/65 通过。最初一次运行的集成测试触发 8 秒超时;后续全量和专项复跑均通过,保留为间歇性超时记录。
  • 三个新增 Web 配置回归测试在修复前全部失败、修复后全部通过。覆盖旧格式及版本 1 的合法边界、类型/范围错误诊断和写入拒绝、无关修改保留字段、实际修改落盘、未知字段保留、应用失败时精确恢复原文件。
  • bun run test 在允许本地测试端口的环境下运行:Node 部分 1776 通过、2 失败、1 跳过(共 1779 项)。两个失败均为 Plan Mode 的 a rich plan renders without throwing and keeps its contentexpanded survives edge-content plans at extreme widths,已在未修改上游 f991f9e 和相同安装依赖下复现(22 通过、2 失败)。测试辅助函数未去除 OSC 8 超链接控制符;本 PR 未修改 Plan Mode,未将全量测试标为通过。
  • Node 失败使脚本未进入 Vitest,因此单独运行全部 20 个 .spec.ts 文件(--maxWorkers=2):291 通过、2 失败。失败分别为 Web settings 的 5 秒超时和 composer 焦点断言;原样单独复跑这两个文件(--maxWorkers=1)13/13 通过,未调整测试断言或超时。
  • 此前用户已在真实 Pi 验收配置落盘、版本号、0600 权限及底栏即时生效;非法 ui.footerStyle="compact"workflows.concurrency=0 请求会解释合法范围并询问,选择保持现状后不调用写入工具。这是此前版本的人工验收,本次 rebase 未重新做真实 TUI 目视验收;没有安装或运行社区 statusline 包。

Impact

  • 用户可见:新增加载告警、setup 诊断及更准确的保存回执;无效配置需要修复或由用户明确移除后才能恢复写入。
  • 模型上下文/工具:补充诊断、实际变化字段及非法值处理说明;不新增模型工具或命令。自然语言意图仍由模型判断,参数校验不能单独保证模型不将原话改写为另一组合法参数。
  • 运行时/生命周期:当前 Session 配置应用增加明确回执与失败恢复;setup writer 的可见性和回合边界保持原有机制。
  • 持久化/兼容:个人配置新增版本号,旧格式显式保存时迁移,未知字段保留。配置仍是用户级,不增加项目作用域、第二套 Footer 或新依赖;兼容当前 main 的 Web 配置字段。
  • 限制:回滚保护覆盖本次进程内应用失败;不是所有 Pi 进程的全局原子事务,也不是崩溃恢复日志。恢复前检查文件身份与内容,发现外部变更则报告恢复不完整;不保证对不遵守锁协议的外部写入实现原子 CAS。

@github-actions github-actions Bot added documentation Improvements or additions to documentation area:setup OpenPI setup, configuration, or setup documentation area:ui Terminal UI, rendering, themes, or visual assets labels Sep 18, 2026
@6iKUN6
6iKUN6 requested a review from tt-a1i September 18, 2026 10:06

@tt-a1i tt-a1i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

需要先 rebase 已合并的 #561,并把新增的 Web UI 配置纳入版本化 schema 后再合并。当前 PR 是 CONFLICTING,现有绿灯基于旧 main,不能作为集成验证。

Comment thread extensions/shared/setup-config.ts

@tt-a1i tt-a1i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

审查提交:da4a4faa2ea61d4905150b4cd3b4aa2e3ca26916

需要修改后再合并。

具体问题

P1 — 配置诊断 schema 未纳入 main 已发布的三个 Web UI 字段 · extensions/shared/setup-config.ts:580

setupShape lacks webChatWidth/webChatFontSize/webExpandThinking while current main canonical config contains them. preserveUnknown treats omitted schema keys as raw unknown values, so mechanical conflict resolution cannot safely validate/persist changes.

验证范围

Reviewed versioning, diagnostics, exact-byte/identity rollback, async consumer receipts and unknown-field preservation; focused config/setup/apply suite completed. Existing exact-head integration finding remains.

限制与后续

Branch conflicts with main; no conflict-resolved tree exists. Finding is an integration blocker, not a claim that a merged build was executed.

Add versioned fail-closed configuration loading, preserve unknown fields, and report load diagnostics through the existing setup entry point and session notifications. Await consumer apply receipts and restore prior configuration on failure. Clarify explicit invalid values and effective-change receipts with regression coverage.
@6iKUN6
6iKUN6 force-pushed the codex/issue-498-setup-config branch from da4a4fa to d45443f Compare September 21, 2026 10:38
The Node phases consumed 265 seconds of the 300-second step budget, leaving too little time for Vitest. Raise the full-suite step limit to 10 minutes while retaining individual test deadlines and the 15-minute job limit.
@6iKUN6
6iKUN6 requested a review from a team as a code owner September 21, 2026 10:52
@github-actions github-actions Bot added the area:github GitHub workflows, templates, ownership, or tests label Sep 21, 2026
@6iKUN6

6iKUN6 commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

@tt-a1i 之前提出的问题和合并冲突都已修复,CI 也已全部通过,麻烦有空时再帮忙 review 一下,谢谢!

@tt-a1i tt-a1i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

复审提交 07610dcf65df33cce5602c83c67ed55ed431afe8

此前指出的配置 schema 缺漏已修复:ui.webChatWidthui.webChatFontSizeui.webExpandThinking 已进入校验与默认值,新增测试覆盖合法边界、拒绝非法值、保存和失败回滚。当前 PR 的远端检查全部通过;我本地专项测试首次 64/65,其中真实 Pi 集成用例触发既有 8 秒超时,单独复跑通过。

仍需修改:与当前 main6132d997)合并时,extensions/post-edit/index.ts 有内容冲突。main 已将待运行任务改成队列(pendingRuns.length = 0),此分支仍有旧的计数器清理逻辑(pendingRuns = 0),同时新增 onSetupApply 配置重载。解决冲突时需要保留当前队列/同步屏障,并确保关闭 post-edit 后清空待运行队列;不能直接接受分支一侧的旧实现。请解决冲突后在合并结果上重跑相关测试。当前绿灯仅覆盖此 PR 分支,不能证明冲突解决后的代码。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:github GitHub workflows, templates, ownership, or tests area:setup OpenPI setup, configuration, or setup documentation area:ui Terminal UI, rendering, themes, or visual assets documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

setup: 配置诊断与 fail-closed 回滚,不新增第二条配置入口

2 participants