Phase 1 완성: 적응형 캡처 + 영역 자동화 + resume (A2~A6) - #5
Open
nemne-bot wants to merge 6 commits into
Open
Conversation
A3 — the capture loop moves from AppleScript to bash and adapts: - each frame is hashed (ImageMagick '%#'); a page commits only when pixels changed, so pace follows the reader instead of a fixed 1.5s - 8 consecutive identical frames after a page-turn key = end of book -> --pages auto (0) captures until the end with no page count needed - screencapture.applescript retired (loop now in lib/capture.sh); apple/activate.applescript + apple/next-page.applescript remain A2 — region ergonomics: - --region auto: derive from the frontmost window minus --region-margin (the technique proven by the E2E harnesses), no coordinate typing - --region NAME loads a preset; --save-region NAME stores the region just used; --list-regions prints them (~/.config/ebook-script/regions.conf) - prompts accept 'auto' for both pages and region Tests: smoke now covers three scenarios — CLI flags (10/10), SIGINT partial merge, and --pages auto end-of-book stop (ALL PASS; auto mode overshoots ~2 frames at the end, tuning note). Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
A4 resume: - interrupted runs keep their PNG dir; --resume continues from the last committed page (number + previous frame hash derived from existing PNGs) - region/app stored in region.txt and auto-reused on resume - lost page-turn key detected (frame matches last page with no pending turn) and re-sent once before giving up; early stop warns loudly when fewer pages than requested were captured A5: per-page progress with percentage and ETA when a page total is known A6: --resize N% / --gray post-processing (magick mogrify) before merge Harness fixes found the hard way: - a non-interactive shell backgrounds a job with SIGINT ignored at startup, making the trap unreachable from kill -INT — the harness now uses SIGTERM (same INT/TERM handler a real Ctrl-C hits) - count committed pages only (pending.png is scratch), keep the resume log, and validate what the Preview stand-in can validate; per-page resume progression is delegated to real-e2e (Preview scrolls fractionally, so remaining-screen counts are stand-in-dependent) - next-page.applescript: settle delay between activate and the key Smoke: ALL PASS (CLI flags / interrupt+partial merge / resume detection / auto-stop + resize). Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
User verification caught this: running from a terminal made the TERMINAL the frontmost window, so auto region captured (nearly) the whole screen. - auto_region(margin, app): query the front window of the named reader process; refuse with clear guidance when the reader has no open window (no silent fallback to whatever happens to be frontmost) - app now resolves BEFORE the region in bin/ebook-capture (and the EBOOK_APP_NAME override moves up with it), so auto always knows which app to target - real-e2e drives the tool's own --region auto instead of computing a frontmost-based region itself; smoke TEST 1 switches to --region auto - smoke TEST 2 stdin lines reordered to the new prompt order (book -> pages -> app -> region) Verified: with Finder frontmost and a Preview document open, region came out exactly window-bounds minus 10px margin. Smoke: ALL PASS. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
User verification round two: with the Kyobo viewer open, auto region still failed with "cannot find an open window". System Events' `whose name is` compares bytes, and process names are NFD-normalized on macOS while script constants are typically NFC — Korean app names never matched (ASCII ones like Preview did, which is why the harness passed). Resolve via `id of application <name>` (LaunchServices lookup, as tolerant as activate) and match the process by bundle identifier instead. Verified read-only against the live Kyobo viewer (region = window bounds ±10px exactly) and Preview. Smoke: ALL PASS. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
User feedback: auto region includes the app's title/tool bar at the top of the window. auto_region now takes a separate top inset so the bar can be cropped out while other sides keep the normal margin; typical Kyobo viewer measures ~48pt (probed live: toolbar ends ~44pt from the window top, page content starts ~46pt). Pair with --save-region to make it a one-time setup. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
User follow-up: tool-bar height is not fixed, so a static margin-top is only a stopgap. auto_region now probes one frame after activating the reader and refines the window box to the actual page: - rows/columns with a bright-pixel fraction >= 40% are page area; the tool bar and the gray surround are not, whatever their height - validated live: 166pt page top detected in windowed mode (bar + surround above the page), full-window box in immersive mode — adapts per run instead of per preset - falls back to window margins when detection is not confident (dark cover pages); an explicit --region-margin-top still pins the manual behavior Smoke: ALL PASS (TEST 1 runs the detection path via Preview). Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
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.
개요
고도화 로드맵 Phase 1 (Track A: UX 고도화) 전체를 담습니다. A1(CLI 재구조화)은 #4에서 머지됨.
기능
--pages auto)--region auto(전경 창 좌표), 프리셋 저장·재사용 (--save-region/--list-regions)--resume으로 마지막 페이지 다음부터 이어서. 저장된 영역·앱 자동 재사용, 유실된 넘김 키 1회 재발송, 조기 종료 경고[12/300] 4% · 경과 1s · 예상 8s--resize 50/--gray검증 (smoke ALL PASS — 4 시나리오)
CLI 플래그 10/10 · SIGTERM 중단→부분 PDF+디렉토리 보존 · resume 재개 판정 · auto 종료+resize
하네스가 발견한 두 가지 (커밋 메시지에 상세):
남은 검증 (릴리스 게이트)
bash test/real-e2e.sh로 실교보 앱에서 resume 진행 확인 — 머지 전 권장Generated with Claude Code
via Happy