Skip to content

feat(tui): 工具列表搜索过滤 + 滚动/重叠修复 - #1

Merged
kugouming merged 9 commits into
mainfrom
feat/tui-tools-search-and-scroll
Aug 27, 2026
Merged

feat(tui): 工具列表搜索过滤 + 滚动/重叠修复#1
kugouming merged 9 commits into
mainfrom
feat/tui-tools-search-and-scroll

Conversation

@kugouming

Copy link
Copy Markdown
Contributor

Summary

本 PR 修复 ServiceTools 视图在工具数量较多时的多个布局/交互问题,并抽取服务表单的共享字段帮助文案。

TUI 工具列表修复 (src/tui/components/ServiceTools.tsx)

  • 滚动:工具列表随选中行滚动,选中项超出第一页时保持可见(复用 ServiceFormUnified 的滚动模式)
  • 重叠:↑ more 指示行不再与最后一行工具重叠(为指示行预留空间)
  • 截断:超长工具名按面板宽度截断(Ink 的 wrap="truncate 未计入 ▶ ✓ 前缀,改用手动截断)
  • 视口高度:新增 terminalHeight prop,由宿主传入实际可用高度,避免按满终端高度算行数导致溢出

工具搜索/过滤

  • / 进入搜索输入态,输入即按名称过滤(大小写不敏感子串),↑↓ 实时导航匹配结果
  • Enter 确认过滤(此后 Space 可切换工具),Esc 分层:退出输入态 → 清空过滤 → 返回服务列表
  • a/A 批量切换作用于当前过滤结果;空匹配显示空态;搜索框常驻显示匹配数

Esc 处理修复 (app-optimized.tsxapp.tsx)

  • 宿主全局 useInput 不再在 tools 视图拦截 Esc,交由 ServiceTools 分层处理;onBack 同时刷新服务列表

服务表单重构

  • 抽取 service-field-config.ts 共享字段帮助文案/占位符(ServiceForm/ServiceFormUnified 复用)
  • 新增 DEFAULT_CONNECTION_POOL 常量(types/service.ts),cli.tsfile-provider.ts 使用

Test plan

  • npm run typecheck 通过
  • npm run build 通过
  • 新增 tests/integration/tui-service-tools-scroll.test.ts(5 用例):滚动不重叠、长名截断、搜索过滤、空匹配、分层 Esc + 过滤态切换
  • 相关现有 TUI 测试 29 个通过(tui-service-list / tui-service-form-unified / tui-trigger-hints)
  • 手动:npx tsx src/cli.ts --mode tui 进入工具多的服务,验证 / 搜索、↑↓ 导航、Space 切换、Esc 三步分层

🤖 Generated with Claude Code

- Deleted unit tests for DataMasker, Logger, and RequestLogger as they are no longer needed.
- Updated ConnectionPool tests to improve idle timeout handling and event emission.
- Enhanced ToolRouter tests to verify connection results and handle failures more effectively.
- Suppressed console warnings and errors in transport tests to clean up test output.
- Adjusted vitest configuration to exclude specific test files and set up for forking.
… check response

- Updated CLI mode integration tests to use Content-Length framing for messages.
- Refactored response reading logic to handle Content-Length headers in CLI mode.
- Modified server mode health check test to verify summary counts in the response.
- Simplified mock implementations in connection pool property tests by removing unused event methods.
- Adjusted MCP handler tests to track session initialization in context rather than the handler.
- Updated transport tests to validate message framing with Content-Length.
- Increased test and hook timeout values in Vitest configuration for improved stability.
- Refactored logger setup to be configuration-driven, allowing for dynamic log level, output format, and masking of sensitive data.
- Introduced `configureLogger` function to initialize logging based on system configuration.
- Updated logger to support JSON formatting and sensitive value masking.
- Added tests for logger functionality, ensuring sensitive data is masked in logs.

fix(health): improve health monitoring event emissions

- Changed event emission from `serviceUnhealthy` to `serviceFailed` for clarity.
- Updated health monitor to manage unhealthy services more effectively.

fix(cli): streamline CLI logging behavior

- Removed unnecessary stderr suppression in CLI mode, allowing for better logging visibility.
- Adjusted logging setup in TUI mode to align with new configuration-driven approach.

feat(config): enforce unique service names in configuration

- Added validation to ensure service names in `mcpServers` do not collide after normalization.

test(tests): enhance integration and unit tests

- Added tests for logger to verify structured logging and sensitive data masking.
- Updated integration tests to check for proper handling of deleted sessions and responses.
- Improved unit tests for health monitoring and tool routing to ensure robustness.

refactor(transport): simplify transport message framing

- Updated `StdioTransport` to use newline-delimited JSON-RPC messages, improving compatibility with legacy peers.
@kugouming
kugouming force-pushed the feat/tui-tools-search-and-scroll branch from 3d37836 to ba7f77f Compare August 27, 2026 02:47
- ServiceTools 新增 `/` 搜索模式,分层 Esc(退出搜索→清除过滤→返回列表)
- 增加工具列表滚动偏移与超长名称截断,修复滚动指示符与工具行重叠
- app/app-optimized 计算 contentHeight 并下传 ServiceTools,移除外层 Esc 拦截
- 提取 service-field-config 统一表单帮助文案与输入占位符
- 抽取 DEFAULT_CONNECTION_POOL 常量,替换 cli/file-provider/JSON 编辑器中的硬编码默认值
- 新增工具滚动/搜索集成测试与字段配置单元测试
- 强制 CI=false,避免 Ink 在 CI 模式下跳过渲染导致捕获输出为空
- 用 vi.hoisted 提升 fetchServiceTools mock,断言 mock 驱动了渲染
- 新增 waitFor 轮询助手替代固定次数等待,适应慢速 CI 与 Ink 32ms 节流
- 滚动到底部命中目标即提前退出,减少不必要迭代
@kugouming
kugouming force-pushed the feat/tui-tools-search-and-scroll branch from 9784fcc to 62d4561 Compare August 27, 2026 04:27
@kugouming
kugouming merged commit ab48ec2 into main Aug 27, 2026
7 checks passed
@kugouming
kugouming deleted the feat/tui-tools-search-and-scroll branch August 31, 2026 14:44
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.

1 participant