Skip to content

feat: add ToolsConfig panel with individual tool toggles - #39

Closed
fallleave001 wants to merge 1 commit into
agegr:mainfrom
fallleave001:feat/tools-config
Closed

fallleave001 wants to merge 1 commit into
agegr:mainfrom
fallleave001:feat/tools-config

Conversation

@fallleave001

Copy link
Copy Markdown
Contributor

概述 / Summary

新增 ToolsConfig 面板,每个工具(内置 + 扩展)可单独开关,替代旧的 Low/High/Off 预设下拉菜单。配置持久化到 settings.json 的 activeTools 字段,pi-cli 也可共享。

Replace the old wrench-icon Low/High/Off preset dropdown with a ToolsConfig modal panel where each tool (built-in + extension) can be individually toggled. Config is persisted to settings.json under activeTools, shared with pi-cli.

改动 / Changes

File Change
app/api/tools/route.ts New — tool enumeration via temp session + read/write activeTools in settings.json
components/ToolsConfig.tsx New — modal panel with per-tool toggles, grouped by Built-in / Extensions
lib/rpc-manager.ts startRpcSession reads activeTools from settings.json; set_tools supports exact flag
components/AppShell.tsx Added Tools button in left sidebar
components/ChatInput.tsx Removed old wrench-icon Low/High/Off preset dropdown
hooks/useAgentSession.ts New sessions read saved config from /api/tools, fall back to old presets
components/ToolPanel.tsx getPresetFromTools uses superset matching for extension compatibility

向后兼容 / Backward Compatibility

  • 旧预设下拉菜单已移除,但 set_tools 不加 exact: true 时仍保留所有已注册工具(含扩展)
  • settings.json 中的 activeTools 字段对旧版 pi-cli 无影响(忽略未知字段)
  • The old preset dropdown is removed, but set_tools without exact: true still preserves all registered tools (including extensions)
  • activeTools in settings.json is ignored by older pi-cli versions

… settings.json

- New ToolsConfig component with per-tool toggle switches (built-in + extensions)
- New /api/tools endpoint for tool enumeration and config persistence
- Tools button in left sidebar replaces old wrench-icon preset dropdown
- Config stored in settings.json 'activeTools' field, shared with pi-cli
- startRpcSession reads saved config on session creation
- getPresetFromTools uses superset matching for extension compatibility
@agegr

agegr commented Jun 4, 2026

Copy link
Copy Markdown
Owner

测了下有点小bug。用户点了 “Disable all” 后下一次仍会启用默认工具。

@agegr agegr closed this Jun 4, 2026
@fallleave001

Copy link
Copy Markdown
Contributor Author

Bug 已修复。根因是三处代码都把空数组 [] 当成了"没配置",导致 Disable all → 新建会话后又启用了默认工具:

  • app/api/tools/route.ts — 存 [] 时直接删 key,读回来是 null
  • lib/rpc-manager.ts — 读配置时 [].length > 0 把 [] 过滤了
  • hooks/useAgentSession.ts — 新建会话时同样过滤 []

三处均已修复,测试通过。方便的话 reopen 一下,谢谢 🙏

brynne8 added a commit to brynne8/pi-web that referenced this pull request Nov 29, 2026
Open a session that loads a skill and read the System panel: the
<available_skills> block is a wall of &quot;. pi writes the skill list into
the prompt as XML and escapes it with escapeXml
(pi-coding-agent dist/core/skills.js), which escapes " and ' as well,
though element text asks only for &, < and >. One skill whose description
lists 89 quoted trigger phrases arrives with 178 &quot; in it, which reads
as noise rather than as the prompt it is.

Unfold the five entities escapeXml emits, plus &agegr#39; for the same apostrophe
written numerically, before rendering. The unfold is one regex pass, not a
chain of replaces: text that really contained "&quot;" reached the prompt as
"&amp;quot;" and comes back as &quot;, not as a quote, so nothing unfolds
twice. What the panel shows is the prompt as authored; the request still
carries the escaped bytes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants