发布

  • fix(cli): unbreak claude-tap on Windows (#83) (#84)

    frostbyte_neo 发布于 2026-04-28 16:58:24 +00:00

    • fix(cli): unbreak claude-tap on Windows (#83)

    Three independent Windows-only failures all surfaced at startup:

    • signal.SIGTSTP is Unix-only — accessing the attribute raised
      AttributeError before any signal handler ever fired. Guard the
      attribute lookup so Windows sessions skip the SIGTSTP wiring.
    • asyncio.create_subprocess_exec("claude", ...) calls CreateProcess,
      which only auto-appends .exe; npm-installed shims land as
      claude.cmd and produced FileNotFoundError [WinError 2]. Resolve
      the command via shutil.which() and pass the absolute path so
      .cmd/.bat shims work the same as .exe binaries.
    • Default Windows console encoding (GBK/cp936) cannot encode the emoji
      used in our progress prints, raising UnicodeEncodeError on the very
      first print. Reconfigure stdout/stderr to UTF-8 with
      errors="backslashreplace" so we never crash on non-UTF-8 consoles.

    Adds tests/test_windows_compat.py with platform-agnostic regressions
    that simulate Windows by removing signal.SIGTSTP and stubbing
    shutil.which, and updates test_codex_launch.py for the new
    resolved-path contract.

    Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

    • refactor(cli): tighten Windows-fix comments and drop dead code
    • Compress the resolved_cmd rationale comment from three lines to two.
    • Inline the display string in the startup print; drop the redundant
      display_cmd local and its unnecessary .rstrip() (str.join over a
      non-empty list never produces trailing whitespace).
    • Drop per-test docstrings in test_windows_compat.py — the test names
      are self-describing; the module docstring already explains the
      cross-platform simulation strategy.
    • Drop the unused captured dict in the SIGTSTP-absent test.

    No behavior change; gates and the 7 targeted tests stay green.

    Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

    • fix(cli): finish Windows compat — uv shim, file URI, manifest paths

    Three follow-ups to the #83 fix uncovered by a deeper audit:

    • _start_background_update invoked ["uv", ...] directly, so the same
      CreateProcess-doesn't-resolve-.cmd problem from run_client would
      silently swallow background upgrades on Windows when uv ships as a
      .cmd shim. Resolve via shutil.which("uv") and bail out cleanly
      when missing.
    • f"file://{html_path.absolute()}" produced malformed URIs on
      Windows (file://C:\path\file.html) and didn't URL-encode spaces.
      Replace with Path.as_uri(), which yields RFC 8089-compliant
      file:///C:/path/file.html on every OS.
    • .cloudtap-manifest.json stored OS-native separators in trace file
      paths, so a .traces/ directory synced between Windows and POSIX
      (cloud drive, git, rsync) would double-register entries because
      2026-04-29/trace.jsonl and 2026-04-29\trace.jsonl compared
      unequal. Introduce _rel_posix() to write forward slashes
      consistently, and normalize backslashes on read so manifests written
      by older builds keep matching.

    Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

    • fix(scripts,tests): UTF-8 hardening for ancillary files on Windows
    • scripts/verify_screenshots.py printed status with emoji (/)
      on the bare print stream, so running it on a Windows GBK console
      raised UnicodeEncodeError before any check could run. Apply the same
      UTF-8 reconfigure pattern used by claude_tap.cli. Same script also
      built file:// URLs with naked Windows paths — switch to as_uri().
    • tests/test_nav_browser.py and tests/test_perf_viewer.py opened
      tempfile.NamedTemporaryFile in text mode without encoding=, so
      they fall back to the locale codec and crash when the viewer
      template's I18N block hits a non-encodable codepoint on Chinese
      Windows. Make the encoding explicit.

    Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com


    Co-authored-by: Claude Opus 4.7 (1M context) noreply@anthropic.com

    下载附件