Skip to content

Normalize Env subscriber path/URL payloads to UTF-8 binaries - #85

Merged
dominicletz merged 1 commit into
mainfrom
fix/canonical-env-subscriber-payloads
Sep 4, 2026
Merged

Normalize Env subscriber path/URL payloads to UTF-8 binaries#85
dominicletz merged 1 commit into
mainfrom
fix/canonical-env-subscriber-payloads

Conversation

@dominicletz

@dominicletz dominicletz commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Desktop.Env subscriber OS events (:open_url, :open_file, :print_file) now always deliver UTF-8 binaries (String.t()), whether they arrive from wx (charlists) or from native bridges (already binaries).

This closes the gap where EventBridge/notify_subscribers sent binaries while wx handle_info forwarded charlists (including a bare charlist as the second tuple element), which broke app adapters that only handled one encoding.

Changes

  • Add t:subscriber_event/0 / t:os_app_event/0 / t:desktop_event/0 and document the contract on subscribe/0 and notify_subscribers/1
  • Normalize path/URL lists at both ingest paths (notify_subscribers cast and OS handle_info) before buffer or delivery
  • Tests for binary passthrough, charlist lists, bare charlist, pre-subscribe buffer replay, :window_activated, and :new_file
  • Move wx-only Env checks to test/desktop/env_wx_test.exs so browser/normalization tests are not polluted by WxCase module setup
  • Changelog under 1.6 (unreleased); fix historical 1.3 note to use list form {:open_url, [url]}

Test plan

  • NO_WX=1 mix test test/desktop/env_test.exs (8 tests, 0 failures)
  • NO_WX=1 mix test.fast (pre-existing unrelated failures in this environment)
  • xvfb-run -a mix test.wx when a display is available

Note

Medium Risk
Changes the on-the-wire contract for OS open events that apps handle via Env.subscribe/0; apps that matched only charlists or only binaries must align with binaries, but behavior is now consistent across wx and native paths.

Overview
Desktop.Env subscribers now always get UTF-8 binaries for :open_url, :open_file, and :print_file, fixing inconsistent charlist vs binary payloads from wx vs bridges.

Normalization runs on notify_subscribers/1 and on OS handle_info ingest (including events buffered before subscribe/0), with a special case for wx’s bare charlist second element ({:open_url, ~c"..."}). subscribe/0 and module docs document t:subscriber_event/0 and related types; other events (:new_file, :window_activated) are unchanged.

Tests cover passthrough, charlist conversion, buffering, and non-path events; wx-only Env tests move to test/desktop/env_wx_test.exs. Changelog and the 1.3 note are updated to describe list-shaped {:open_url, [url]}.

Reviewed by Cursor Bugbot for commit 8a3d5fa. Configure here.

Wx charlists (including a bare charlist as the event list) are converted at
the Env boundary on notify_subscribers and OS handle_info ingest so
subscribers always receive String.t() paths. Document the subscriber_event
types and cover binary, charlist, buffer-replay, and lifecycle events in tests.
@dominicletz
dominicletz marked this pull request as ready for review September 4, 2026 15:02
@dominicletz
dominicletz merged commit 892b1b7 into main Sep 4, 2026
2 checks passed
@dominicletz
dominicletz deleted the fix/canonical-env-subscriber-payloads branch September 4, 2026 15:03
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.

2 participants