Skip to content

fix(linux): bump xcap 0.0.4 → 0.9 — fixes UTF-8 crash on non-ASCII window titles#22

Open
leiha wants to merge 6 commits into
P3GLEG:mainfrom
leiha:fix/bump-xcap-utf8
Open

fix(linux): bump xcap 0.0.4 → 0.9 — fixes UTF-8 crash on non-ASCII window titles#22
leiha wants to merge 6 commits into
P3GLEG:mainfrom
leiha:fix/bump-xcap-utf8

Conversation

@leiha
Copy link
Copy Markdown

@leiha leiha commented Apr 9, 2026

Summary

take_screenshot fails on Linux/X11 with invalid utf-8 sequence when any window on the desktop has a non-ASCII title (e.g. French accents in browser tabs, em-dash in file manager).

Root cause: xcap 0.0.4 uses str::from_utf8() (strict) to parse X11 window titles. A single invalid byte crashes the entire Window::all() enumeration. Fixed upstream in nashaofu/xcap#266.

Changes

  • xcap 0.0.4 → 0.9 (Linux + macOS)
  • image 0.24.7 → 0.25 (required by xcap 0.9)
  • Adapt xcap API: .title() / .app_name() / .is_minimized() now return XCapResult<T> — use .unwrap_or_default() for graceful degradation
  • Migrate image API: ImageOutputFormat::Jpeg(quality)JpegEncoder::new_with_quality() (image 0.25 breaking change)

Files changed

  • Cargo.toml — dep versions
  • src/platform/unix.rs — xcap Result handling
  • src/platform/macos.rs — xcap Result handling
  • src/tools/take_screenshot.rs — image 0.25 JPEG encoding

Test plan

  • cargo check passes on Linux
  • Runtime test on Linux with non-ASCII window titles
  • Runtime test on macOS

Generated with Claude Code

leiha and others added 6 commits April 9, 2026 10:56
xcap 0.0.4 crashes with "invalid utf-8 sequence" on Linux/X11 when
any window on the desktop has a title containing non-ASCII characters
(accented characters, em-dash, etc). This is fixed in xcap upstream
(nashaofu/xcap#266).

Changes:
- Bump xcap from 0.0.4 to 0.9 (Linux + macOS)
- Bump image from 0.24.7 to 0.25
- Adapt xcap API: .title()/.app_name()/.is_minimized() now return
  XCapResult<T>, use .unwrap_or_default() for graceful degradation
- Migrate image API: ImageOutputFormat::Jpeg(quality) replaced by
  JpegEncoder::new_with_quality() (image 0.25 breaking change)

Tested: cargo check passes on Linux.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
image 0.25 makes codecs opt-in. Without explicit features, JPEG
encoding fails at runtime with "encoder not enabled".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
JPEG does not support alpha channel. The encoder fails when given
Rgba8 data. Convert to Rgb8 before encoding.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Quand application_name est fourni, dérive /tmp/tauri-mcp-<app>.sock
pour permettre coexistence multi-consumers (ori, iwe) sur l'écosystème
Orun sans collision socket Unix.

Cf D-015 iwe V0a (2026-04-29) — éprouvé runtime depuis 2026-04-29 via
path-local consumers. Commit ratifie l'état déjà éprouvé pour pinning
SHA cross-orisha (T-4 β D-028' sprint:9 iwe).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
executeJavaScript previously used new Function(`return (${code})`)() with a
new Function(code)() fallback, which returns undefined for multi-statement
snippets (e.g. 'const x=1; const y=2; x+y') — forcing callers to wrap
everything in an IIFE.

Replace with indirect eval via an alias (const indirectEval = eval). Indirect
eval runs in global scope (like new Function) but returns the completion value
of the last evaluated statement, so multi-statement code, declarations and bare
expressions all work. Level 1 wraps in parens for object-literal/expression
cases; Level 2 evaluates raw for statement lists. IIFEs keep working (already
expressions; the level-1 double-wrap is a harmless valid expression).
The ori/iwe apps now consume this fork via a pnpm `link:` path dependency
(replacing the npm-registry `tauri-plugin-mcp@^0.1.0`, which shipped the old
unfixed guest-js). pnpm does NOT run lifecycle scripts (prepare) for linked
local packages, so the compiled dist-js must be present in the tree — otherwise
a fresh clone of Orun would leave a dead link with no artifact to resolve.

Un-gitignore dist-js/ and commit index.js/index.cjs/index.d.ts so the execute_js
completion-value fix (22bbf41) reaches the apps' runtime without a build step.
Rebuild with `pnpm build` after editing guest-js/.
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