Skip to content

feat(web): 在 Composer 中提供 Pi 原生斜杠命令发现 - #526

Merged
tt-a1i merged 5 commits into
openpi-dev:mainfrom
6iKUN6:codex/web-slash-command-discovery
Sep 12, 2026
Merged

feat(web): 在 Composer 中提供 Pi 原生斜杠命令发现#526
tt-a1i merged 5 commits into
openpi-dev:mainfrom
6iKUN6:codex/web-slash-command-discovery

Conversation

@6iKUN6

@6iKUN6 6iKUN6 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Problem

Closes #489.

Web Composer 缺少 Pi 原生斜杠命令的发现入口。用户输入 / 时无法查看当前 Session 注册的 Prompt Template、Skill 和 Extension Command,也无法了解命令来源及其在 Web 中的支持状态。

在浏览器中维护硬编码命令表会复制 Pi 的注册逻辑、随运行时能力漂移,并可能泄露本机资源路径。

Value

让 Web 用户可以直接发现并补全当前 Pi Session 提供的命令,同时继续由 Pi 负责命令注册与 Prompt Template、Skill 的展开语义。

不支持的 Extension Command 会明确置灰,避免把命令已接收误解为命令已完成。

Approach

  • 通过隐藏的只读扩展桥调用 Pi getCommands(),以 Pi 作为命令注册的唯一事实来源。
  • 新增经过鉴权并绑定当前 Session 的 GET /api/commands
  • 对命令数量、扫描数量和响应字节数设置硬上限,并移除源码路径等本机信息。
  • Composer 输入 / 后加载一次命令,后续输入只在浏览器本地过滤。
  • 支持 ArrowUp/ArrowDown、Enter、Tab、Escape 和鼠标或触摸操作。
  • 选择 Prompt Template 或 Skill 时只补全 /name ,不会立即提交。
  • Extension Command 统一排在列表末尾并标记为 Web 暂不支持。
  • 新会话默认在输入框下方展示菜单,空间不足时自动翻转到上方;历史会话保持在输入框上方。
  • Session 或工作区变化时取消旧请求,防止过期结果跨 Session 展示。
  • 不复制 Pi TUI 内建命令,也不在 Web 中实现第二套命令解析器。

Validation

  • bun run check
    • 配置契约、纪律账本、Web 构建、格式、Lint 和 TypeScript 检查通过。
  • bun run test
    • Node:1529 passed,0 failed,1 个 Windows 专属测试 skipped。
    • Vitest:143 passed,0 failed。
  • bun run test:web:e2e
    • 12 passed,0 failed。
    • 覆盖命令发现、Session 绑定、Extension Command 置灰、Prompt Template/Skill 补全、不立即提交、路径隐藏、键盘操作和菜单空间翻转。
  • 手工 Web smoke
    • 验证新会话与历史会话的展开方向、空间不足自动翻转、键盘滚动跟随,以及不支持命令的排序和禁用状态。
  • git diff --check
    • 通过。

Impact

  • User-visible behavior:Web Composer 新增斜杠命令发现、过滤和补全菜单。
  • Model-visible context/tools:无变化;不新增模型工具或系统提示。
  • Runtime/lifecycle:新增 Session 绑定的只读命令投影;工作区和 Session 切换时清理旧状态。
  • Persisted config/data:无变化。
  • Compatibility/risk:Pi TUI 内建命令不在本次范围内;缺少明确 Web 能力元数据的 Extension Command 默认禁用。命令投影和响应大小均有界。

Define Pi-owned discovery, bounded command projection, conservative Web availability, and Composer completion behavior for openpi-dev#489.
Project Pi-native prompt templates, skills, and extension commands through a bounded Session-bound endpoint. Add local filtering, accessible completion interactions, stale-request isolation, responsive menu placement, and browser coverage.\n\nCloses openpi-dev#489\n\nCo-Authored-By: Codex <codex@openai.com>
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 d7706de after current-main integration. Standards: no remaining actionable blocker identified. Spec: Command discovery uses the native Pi catalogue, is Session-bound and bounded; unsupported extension execution is explicit. 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 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
tt-a1i merged commit acf3c5b 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.

feat(web): 在 Composer 中提供 Pi 原生快捷命令发现

2 participants