Skip to content

fix(web): 支持查找快照中省略的模型 - #521

Merged
tt-a1i merged 8 commits into
openpi-dev:mainfrom
6iKUN6:codex/web-model-search
Sep 12, 2026
Merged

fix(web): 支持查找快照中省略的模型#521
tt-a1i merged 8 commits into
openpi-dev:mainfrom
6iKUN6:codex/web-model-search

Conversation

@6iKUN6

@6iKUN6 6iKUN6 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Problem

Web 快照会有意将模型投影限制在 250 个以内,但模型选择器既没有展示 modelsOmitted,也没有提供查找快照外模型的入口。因此,当模型目录被截断时,用户无法得知当前列表并不完整,也无法选择被省略的可用模型。

Closes #459

Value

即使初始 Web 快照发生截断,用户现在也能查找并准确选择 Pi 中的任意可用模型。未发生截断时,模型选择器仍保持原有的简洁形态。整个实现继续以 Pi 为唯一事实来源,并对浏览器端和协议层的工作量设置明确上限。

Approach

  • 保留快照最多投影 250 个模型的限制以及当前模型保留逻辑,同时向界面提供准确的省略数量。
  • 新增经过身份验证、绑定当前 Session 的 GET /api/models 接口,在 Pi 的完整可用模型快照中搜索。
  • searchModels() 作为 Web Runtime 的强制契约,删除无字节限制的 Host fallback,并由一个共享投影器负责所有搜索响应。
  • 将查询文本限制为最多 200 个字符、结果限制为最多 50 条、完整响应限制为最多 64 KiB;truncation.bytes 计入模型、统计与截断元数据。
  • 保留原始 provider/modelId 作为精确选择身份,只裁剪名称和标签等展示文本;无法容纳的身份以截断证据省略,不返回被修改的身份。
  • 仅在模型目录被截断时显示搜索框,并加入 250 ms 防抖、请求取消、查询/Session/工作区/snapshot 代际隔离,以及独立的加载、空结果、错误和结果截断状态。
  • 新 snapshot 或 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

  • 用户可见行为:模型目录被截断时,选择器会展示省略信息和完整目录搜索入口;目录完整时保持原有简单选择器。
  • 模型可见上下文和工具:无变化。
  • 运行时和生命周期:模型搜索成为强制且有界的 Web Runtime 契约;结果绑定当前 Pi Session 与 snapshot 代际,过期状态失败关闭。
  • 持久化配置和数据:无变化。
  • 兼容性和风险:新增 Web 协议字段和接口,不破坏现有浏览器协议。搜索具有数量与完整响应字节上限、防抖和取消能力,并隔离查询、Session、工作区和 snapshot 变化产生的过期结果。

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Sep 9, 2026
@6iKUN6 6iKUN6 changed the title fix(web): find models omitted from snapshots fix(web): 支持查找快照中省略的模型 Sep 9, 2026

@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.

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>
@6iKUN6
6iKUN6 force-pushed the codex/web-model-search branch from 6376c16 to 9df3ab8 Compare September 10, 2026 05:26
@6iKUN6

6iKUN6 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

@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.

@6iKUN6
6iKUN6 requested a review from tt-a1i September 11, 2026 08:19
tt-a1i
tt-a1i previously approved these changes Sep 12, 2026

@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.

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
tt-a1i previously approved these changes Sep 12, 2026

@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.

最新 main 集成修复已完成,重新生成 Web 产物。双线复审保留既有侧栏焦点行为和本 PR 功能。 bun run check 已通过;完整测试已执行或正在串行验证,本机部分测试存在资源竞争超时,最终状态以最新 CI 为准。未发现 P0/P1。此账户推送了修复,仍需另一位维护者满足最后一次推送后的独立批准。

tt-a1i and others added 2 commits September 12, 2026 14:18
# 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
@tt-a1i
tt-a1i merged commit 8a717ec into openpi-dev:main Sep 12, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Web UX] 模型列表截断未提示,缺少有界的完整查找入口

2 participants