Commit Graph

25 Commits

Author SHA1 Message Date
Michał Pierzchała 9e165114c0 perf: optimize rslib startup build (#803) 2026-06-15 08:51:47 +02:00
Michał Pierzchała b8172e3da3 perf(daemon): offload PNG decode/encode and screenshot diff to a worker thread (#734)
* perf(daemon): offload PNG decode/encode and screenshot pixel diff to a worker thread

PNG decode (inflateSync) and per-pixel screenshot diffing previously ran
synchronously on the daemon event loop, stalling all concurrent sessions
while multi-MB screenshots were processed.

- add src/utils/png-worker.ts worker_threads entry (rslib internal/png-worker)
  handling one decode, encode, or diff-pixels job per message
- add src/utils/png-worker-client.ts async wrappers (decodePngAsync,
  encodePngAsync, computeScreenshotDiffPixelsAsync) that lazily spawn the
  worker, resolve it next to the current module in dev (.ts) and dist (.js)
  like the companion tunnel entry, and fall back to the in-process
  synchronous path when the worker is unavailable
- extract the unchanged pixel-compare loop into
  src/utils/screenshot-diff-pixels.ts so both paths share identical logic
- route daemon call sites (screenshot-overlay annotate, compareScreenshots)
  through the async wrappers; results stay byte-identical

https://claude.ai/code/session_01LXZXzxi55sZ11DSyqWyBA2

* refactor(daemon): apply review findings to PNG worker offload

- guard postMessage failures: a job-specific send error (e.g. DataCloneError)
  now cleans up its pending entry and falls back to sync for that call only
- resolve the worker entry via a shared src/utils/internal-entry.ts helper
  that returns null on any resolution failure (non-file import.meta.url)
- match repo precedent: spawn the worker with --experimental-strip-types
  when the resolved entry is a .ts module
- report permanent worker degradation once (scoped diagnostic + process
  warning with the failure reason) instead of silently going sync-only
- daemon lifecycle: pre-warm the worker at startup and terminate it during
  shutdown with a 1s best-effort timeout (daemon-only)
- collapse the three async wrappers onto one kind-typed job runner with a
  single unavailability channel (rejection, no null path) and drop the dead
  mismatched-result guards
- derive the diff-pixels contract types from screenshot-diff-pixels.ts and
  share toBuffer via the contract module
- serialize worker errors with normalizeError and reconstruct AppError
  (code/message/details) client-side; the worker reuses decodePng so decode
  failures are identical on both paths
- transfer result buffers back to the client when a view fully owns its
  ArrayBuffer; clone pooled buffers to protect Node's shared buffer pool
- decode baseline/current screenshots concurrently in compareScreenshots
- move resizePngFileToMaxSize to src/utils/png-resize.ts and route its
  decode/encode through the worker (daemon screenshot --max-size path)

https://claude.ai/code/session_01LXZXzxi55sZ11DSyqWyBA2

* fix(fallow): declare png worker entry and simplify resultTransferList

The Fallow audit flagged src/utils/png-worker.ts as unreachable from any
entry point and resultTransferList as over the complexity threshold.

- Declare src/utils/png-worker.ts in .fallowrc.json's entry list: it is a
  worker_threads entry point loaded at runtime (mirrors src/daemon.ts /
  src/companion-tunnel.ts and the internal/png-worker rslib entry).
- Flatten resultTransferList into filter/map over an extracted
  ownsEntireArrayBuffer predicate, preserving the exact transfer rule
  (byteOffset === 0, byteLength === owner.byteLength, real ArrayBuffer).
- Add direct unit coverage asserting fully-owned buffers are transferred
  while pooled/offset views are not.

https://claude.ai/code/session_01LXZXzxi55sZ11DSyqWyBA2

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-06-10 12:27:44 +02:00
Michał Pierzchała 8aa4abe465 feat: expand android adb provider boundary (#481) 2026-04-29 21:45:42 -04:00
Michał Pierzchała fea7a5b73f feat: expose daemon embedding and Android ADB APIs (#480) 2026-04-29 19:18:17 -04:00
Michał Pierzchała 72ba612e83 fix: centralize Android adb execution (#478) 2026-04-29 18:25:21 -04:00
Michał Pierzchała 6a2bf9f626 feat: export batch orchestration helpers (#472) 2026-04-29 10:48:17 -04:00
Michał Pierzchała d77a9211ab feat: add Android snapshot helper (#454)
* feat: add android snapshot helper

* fix: harden android snapshot helper packaging

* fix: harden android xml attribute parsing

* fix: capture android helper window roots

* fix: validate android helper install args

* fix: harden android helper manifest and traversal

* refactor: drop unused helper timeout parameter

* feat: bundle android snapshot helper in npm package

* feat: enable bundled android snapshot helper by default

* refactor: simplify android snapshot helper resolution

* fix: harden android snapshot helper artifacts

* refactor: split android snapshot helper modules

* fix: use type-only snapshot helper imports
2026-04-27 16:01:37 -04:00
Michał Pierzchała 2e2b9af8c3 chore: drop hosted runtime entrypoints (#448) 2026-04-26 12:02:13 -04:00
Michał Pierzchała 53750084a7 refactor: finish companion tunnel naming (#446) 2026-04-26 11:42:30 -04:00
Michał Pierzchała 3645479454 feat: export observability helpers (#444) 2026-04-25 20:24:01 -04:00
Michał Pierzchała add43ec4f4 fix: prevent rslib publish chunk collisions (#423) 2026-04-17 12:51:34 +02:00
Michał Pierzchała 8bcefb754a feat: add runtime command boundary (#412)
* feat: add runtime command boundary

* refactor: harden runtime command boundary

* fix: address runtime boundary review

* fix: preserve selector snapshot flags

* fix: preserve selector get and screenshot cleanup

* fix: harden runtime boundary follow-ups

* fix: close runtime parity gaps

* test: harden android replay navigation

* fix: close screenshot surface edge cases

* test: harden packaged runtime API smoke

* fix: close runtime review edge cases

* test: isolate CLI state dir in unit helpers
2026-04-16 13:03:31 +02:00
Michał Pierzchała 39a09f95c4 feat: export Android app parsers (#406) 2026-04-13 14:11:53 +02:00
Michał Pierzchała f4f143ced7 fix: restore helper subpath exports (#402)
* fix: restore helper subpath exports

* fix: polish helper subpath typings
2026-04-11 22:16:32 +02:00
Michał Pierzchała 8e42f2e654 fix: harden public API boundaries (#399) 2026-04-11 21:01:09 +02:00
Michał Pierzchała 037caf749f feat: export artifact package resolver (#392) 2026-04-11 20:02:14 +02:00
Michał Pierzchała 0b76783360 feat: export install-source helpers (#393)
* feat: export install-source helpers

* fix: freeze exported archive extensions
2026-04-11 20:00:38 +02:00
Michał Pierzchała 966fcb2547 feat: export finder helpers (#391) 2026-04-11 19:51:30 +02:00
Michał Pierzchała 6cf63c262c feat: expose selector helper subpath (#384) 2026-04-11 19:07:42 +02:00
Michał Pierzchała 66d65c887c refactor: expose metro and remote config node apis (#372)
* refactor: expose metro and remote config node apis

* refactor: tighten public node api surface

* refactor: tighten metro public type boundaries

* refactor: normalize remote config public profile

* refactor: make remote config parser library-owned

* refactor: share remote config parsing primitives

* refactor: avoid regex in base url normalization
2026-04-10 13:03:13 +02:00
Michał Pierzchała a4d686e686 fix: package detached worker entrypoints (#371)
* fix: package detached worker entrypoints

* refactor: rename metro companion worker entry

* chore: trim packaged smoke logging
2026-04-10 11:45:20 +02:00
Michał Pierzchała 05a822455c chore: publish bundled public type declarations (#262)
* chore: publish bundled public type declarations

* chore: keep package root exports value-only
2026-03-25 18:40:36 +01:00
Michał Pierzchała 34b9579b51 Add typed TypeScript daemon client (#218)
* feat: add typed daemon client

* chore: tighten client package exports

* fix: preserve open and screenshot cli flags

* feat: expose runtime open and install-source client flows

* feat: expose retained materialization paths in client

* feat: complete typed client cleanup

* fix: fall back to XML plist parsing
2026-03-14 14:19:16 +01:00
Michał Pierzchała 2237c78440 chore: use esnext when bundling 2026-02-17 12:07:23 +01:00
Michał Pierzchała 4da4745a6c initial commit 2026-01-30 19:41:00 +01:00