fix: prevent bridge glance observation hangs - #89
Merged
Conversation
The snapshot child PATH omitted ~/.local/bin and nvm, so a missing herdr CLI triggered a 10s server-start poll per live task and /api/observation timed out. Fail that check immediately, resolve tool dirs at server start, replace eternal Loading with the unreachable-desk state, and keep today's photo count on 503. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Fix the Starship bridge glance page so the captain's phone never stays stuck on Loading. Field state: all four buckets showed Loading and /api/observation returned 503 bearings snapshot timed out on every call. The snapshot completed in about 2.6s with a full user environment but hung with zero output under the bridge server's scrubbed child environment (PATH limited to system dirs, no ~/.local/bin or nvm). Diagnose the hanging step and fix both layers: (1) Server: make the child environment sufficient by resolving needed tool dirs at server start from HOME and the real environment rather than hardcoding a version-specific nvm path, keep the env scrubbed otherwise with no secrets/vars leakage, and make the snapshot path fail fast when a required tool is missing (no silent hangs; a clear error within seconds). The live hang was herdr missing from the child PATH: every in-flight task is Herdr, and pane capture called server_ensure which backgrounded a missing herdr binary and polled 10s per task. Fail that immediately and use the read-only target existence check so observation never starts a herdr server. (2) Client: when /api/observation returns an error or the fetch fails, buckets must show the honest cannot-reach-the-desk state per the original design, never eternal Loading. A first failed observation overlays immediately; the 90s overlay remains only after a successful load if refreshes later stop. (3) Photo counter: Photos received today showed 0 right after real uploads landed in data/bridge-inbox; count today's sidecars correctly (UTC received_at, filename-date fallback) and still return photos_today on 503 so the counter does not depend on glance data loading. (4) Tests: scrubbed-env-shaped observation succeeds or fails fast with an honest error; client error-state rendering; counter counts today's sidecars correctly. Do not use --yes. After CI is green, report the PR URL.
What Changed
PATH, fail immediately when Herdr is unavailable, and keep passive observation from starting a Herdr server.received_ator filename fallback, return the count on 503 responses, and add executable regression coverage and documentation for these behaviors.Risk Assessment
✅ Low: The incremental commit closes the prior gap by executing the actual page script in a dependency-free Node VM and verifying the initial 503 transition, all four bucket states, overlay activation, and photo counter; the complete change remains well-bounded and conforms to the stated intent.
Testing
Both relevant automated suites passed, including scrubbed-environment PATH discovery, immediate missing-Herdr failure, client error rendering, and UTC/fallback photo counting. A live authenticated browser check confirmed all four buckets immediately showed “Cannot reach the desk” instead of “Loading,” the overlay appeared, and the 503-backed counter still showed two photos.
/var/folders/1g/hctp3vpn27b1zrlsn4nsfg680000gn/T/no-mistakes-evidence/01M0DGGN382KPB8DXTWWDMV4JZ/bridge-unreachable.png)Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
tests/fm-bridge-view.test.sh:1058- The required criterion “Tests: client error-state rendering” is not actually exercised. This test only checks that the served HTML containsmarkBucketsUnreachableandlet lastSuccess = 0; it never executesrefresh()with a failed fetch or asserts the resulting bucket/overlay DOM state, so broken or unreachable error-handling code could still pass. Add an executable client test that simulates the initial observation failure and verifies the rendered state.🔧 Fix: Exercise client error rendering with executable DOM test
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
Inspectedgit diff --stat 335876759482e4b1105d122326b5fb2710da1f56..2875a8301ef1d0dd9a8603bd7e167c39f5a6548fand target-specific tests.bash tests/fm-bridge-view.test.shbash tests/fm-backend-herdr.test.shStarted an authenticated bridge with a snapshot fixture that immediately reports missingherdr, then openedhttp://bridge.localhost:18766/in Chrome and captured the rendered failure state.Verifiedgit status --shortafter testing.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.