You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(relay): ask the page's own origin before saying the device is offline where no account service is - #4900
#4810 made a phone or browser that says navigator.onLine === false ask the account service before the screen believes it. A page with no account service still believed the flag alone: a hosted app built with OVIS_ACCOUNT_SERVICE_URL=off (no ovis-account-service meta) showed "This device is not connected to the internet" and refused every open on a working network whenever the browser said so.
src/lib/useOffline.ts: checkNetwork() now asks the page's own origin, /api/health, when there is no account service. The ask is the same one as before: one no-cors, no-store request, 8 s limit, and any answer counts. The service worker never answers /api/ (public/sw.js), so only the network can answer. Inside the phone app the flag still decides alone, as it did before this change: the app answers its own origin itself, with or without a network (Android's BundledShell serves every path of app.ovis.sh locally, 404 included), so its answer would prove nothing.
src/components/RelayShellScreens.tsx, src/components/ConnectStart.tsx: the hold a relay row puts on a click while the device says it is offline is now followUnlessOffline() in useOffline.ts. The accountless Your PCs row, which followed its link without asking, uses it too; with no answer, the offline line above the list says so (no new text). confirmOffline() now waits for an ask that replaced its own (Try again during a tap), so the tap goes on with that answer instead of staying shut.
src/conventions.test.ts: navigator.onLine is read only in src/lib/useOffline.ts and src/lib/ws.ts, so a new screen cannot go back to trusting the flag alone.
No new strings, controls, layout or HTTP/WS fields. What a "yes" from the page's own host proves is narrower than an answer from the account service: a network that reaches the shell's host and nothing else counts as online, and the open then fails with its own error. That is the same trade #4810 accepted for the account service.
Reviews
The omo gate review and one Codex adversarial review ran on 2a6471478c. This push (71a4ba7332) addresses them:
(HIGH, gate) The accountless Your PCs row opened without a fresh ask: it now holds the click as the account rows do. It never checked on main either.
(MEDIUM, gate and Codex) Try again during a tap left the PC shut: the tap now waits for the ask that replaced its own.
(LOW, Codex) The test's answers are now 404s, so any answer counts, as on a static host.
(LOW) The fixture's origin is app.ovis.sh only. The conventions lock does not catch navigator["onLine"] or destructuring.
Validation
src/components/RelayShell.test.tsx: the fix(relay): ask the account service before saying the device is offline #4810 test now runs twice, once with an account service and once without. In the second run the screen asks https://app.ovis.sh/api/health. No answer (the ask's timeout) shows the offline line, Try again's answer takes it away, a tap asks again and opens the PC once it answers, and a later unanswered tap says the device is offline and opens nothing. "Says this device, in a browser, and opens nothing while it is offline" now stubs fetch as a dropped network: every ask fails, the screen asked only its own origin, and nothing opened. Both no-account-service cases fail on main (no ask is made). The account-service case and the two phone-app cases pass unchanged.
The new conventions test fails when a navigator?.onLine read is added to src/lib/nativeApp.ts. The first version of its pattern matched a prop named onLine in RepoDiff.tsx, so it is now navigator.onLine only.
bun test src/components/RelayShell.test.tsx src/conventions.test.ts src/lib/ws.test.ts src/components/ConnectStart*: 304 pass, 0 fail. bun run typecheck: ok.
bun run check fast: ok (typecheck, build, unit tests: 29428 pass, 0 fail).
Browser: relay-offline-reasons-regression, relay-shell-browser-qa, relay-e2e-regression, relay-first-link-regression, add-pc-more-relay-regression, relay-account-pcs-regression: 6/6 pass on bun run check run at 2a6471478c. At 71a4ba7332 all six pass too, two of them only on the second try: on the first, the test herdr answered "server is shutting down" before any page loaded.
Skipped: the Android emulator run with CDP forcing onLine=false. Every shipped phone build carries the account service meta, so this change does not run in the app (the app keeps the flag, see above).
…line where no account service is
A hosted shell built with OVIS_ACCOUNT_SERVICE_URL=off has no account service to ask, so it believed navigator.onLine === false alone and refused every open. checkNetwork now asks the page's own origin under /api/ (which the service worker does not answer) with the same one no-cors, no-store ask and 8 s limit. The phone app answers its own origin itself, so there the flag still stands.
Auto incremental reviews are disabled on this repository.
Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Summary
Summary by CodeRabbit
Bug Fixes
Hosted apps without an account service now check their own health endpoint before deciding whether to open a PC, instead of relying only on the browser’s offline status.
If the health check fails or times out, the offline message is shown and relay-row navigation is blocked. Navigation proceeds once the check succeeds.
When the browser reports offline, checkNetwork now checks the configured account service or, for hosted apps without one, the page’s /api/health endpoint. Native apps without an account service make no request. Tests cover health-check results and relay navigation.
Changes: Offline network checks
Layer / File(s)
Summary
Select and verify the health-check destination src/lib/useOffline.ts, src/components/RelayShell.test.tsx, src/conventions.test.ts, changelog.d/offline-line-asks-own-origin.md
checkNetwork uses the configured account-service URL or the page-origin /api/health endpoint. A native app without an account service clears the answered state without a request. Tests cover both configurations, timeout behavior, offline messaging, and blocked relay navigation. A convention test restricts navigator.onLine reads in client code.
Hosted shells built without an account service now check their own origin before refusing to open a PC while the browser reports offline. Phone app behavior is unchanged. No concrete merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: when no account service is configured, the relay asks the page's own origin before reporting the device offline. The changeset adds this /api/health check in src/lib/u…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The description follows the template. It has a Change section that explains the problem (a page without an account service trusted navigator.onLine alone), the resulting behavior (checkNetwork asks /a…
Full details: Title check
Explanation
The title names the main change: when no account service is configured, the relay asks the page's own origin before reporting the device offline. The changeset adds this /api/health check in src/lib/useOffline.ts, with matching tests and a convention test. The title is specific and matches the change.
Full details: Description check
Explanation
The description follows the template. It has a Change section that explains the problem (a page without an account service trusted navigator.onLine alone), the resulting behavior (checkNetwork asks /api/health, the phone app keeps the flag), and the files touched. It has a Validation section that lists the commands run (bun test subset, bun run typecheck, bun run check fast, six browser regression checks) and the one skipped check (Android emulator run) with a reason. The Change section does not link an issue, but this is a fix to an earlier PR (#4810) and the template asks for a link only for features, so this is not required here.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between 1d88a2d and 2a64714.
Files selected for processing: 4
changelog.d/offline-line-asks-own-origin.md
src/components/RelayShell.test.tsx
src/conventions.test.ts
src/lib/useOffline.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.
… wait for Try again's answer
Review round: the accountless Your PCs row followed its link without asking, and a tap whose ask Try again replaced read the old answer and stayed shut. The ConnectStart rows' hold moves to followUnlessOffline in useOffline.ts, which the accountless row uses too, and confirmOffline waits for the ask that replaced its own.
Merged through pr-merge at head 4f25fb665. Seen before the merge was asked for: required checks green, no unresolved thread, no conflict, no hold, main not red, no release in progress. CodeRabbit finished, with no review that names this head.
main had moved since the checks of 71a4ba733: pr-merge --update merged it in (d1c1355e6), and every required check was green at this head.
It waited in the merge queue behind #4896, whose change overlaps it, before it was updated.
omo gate review and one Codex adversarial review (gpt-6.2-sol-fast, xhigh) ran on 2a64714; the one fix round 71a4ba7 addresses the HIGH and both MEDIUMs (see PR body). Merged on the lane lead's go for plan step A1. CodeRabbit did not review this head.
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
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.
Change
#4810 made a phone or browser that says
navigator.onLine === falseask the account service before the screen believes it. A page with no account service still believed the flag alone: a hosted app built withOVIS_ACCOUNT_SERVICE_URL=off(noovis-account-servicemeta) showed "This device is not connected to the internet" and refused every open on a working network whenever the browser said so.src/lib/useOffline.ts:checkNetwork()now asks the page's own origin,/api/health, when there is no account service. The ask is the same one as before: oneno-cors,no-storerequest, 8 s limit, and any answer counts. The service worker never answers/api/(public/sw.js), so only the network can answer. Inside the phone app the flag still decides alone, as it did before this change: the app answers its own origin itself, with or without a network (Android'sBundledShellserves every path ofapp.ovis.shlocally, 404 included), so its answer would prove nothing.src/components/RelayShellScreens.tsx,src/components/ConnectStart.tsx: the hold a relay row puts on a click while the device says it is offline is nowfollowUnlessOffline()inuseOffline.ts. The accountless Your PCs row, which followed its link without asking, uses it too; with no answer, the offline line above the list says so (no new text).confirmOffline()now waits for an ask that replaced its own (Try again during a tap), so the tap goes on with that answer instead of staying shut.src/conventions.test.ts:navigator.onLineis read only insrc/lib/useOffline.tsandsrc/lib/ws.ts, so a new screen cannot go back to trusting the flag alone.No new strings, controls, layout or HTTP/WS fields. What a "yes" from the page's own host proves is narrower than an answer from the account service: a network that reaches the shell's host and nothing else counts as online, and the open then fails with its own error. That is the same trade #4810 accepted for the account service.
Reviews
The omo gate review and one Codex adversarial review ran on
2a6471478c. This push (71a4ba7332) addresses them:Not changed:
navigator["onLine"]or destructuring.Validation
src/components/RelayShell.test.tsx: the fix(relay): ask the account service before saying the device is offline #4810 test now runs twice, once with an account service and once without. In the second run the screen askshttps://app.ovis.sh/api/health. No answer (the ask's timeout) shows the offline line, Try again's answer takes it away, a tap asks again and opens the PC once it answers, and a later unanswered tap says the device is offline and opens nothing. "Says this device, in a browser, and opens nothing while it is offline" now stubsfetchas a dropped network: every ask fails, the screen asked only its own origin, and nothing opened. Both no-account-service cases fail on main (no ask is made). The account-service case and the two phone-app cases pass unchanged.navigator?.onLineread is added tosrc/lib/nativeApp.ts. The first version of its pattern matched a prop namedonLineinRepoDiff.tsx, so it is nownavigator.onLineonly.RelayShellScreens.tsx, and the Try-again-during-a-tap step fails without theconfirmOfflinewait (in both runs of the fix(relay): ask the account service before saying the device is offline #4810 test).bun test src/components/RelayShell.test.tsx src/conventions.test.ts src/lib/ws.test.ts src/components/ConnectStart*: 304 pass, 0 fail.bun run typecheck: ok.bun run check fast: ok (typecheck, build, unit tests: 29428 pass, 0 fail).relay-offline-reasons-regression,relay-shell-browser-qa,relay-e2e-regression,relay-first-link-regression,add-pc-more-relay-regression,relay-account-pcs-regression: 6/6 pass onbun run check runat2a6471478c. At71a4ba7332all six pass too, two of them only on the second try: on the first, the test herdr answered "server is shutting down" before any page loaded.onLine=false. Every shipped phone build carries the account service meta, so this change does not run in the app (the app keeps the flag, see above).