Skip to content

Replace a pane-exported HERDR_BIN_PATH with the bundled herdr in the packaged app - #242

Merged
yansfil merged 6 commits into
mainfrom
fix/desktop-herdr-bin-path
Sep 28, 2026
Merged

yansfil merged 6 commits into
mainfrom
fix/desktop-herdr-bin-path

Conversation

@yansfil

@yansfil yansfil commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #214

A packaged app opened from a Herdr pane (open /Applications/hide.app) inherited the HERDR_BIN_PATH Herdr exports into every pane.
That path dies when the bundle that started the server is replaced, so hide connect refused it as start_failed on every attempt and the window never attached.
The packaged host now treats an inherited HERDR_BIN_PATH as an explicit override only when it arrives without HERDR_PANE_ID.
With HERDR_PANE_ID it is Herdr's own export, and the host hands its bundled herdr to every hide child instead, logging the replaced path as replaced_pane_herdr.
An unpackaged host still passes whatever it inherited; the rule lives in desktop/src/main/herdr.ts and docs/ARCHITECTURE.md (The desktop host).

Same launch, same stale pane environment (HERDR_PANE_ID set, HERDR_BIN_PATH naming a missing herdr-runtime/herdr). Before: "hided could not start". After: attached, and the fixture pane's terminal attaches through the bundled herdr.

Before After
before after

Review

  • Please judge: the issue offered two fixes; this takes "ignore the pane-exported value", not "show the refusal on screen". Is that the right call?
  • Please judge: HERDR_BIN_PATH=/x open hide.app typed inside a pane cannot be told apart from Herdr's export and is replaced too (documented).
  • Files to watch: desktop/src/main/host.ts - failure path: childEnvironment spreads the chosen herdr after the inherited env, so the replacement wins.
  • Files to watch: desktop/src/main/env.ts - the env registry now reads HERDR_PANE_ID (presence only).
  • Question: other pane keys (HERDR_SOCKET_PATH, pane/tab/workspace ids, HERDR_ENV) still reach hide and the daemon; none blocks attach. Worth a follow-up issue?

Evidence

  • Confirmed: chooseHerdr unit tests, one per branch (bundled, override, pane replaced, pane already bundled, unpackaged); desktop 48/48.
  • Confirmed: a packaged app built from this branch's debug binaries with @electron/packager, launched with a stale HERDR_BIN_PATH + HERDR_PANE_ID against a private Herdr server.
    • Before: herdr:"inherited", then discovery.failed start_failed.
    • After: herdr:"bundled", replaced_pane_herdr set, discovery.attached, core terminal.session_ready for the pane.
  • Confirmed: scripts/verify-web.sh passes (hcoord, web and desktop typecheck/lint/test/build); identity and attribution checks pass.
  • Confirmed: pnpm --dir desktop e2e: 18 passed, 1 skipped, 1 failed.
  • Not confirmed: browser.spec.ts:465 (zoom of a focused page) fails on this unattended machine. It fails the same way with origin/main's desktop source, and e2e runs unpackaged, where herdr resolution is unchanged.
  • Not confirmed: the real /Applications/hide.app was not replaced or relaunched (operator's copy); no release build was made.

AI tooling: Mostly AI tooling; the rule was checked against the before/after launch logs and screenshots of a real packaged build.

…packaged app

A packaged app opened from a Herdr pane inherited the HERDR_BIN_PATH Herdr
exports into every pane. That path dies when the bundle that started the
server is replaced, so hide connect refused it as start_failed on every
attempt and the window never attached.

An inherited HERDR_BIN_PATH is now an explicit override only when it arrives
without HERDR_PANE_ID. With HERDR_PANE_ID it is Herdr's own export, and the
packaged host hands its bundled herdr to every hide child instead, recording
the replaced path as replaced_pane_herdr on discovery.start. An unpackaged
host still passes whatever it inherited.
…ement only when the value differed

The install guide, the agent notes and the env registry comment still
described the old pass-through rule; the packaged app now replaces a pane
value, while the hide CLI run in a pane and an unpackaged host still
inherit it. A pane value that already names the bundled herdr is no longer
recorded as replaced.
git commit starts a detached git maintenance run --auto, which can pack
and prune the fixture's loose objects while the next git clone --bare is
still copying them, failing a random clone test with "failed to copy file
to ...: No such file or directory" on the hosted macOS runner. The
fixture's git calls now turn auto maintenance and auto gc off.
The core's clone tests build their bare repository the same way, commit
then a local git clone --bare, so they carry the same race. Both comments
now say which setting carries the fix.
@yansfil
yansfil merged commit ffe8499 into main Sep 28, 2026
7 checks passed
@yansfil
yansfil deleted the fix/desktop-herdr-bin-path branch September 28, 2026 11:29
yansfil added a commit that referenced this pull request Sep 28, 2026
…one test fixtures (#245)

Related: 2a8e6d1 is on `feat/overview-lenses` (#238); the maintenance
guard was found while working on #242. This lands both on `main`.

## Summary

- The clone test fixtures (`hide-host/tests/clone.rs`,
`herdr-core/src/runtime/tests/repository_clone.rs`) commit, then run a
local `git clone --bare`.
- `git commit` starts a detached `git maintenance run --auto`, which can
pack and prune loose objects while the clone is still copying them.
- On macOS CI runners this fails a random clone test with "failed to
copy file ... No such file or directory" in the fixture, before the code
under test runs.
- Tonight it failed the `rust workspace` lane of #242 (twice), #243 and
#244, always at `clone.rs:24`.
- The fixtures' `git` calls now turn off auto maintenance and auto gc,
and the bare origin is cloned with `--no-local` (a pack through Git's
transport, no file copy). Test-only.

## Review

- **Please decide**: whether landing this on `main` before #238 is fine;
2a8e6d1 is identical to the commit on `feat/overview-lenses`, so #238
merges over it cleanly.
- **Files to watch**: `herdr-core/src/runtime/tests/repository_clone.rs`
- preventive: the same fixture shape, not observed failing.

## Evidence

- **Confirmed**: `cargo test -p hide-host --test clone` passes 5/5
locally; the hide-host race reproduced locally under forced background
gc before the maintenance guard and not after (measured while working on
#242).
- **Not confirmed**: the flake rate on CI after the change beyond this
PR's own runs; the herdr-core fixture never reproduced.

**AI tooling**: mostly AI tools; the diff is three cherry-picked
commits, compared by hand.
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.

The packaged app launched from a Herdr pane inherits a stale HERDR_BIN_PATH and never attaches

1 participant