fix(desktop): spawn managed agents with the configured relay URL - #3484
fix(desktop): spawn managed agents with the configured relay URL#3484JHSeo-git wants to merge 1 commit into
Conversation
Relay tenancy is derived from the HTTP Host header, but the managed-agent spawn path handed the child the canonical runtime-key relay URL, whose normalization rewrites loopback spellings to 127.0.0.1. Against a local relay joined as ws://localhost:3000, every harness therefore connected to the empty 127.0.0.1:3000 community, discovered 0 channels, and never saw a mention while the UI showed the agent stuck on Waking. Spawn now hands the child the caller's configured relay URL (BUZZ_RELAY_URL and the git-credential scope) through a small child_connect_relay_url seam, and every path that reaches spawn passes the configured spelling through: start_pair, launch restore, ensure-running, the reconcile fan-out, and the relay-access probe (which now probes the requested authority). start_pair also fills requested_relay_url in its status rows so the frontend's requestedRelayUrl fallback re-dials the configured URL on restart. The canonical form remains the identity for runtime keys, receipts, log paths, and the spawn-config hash: status_for recomputes that hash from key.relay_url, so hashing the configured spelling would read as permanent drift and flag a spurious restart. Signed-off-by: JHSeo <qnfqnfqnf@gmail.com>
556d776 to
cb11965
Compare
|
Independent verification on Linux — this PR fixes #2444 for me. Prior reports were macOS (0.4.23 DMG) and a Symptom was worse than "agents don't respond": onboarding never completes. On a fresh install the app hangs permanently on the final onboarding step, "meet your starter team". There is no error, no failed request, and no timeout — the step simply never resolves, because it waits on starter-team agents that are connecting to a different community. The state is also persistent: quitting and relaunching returns straight to the frozen step, so the app is unusable until localStorage is cleared manually. #2444 describes agents going silent in an established workspace; this is the same root cause blocking first-run entirely. Environment
Reproduction
Result: hangs at "meet your starter team" indefinitely. Evidence it is the loopback tenant split The dev database seeds a community row per loopback spelling, which makes the split directly observable. Before the patch, everything the UI wrote landed under After applying this PR (applies cleanly to 19d57b0) and joining as Onboarding completes and the starter team appears. Why this took a long time to diagnose Every check said the stack was healthy. The relay passed The tenancy mismatch has no error path anywhere, so the only visible signal is a UI step that never finishes. One measurable symptom, if it helps others identify this While stuck, Worth stating explicitly so nobody chases it as a rendering bug: it is not WebKitGTK. I initially suspected #3654 (NVIDIA + One adjacent note on relay URL entry For a plaintext local relay you must type the scheme explicitly. A scheme-less entry (
|
Summary
On a local relay, desktop-managed agents silently never respond: the relay derives the community boundary from the HTTP Host header, but every managed-agent spawn path handed the child
ManagedAgentRuntimeKey.relay_url— the canonical identity form, whose normalization folds every loopback spelling to127.0.0.1. With a community configured asws://localhost:3000, the UI writes all channels, memberships, and messages into thelocalhost:3000community while every agent connects to the empty127.0.0.1:3000community. Each harness logsdiscovered 0 channel(s)/no channel subscriptions resolved — agent will sit idle, the member list shows the agent stuck on "Waking", and mentions are never answered. No error surfaces anywhere.This also violates the contract documented on
buzz_core::relay::normalize_relay_urlitself:Related issue
Fixes #2444. Same root cause family as #3283 (loopback tenant split on the seed side). Closest existing PR: #2446 — same diagnosis and direction; it now has merge conflicts against
mainand its description notes the missing automated regression test as an honest gap. This PR is rebased on currentmain, adds that regression coverage via a small testable seam, and additionally pins the spawn-config hash to the canonical form so restart-drift detection cannot false-positive. Happy to close this in favor of a revived #2446 if maintainers prefer — the test seam here grafts onto it cleanly.Fix
Keep the canonical form for identity only (runtime-map keys, receipts, log paths, spawn-config hash). Dial the configured URL everywhere a child or probe actually connects:
child_connect_relay_url(configured, key)— new seam inruntime.rsthat returns the configured URL for the child'sBUZZ_RELAY_URLand git-credential scope, with adebug_assertthat the configured URL canonicalizes to the runtime key's relay (callers cannot hand it a URL from a different pair).start_pair, launch restore, ensure-running) pass their already-resolved configured URL instead ofkey.relay_url.start_pairinstead of the canonical echo.probe_agent_relay_accessprobes over the requested authority, so spawn eligibility is checked against the same community the child will join.start_pairfillsrequested_relay_urlin its status rows, so the frontend's existingrequestedRelayUrl ?? relayUrlfallback re-dials the configured URL on restart.runtime_key.relay_url:status_forrecomputes that hash fromkey.relay_url, so hashing the configured spelling would read as permanent drift and flag a spurious restart on every status pass.Testing
child_connect_relay_url_preserves_configured_loopback_authority(canonical key isws://127.0.0.1:3000while the child still getsws://localhost:3000) andchild_connect_relay_url_is_identity_for_non_loopback_relays.just cipasses locally;cargo test --libon the Tauri crate: 1851 passed, 0 failed; clippy clean.discovered 0 channel(s)and never replied (memberships verified present in the relay DB, all events under thelocalhost:3000community while harnesses connected to127.0.0.1:3000); after the fix, each harness logsdiscovered 1 channel(s)and a mention in the Welcome channel gets an agent reply within ~50s.Follow-up candidates (out of scope here, discussed in #2444/#3283): collapsing loopback spellings into one community key on the relay side (#2619 explores this), and surfacing the agent-idle state in the UI instead of only in the harness log.