fix(web): 支持查找快照中省略的模型 - #521
Conversation
tt-a1i
left a comment
There was a problem hiding this comment.
Reviewed at exact head 6376c16.
Standards
[P1] The advertised response-bound invariant fails open through the optional runtime fallback. WebRuntimeController.searchModels is optional, and the fallback in web/host/web-host.ts slices only by result count. It does not enforce the 64 KiB response limit or bounded identity fields, calls listModels() twice, and reports totalMatches / matchesOmitted after slicing. A conforming runtime without searchModels can therefore return an arbitrarily large response with false truncation evidence. This conflicts with the repository contract that runtime resource limits and exact terminal evidence must be enforceable facts. Please make the bounded search contract mandatory, or centralize a single host-owned bounded projector used by every runtime path.
Spec
[P2] PiWebRuntime.searchModels() truncates provider and id to 500 characters, but the browser later uses those projected values as the canonical selection key. A valid long custom identifier is mutated into a string ending in [truncated], so exact provider/modelId selection fails. Keep an opaque canonical identity separate from bounded display text, or reject unrepresentable identities explicitly.
[P2] The 64 KiB accounting measures only { models }, while WebHost serializes the larger result object containing totals and truncation metadata. Near the boundary, the actual HTTP response exceeds the documented cap. Please assert the size of the final serialized response.
[P2] Search results are reset only when Session identity changes. If the provider configuration or available model catalog changes within the same Session, stale search results remain selectable. Please invalidate results against catalog/snapshot generation as well as Session/query generation.
Show bounded snapshot truncation, search Pi's full available model set, and preserve exact provider/model identity through selection. Add debounce, stale-result isolation, bounded protocol responses, and browser coverage for selecting the 251st model.\n\nRefs openpi-dev#459\n\nCo-Authored-By: Codex <codex@openai.com>
Document Pi ownership, bounded full-catalog search, browser behavior, and the validation limits for issue openpi-dev#459.
Make model search a required runtime contract, preserve exact provider/model identities, account for the complete serialized response, and invalidate stale search results across snapshot generations.\n\nAddress review feedback on openpi-dev#521.\n\nCo-Authored-By: Codex <codex@openai.com>
Update the validated source boundary and preserve the review gaps, corrected invariants, and final verification evidence for PR openpi-dev#521.\n\nCo-Authored-By: Codex <codex@openai.com>
6376c16 to
9df3ab8
Compare
|
@tt-a1i Addressed all four review points at 9df3ab8: model search is now a mandatory bounded runtime contract, canonical provider/model identities stay exact, byte evidence covers the complete serialized response, and search state is invalidated and re-queried across snapshot generations. Rebased onto current main; check, full tests, and Web E2E pass. Please take another look when convenient. |
tt-a1i
left a comment
There was a problem hiding this comment.
Reviewed 9bdeda8 after current-main integration. Standards: no remaining actionable blocker identified. Spec: Canonical model search occurs before bounded projection, and provider/id identity is preserved. The previous fallback and identity-truncation blockers are fixed. No P0/P1 found. This supersedes findings against older implementations where stated; merge remains conditional on current required CI and branch protection.
# Conflicts: # web/dist/app.js # web/dist/styles.css
tt-a1i
left a comment
There was a problem hiding this comment.
最新 main 集成修复已完成,重新生成 Web 产物。双线复审保留既有侧栏焦点行为和本 PR 功能。 bun run check 已通过;完整测试已执行或正在串行验证,本机部分测试存在资源竞争超时,最终状态以最新 CI 为准。未发现 P0/P1。此账户推送了修复,仍需另一位维护者满足最后一次推送后的独立批准。
# Conflicts: # tests/web/app-render.spec.ts # tests/web/web-protocol.spec.ts # web/dist/app.js # web/dist/styles.css # web/protocol/types.ts # web/runtime/pi-runtime.ts # web/runtime/types.ts # web/ui/src/app/App.tsx # web/ui/src/features/composer/Composer.tsx # web/ui/src/protocol/client.ts # web/ui/src/store/web-store.ts # web/ui/src/styles.css
Problem
Web 快照会有意将模型投影限制在 250 个以内,但模型选择器既没有展示
modelsOmitted,也没有提供查找快照外模型的入口。因此,当模型目录被截断时,用户无法得知当前列表并不完整,也无法选择被省略的可用模型。Closes #459。
Value
即使初始 Web 快照发生截断,用户现在也能查找并准确选择 Pi 中的任意可用模型。未发生截断时,模型选择器仍保持原有的简洁形态。整个实现继续以 Pi 为唯一事实来源,并对浏览器端和协议层的工作量设置明确上限。
Approach
GET /api/models接口,在 Pi 的完整可用模型快照中搜索。searchModels()作为 Web Runtime 的强制契约,删除无字节限制的 Host fallback,并由一个共享投影器负责所有搜索响应。truncation.bytes计入模型、统计与截断元数据。provider/modelId作为精确选择身份,只裁剪名称和标签等展示文本;无法容纳的身份以截断证据省略,不返回被修改的身份。runtime_changed到达时立即清除旧搜索结果;选择器仍打开时按原查询重新执行一次防抖搜索。docs/architecture/WEB_MODEL_DISCOVERY.md中保留初始实现的 review 缺口,并记录修复后的所有权边界、容量限制和验证证据。Validation
bun run check:通过。bun run test:通过;Node 测试 1,528 个通过、0 个失败、1 个 Windows 专属测试跳过,Vitest 测试 138 个通过、0 个失败。bun run test:web:e2e:最终完整重跑 12 个通过、0 个失败。git diff --check:通过。一次较早的完整 E2E 运行在 trajectory 场景的 axe 分析中偶发超时;该场景随后单独运行 1.8 秒通过,最终完整重跑 12 项全部通过。
浏览器 E2E 使用确定性拦截的模型 API 数据,构造 250 个快照内模型和 1 个只能通过搜索找到的模型。该测试不代表已经在配置了 251 个真实模型的 Provider 账户中完成验证。Adapter 测试另外使用了包含 1,000 个模型的目录,覆盖快照数量限制和字节限制。
Impact