Skip to content

chore: rename project from system-test-sandbox to cli-box#17

Merged
Shadow-Azure merged 8 commits into
mainfrom
rename/cli-box
Jun 3, 2026
Merged

chore: rename project from system-test-sandbox to cli-box#17
Shadow-Azure merged 8 commits into
mainfrom
rename/cli-box

Conversation

@Shadow-Azure

@Shadow-Azure Shadow-Azure commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Summary

This PR covers three main areas: project rename, screenshot reliability improvements, and comprehensive test coverage.

1. Project Rename: system-test-sandbox → cli-box

  • Rename all occurrences of system-test-sandboxcli-box and System Test SandboxCLI Box across the entire codebase
  • Update appId from com.system-test-sandbox to com.cli-box
  • Update absolute paths in .claude/settings.local.json
  • 34+ files changed, pure string replacement, no logic changes

2. Screenshot Reliability & Electron Reuse

Problems solved:

Problem Root Cause Solution
Screenshot captured entire Electron window instead of terminal content WebSocket connection dropped silently, causing fallback to ScreenCaptureKit (full window capture) Added WebSocket ping/pong heartbeat (10s interval) in daemon + exponential backoff reconnection in renderer (1s→30s max)
No visibility into why screenshot used fallback Fallback happened silently with no indication to CLI caller Added X-Screenshot-Source and X-Screenshot-Fallback-Reason response headers; CLI prints warning on stderr when fallback is used
cli-box start always spawned new Electron window No check for existing running Electron instance Added find_running_electron() that checks ~/.cli-box/electron.json for alive PID; skips spawn if already running

Key changes:

  • daemon/mod.rs: WebSocket ping/pong via tokio::select!, screenshot_response() helper with headers, request_renderer_screenshot() returns Result<Vec<u8>, String> with descriptive errors
  • client.rs: ScreenshotResult struct with source and fallback_reason fields
  • main.rs: CLI fallback warning on stderr, Electron reuse via find_running_electron()
  • main.tsx: WebSocket reconnection with exponential backoff (1s→2s→4s→...→30s max), resets on successful connection

3. Comprehensive Test Coverage (224 tests)

Added tests guarding against all previously encountered issues:

Layer Test Guards Against
Daemon UT screenshot_response header tests (2) Fallback headers missing or wrong
Daemon UT request_renderer_screenshot error test WebSocket not connected returns descriptive error
Renderer UT WebSocket reconnection tests (4) Reconnection, exponential backoff, backoff reset
CLI UT find_running_electron tests (2) Electron reuse detection
CLI UT ScreenshotResult tests (2) Header parsing correctness
E2E Screenshot fallback test (1) End-to-end header verification
test.sh Sandbox remnant grep check Detects leftover "sandbox" strings in user-facing code

test.sh improvements:

  • Added cargo clippy --all-targets -- -D warnings
  • Added cargo fmt --all -- --check (skipped on Linux CI, handled by separate CI job)
  • Added cargo test -p cli-box-cli (previously only ran cli-box-core)
  • Added sandbox remnant grep check for user-facing strings

