feat(screenshot): --with-frame, relative paths, tab switching, readiness wait#26
Merged
Conversation
Default screenshot now uses Electron renderer canvas only — no Screen Recording permission required. Add --with-frame flag to explicitly use ScreenCaptureKit for full window frame capture. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
🔒 门禁检查结果
Rust 测试覆盖率
前端测试覆盖率
✅ 所有检查通过,可以合入
|
- Remove dead screenshot_fallback function - Add stale window ID handling to screenshot_with_frame - Add tests for with_frame=true query param path - Add test for default screenshot rejection without with_frame Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Rust IT: verify with_frame query param routing (CI-runnable) - Shell E2E: full CLI flow test (local macOS only, skips CI) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add screenshot --with-frame implementation plan - Update release README build timestamp - Add --with-frame test scenario to release_test.md Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…tabs Bug 1: `screenshot -o subdir/shot.png` failed with ENOENT when parent directory didn't exist. Fix: call create_dir_all on parent before writing. Bug 2: `screenshot --with-frame` captured whatever tab was visible in the Electron window instead of the target sandbox's tab. Fix: add switch_tab_request/switch_tab_response messages to the screenshot WebSocket protocol. The daemon now sends a switch_tab_request before SCK capture, and the renderer switches the active tab before responding. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Renderer switch_tab_request handler now calls window.sandbox.switchTab() via IPC to reposition WebContentsView, not just setActiveTabId - Fix screenshot_with_frame test assertions to accept 404 (WindowNotFound) as valid SCK failure mode alongside 500 (previously failed with screencapturekit feature enabled) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…wly spawned Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add 3s per-request timeout to daemon_readiness() to prevent stalling - Log readyz check errors at trace level for debugging Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add doc comment explaining daemon /readyz always returns 200 (polling endpoint) - Use fixed-width padding for animated dots instead of trailing spaces Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Complete 7-phase development workflow (branch → brainstorm → test design → plan → execute → review → test → CI) - Superpowers skill mapping per phase - Testing layers: UT / IT / E2E / Release test - Key constraints: no auto-merge, CLI-first testing, screenshot verification Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR解决了一个核心问题:
screenshot命令默认需要 Screen Recording 权限,对用户不友好。同时修复了截图相关的多个 bug,并优化了启动体验。解决的问题
screenshot命令使用 SCK 截图,需要系统授权-o参数不支持相对路径 — 嵌套目录会报错--with-frame截图时 tab 未切换 — 多 tab 场景下截图显示的是错误的 tab 内容cli-box start启动后立即截图失败 — Electron 渲染器 WebSocket 未连接时截图会报错解决方案
1. SCK 可选化 (
--with-frame)cli-box screenshot(CLI tab)cli-box screenshot --with-framecli-box screenshot(app mode)--with-frameflag 显式使用 ScreenCaptureKit 截取完整窗口(需要权限)entitlements.plist中的 screen-capture 声明2. 相对路径支持
screenshot -o subdir/test.png现在会自动创建嵌套目录(create_dir_all)。3. Tab 切换协议
新增 WebSocket 协议
switch_tab_request/switch_tab_response:--with-frame请求时,先通过 WebSocket 通知 renderer 切换到目标 tabwindow.sandbox.switchTab()重新定位 WebContentsView4. 启动就绪等待 (
/readyz)新增 daemon 级别
/readyz端点,报告 renderer WebSocket 连接状态:cli-box start启动新 Electron 时,轮询/readyz直到 renderer 连接Changes
cli-box-cli/src/main.rs--with-frameflag, relative path support, readiness pollingcli-box-cli/src/client.rsdaemon_readiness(), passwith_frameparamcli-box-core/daemon/mod.rs/readyzendpoint,switch_tab_request/responseprotocol,screenshot_with_frame()cli-box-core/tests/daemon_integration.rselectron-app/src/renderer/main.tsxswitch_tab_request, callswitchTabIPCentitlements.plistTest plan
cargo test --all— 268+ tests passcargo clippy --all-targets -- -D warnings— no warningspnpm typecheck && pnpm test:unit— 36 tests passsh test.sh— all E2E tests pass--with-frame截图显示完整窗口框架-o subdir/test.png正常工作🤖 Generated with Claude Code