4. Additional Fixes

  • MCP server name: sandbox-mcpcli-box-mcp
  • capture_sandbox integration tests: tolerate Electron running (don't hard-assert failure)
  • find_running_electron test: use current PID instead of PID 1 (macOS permission issue)

Files Changed

  • Rust core: daemon/mod.rs, capture/mod.rs, process/mod.rs, server/mod.rs
  • Rust CLI: main.rs, client.rs
  • Rust tests: capture_integration.rs, sandbox_integration.rs, config_integration.rs
  • Electron app: main/index.ts, main.tsx, api.ts, tabState.ts
  • Frontend tests: screenshotWsReconnect.test.ts (new), screenshot-fallback.spec.ts (new)
  • Build/CI: test.sh, release.sh, ci.yml, release.yml
  • Documentation: CLAUDE.md, plan docs

Verification

  • sh test.sh — all sections pass (Rust 177 + Frontend 36 + E2E 11 = 224 tests)
  • cargo clippy --all-targets -- -D warnings — clean
  • cargo fmt --all -- --check — clean
  • CI Gate: all 8 jobs pass (Rust fmt, Clippy, Rust tests, Frontend tests, E2E, test.sh, Security, Gate result)

🤖 Generated with Claude Code

ZN-Ice and others added 3 commits June 3, 2026 08:00
Replace all occurrences of the old project name across source code,
configuration, documentation, and build files:
- "system-test-sandbox" → "cli-box"
- "System Test Sandbox" → "CLI Box"
- "com.system-test-sandbox" → "com.cli-box"

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Rename all user-facing "sandbox" references to "cli-box":
- Cargo crates: sandbox-core → cli-box-core, sandbox-cli → cli-box-cli, sandbox-daemon → cli-box-daemon
- Binary names: sandbox → cli-box, sandbox-daemon → cli-box-daemon
- API routes: /sandbox/{id}/... → /box/{id}/...
- Config dir: ~/.sandbox/ → ~/.cli-box/
- Log files: sandbox-cli.log → cli-box-cli.log
- UI text, CI/CD, release scripts, and all documentation

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…open"

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

🔒 门禁检查结果

检查项 状态
Rust 格式化 ✅ success
Rust Clippy ✅ success
Rust 测试 & 覆盖率 ✅ success
前端测试 & 覆盖率 ✅ success
Playwright E2E ✅ success
统一测试 (test.sh) ✅ success
安全检查 ✅ success

Rust 测试覆盖率

指标 覆盖率
行覆盖率 69.2%
分支覆盖率 0.0%
模块 行覆盖率
crates.cli-box-core.src.server █████████████████░░░ 87.5%
crates.cli-box-core.src.instance ███████████████████░ 99.1%
crates.cli-box-core.src.sandbox ███████████████████░ 98.8%
crates.cli-box-core.src.automation ███████████░░░░░░░░░ 58.8%
crates.cli-box-core.src ███████████░░░░░░░░░ 55.3%
crates.cli-box-core.src.daemon ██████████░░░░░░░░░░ 53.2%
crates.cli-box-core.src.process █████████████░░░░░░░ 65.7%
crates.cli-box-core.src.capture ████████████████████ 100.0%

详细报告见 Rust 覆盖率 artifact

前端测试覆盖率

指标 覆盖率
行覆盖率 ████████████████░░░░ 82.3%
分支覆盖率 68.9%
函数覆盖率 80.0%
语句覆盖率 80.0%
文件 行覆盖率
src/tests/mocks/websocket.ts ██████████████████░░ 88.0%
src/tests/mocks/xterm.ts ████████████████████ 100.0%
src/renderer/api.ts ██████████████░░░░░░ 68.2%
src/renderer/tabState.ts ████████████████████ 100.0%

详细报告见前端覆盖率 artifact

✅ 所有检查通过,可以合入

点击 Squash and merge 合并此PR

ZN-Ice and others added 5 commits June 3, 2026 13:29
- cli-box list help text now shows "cli-box start" instead of "sandbox start"
- Update Playwright snapshot for renamed UI text

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…reuse

- Daemon: add WebSocket ping/pong (10s interval) to keep renderer connection alive
- Daemon: add X-Screenshot-Source + X-Screenshot-Fallback-Reason response headers
- Daemon: refactor screenshot_handler into screenshot_handler + screenshot_fallback
- Renderer: add WebSocket reconnection with exponential backoff (1s→30s max)
- CLI: read fallback headers and warn user when ScreenCaptureKit is used
- CLI: skip Electron spawn when already running (find_running_electron check)
- CLI: MCP server includes screenshot_source/fallback_reason in response

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add tests guarding against previously encountered issues:
- Daemon: screenshot_response header tests, request_renderer_screenshot
  error reason test when WebSocket not connected
- CLI: find_running_electron and ScreenshotResult tests
- Renderer: WebSocket reconnection with exponential backoff tests (4 tests)
- E2E: screenshot fallback header verification
- test.sh: add clippy, fmt, cli crate tests, and sandbox remnant grep check

Also fixes:
- MCP server name: sandbox-mcp → cli-box-mcp
- capture_sandbox tests: tolerate Electron running (don't hard-assert failure)
- find_running_electron test: use current PID instead of PID 1 (permission issue)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…stalled

The CI environment installs Rust without the rustfmt component.
Formatting is already checked by a separate "Rust 格式化检查" CI job,
so test.sh should skip this check on Linux CI (same pattern as clippy).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Shadow-Azure
Shadow-Azure merged commit 95bb57f into main Jun 3, 2026
9 checks passed
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