Repository navigation
fix(relay): keep a PC's file paths and panes out of app.ovis.sh requests - #2605
Conversation
In the hosted shell, the page's own query (a reader tab's ?read=, the app's ?ws=&pane=&file= address, an alert's cold start, Reconnect) rides in the URL fragment, which the browser never sends; a PC's own server keeps the query. An older address with a query is moved into the fragment on load and on Back. Refs #2599
…r pane Records every request (and its Referer) the Pages host receives while a PC file is opened in the app, in its own tab, as a raw file, after a followed link and reloads, and fails when any names the file, folder, workspace or pane.
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
| Layer / File(s) | Summary |
|---|---|
Query reading and legacy migration src/lib/pageQuery.ts, src/lib/relay/boot.ts, src/lib/pageQuery.test.ts, src/lib/relay/shellState.test.ts, docs/relay.md, changelog.d/relay-paths-stay-on-phone.md |
New helpers read and construct relay-mode fragment addresses. Relay boot moves legacy queries into fragments, including on Back navigation. Tests and documentation cover query migration and the information exposed by legacy query URLs. |
App navigation and reader addresses src/lib/fileReader.ts, src/lib/fileReader.test.ts, src/App.tsx, src/components/FileReader.tsx, src/components/PaneTerminal.tsx, src/lib/useAddressBar.ts, src/lib/useSelection.ts, src/main.tsx, src/lib/relay/resources.test.ts, scripts/relay-media-browser-qa.ts |
Deep-link parsing, address synchronization, selection targets, reader links, and reconnect links use page-query helpers or relay-mode fragment addresses. Tests cover reader-link parsing and fragment URLs. |
Notification URLs and browser QA public/sw.js, src/pwa-notification.test.ts, src/pwa.test.ts, scripts/pages-static.ts, scripts/relay-shell-browser-qa.ts |
Hosted-shell app-window detection and notification targets handle fragment parameters. Browser QA records host requests and checks file navigation and page queries. Notification tests cover hosted-shell fragment URLs. |
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related issues
- Native apps: open app.ovis.sh pairing links in the app, name relay PCs, keep file paths out of app.ovis.sh requests #2599 — This change moves relay file, workspace, and pane state into URL fragments. The issue’s native-app deep-link and relay-PC naming requests are not covered.
- Notification improvements #1490 — This change updates notification-click cold starts and hosted-shell target URLs, but does not implement alert replacement or clearing.
Merge Risk: 
Low · previous review af7f8
-
Modified Reconnect clicks behave unexpectedly, and older links can expose details before migration. The change is mergeable with those limitations understood.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Description check
-
Explanation
The description clearly explains the problem, changed behavior, affected components, privacy caveats, validation results, and skipped checks. It includes HTTP-related browser QA coverage, although it does not explicitly identify contract-test coverage.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 61.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 18 functions across 19 files. (2 skipped: 2 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
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.
# Conflicts: # docs/relay.md
Deploying ovis with
|
| Latest commit: |
791c614
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://eae0a6fd.ovis.pages.dev |
| Branch Preview URL: | https://fix-relay-path-leak.ovis.pages.dev |
…ay an old link's first load still sends its path reloadOnPlainClick (lib/pageQuery.ts) takes over only a plain left click in the hosted shell; Ctrl, Cmd, Shift, Alt and a middle click open or save the link as the browser does. The changelog now says a link saved from an older version still sends its path with its first load. Refs #2599
…r or its PC In the hosted shell an address that changes only its fragment loads nothing, so pasting a reader link into an app tab, or Back between a reader and an app entry, left the wrong page up, and a reader moved to another PC read the file from the old one. reloadWhenReaderChanges (lib/fileReader.ts) loads the page then; a step between files of one PC stays the reader's. relay-media-browser-qa opens each file as a load of its own and expects the copied #read= link. Refs #2599
|
Part 3 of #2599, on the owner's OK; #2599 stays open for its other two parts. Merge-pass review: client-only (no server, shared or contract change). In the hosted shell (app.ovis.sh) only, what a page shows (a reader tab's file, the app's workspace/pane/file, a tapped alert's pane, Reconnect) rides in the URL fragment, which the browser never sends, instead of the query; a PC's own server keeps the query exactly as before (pageQuery.ts pageSearch/pageAddress gate on shellMode() === "relay"). An older address with a query is still read, then moved into the fragment at boot and on Back/Forward (moveQueryToFragment), and docs/relay.md says that such an address still reaches the host once. The service worker's alert tap opens 791c614 drops #2600's caveat from the privacy policy (en, ko) and the store notes: app.ovis.sh now sees only the phone's address and the PC's relay ID; what a page shows stays in the fragment. CodeRabbit's two Minors were fixed in 41ff862: a Ctrl/Cmd/Shift/Alt or middle click on Reconnect is left to the browser (only a plain click replaces and reloads; unit test), and the changelog says a link saved from an older version still sends its path with its first load. 8f6f45c fixes a case CI's relay-e2e found that users could hit: in the hosted shell, pasting a reader link into an app tab, or Back/Forward between the reader and the app, changes only the fragment and loaded nothing. The page now reloads when a fragment-only step turns it from app into reader or back, or moves the reader to another PC (reloadWhenReaderChanges, relay mode only; a step between two places in the app, the pairing #offer= and the #auth= link don't reload); test fails first. CodeRabbit's check shows skipping on this head; the merge pass reviewed it. |
Part of #2599 (item 2). ## Problem `RelayService.offer()` built the pairing offer without `name`, so the phone app's connect screen listed a relay PC as its raw scope URL (`https://app.ovis.sh/s/<32 hex>/`), while a direct PC shows its host. `RelayOffer.name`, `relayLink()` and `HerdrShell.open` already use the name when it is there. ## Fix `offer()` sets `name` to this PC's name as Ovis lists it (`os.hostname()`, as in `server/machines.ts`), cut to the 64-character limit `RelayOffer` allows. The name travels in the `#offer=` fragment, so it never reaches app.ovis.sh or the relay. ## Not in this PR - Item 1 (open `app.ovis.sh/s/` links in the native app) needs an Android App Link (`autoVerify` intent-filter plus `/.well-known/assetlinks.json` with the Play signing key's SHA-256) and an iOS Universal Link (Associated Domains entitlement plus `apple-app-site-association` with the Team ID). Both need signing details and an Apple capability change from the maintainer, so they are left for a follow-up. - Item 3 (file path in the app.ovis.sh page address) was fixed by #2605. ## Validation - New test `names the PC in the relay offer as Ovis lists it` (`server/relay/service.contract.test.ts`) failed on main (`Received: undefined`) and passes with the fix. - `bun test server/relay/ shared/` - `bun run check fast`
Part of #2599 (item 2, for the pairing link added after #2759). ## Problem #2759 made `RelayService.offer()` (`POST /api/relay/offer`, the QR code) carry the PC's `name`, so the phone app lists a relay PC under its name instead of its scope URL. The code-less pairing link added later in #2696 (`RelayService.pairingLink()`, `POST /api/relay/link`, **Copy a link without a code**) still builds its offer without `name`. A phone that pairs from that link saves the PC as `https://app.ovis.sh/s/<32 hex>/` again, which is the gap #2599 item 2 describes. ## Fix Both offers take the name from one helper, `offerName()` in `server/relay/service.ts`: `os.hostname()` (the name Ovis lists the PC under, as in `server/machines.ts`), cut to the 64 characters `RelayOffer` allows, left out when empty. The name rides in the `#offer=` fragment, so it never reaches app.ovis.sh or the relay. The link holds no code either way. Its `name` is no more secret than the one the QR offer already carries. The code-less link has only shipped in betas (`v0.4.23-beta.6`), so this PR extends its unreleased `Added` fragment (`changelog.d/relay-pair-by-comparing-digits.md`) instead of adding a `Fixed` line for a feature the next release introduces. ## State of the other #2599 items on main (cbcb961) - Item 1 (open `app.ovis.sh/s/` links in the native apps) is still open. It needs an Android App Link (`autoVerify` intent-filter plus `/.well-known/assetlinks.json` with the Play signing key's SHA-256) and an iOS Universal Link (Associated Domains plus `apple-app-site-association` with the Team ID). That takes signing details and an Apple capability change from the maintainer, so this PR does not close the issue. - Item 3 (file path in the app.ovis.sh page address) was fixed by #2605: `readerHref()` goes through `pageAddress()`, which puts the query in the fragment in relay mode. ## Validation - New test `names the PC in the pairing link without a code as Ovis lists it` (`server/relay/service.contract.test.ts`) failed on main (`Expected: "<hostname>"`, `Received: undefined`) and passes with the fix. - `bun test server/relay/service.contract.test.ts server/relay/pair-sas.contract.test.ts server/dispatch.test.ts`: 67 pass, 0 fail. - `bun run check fast` ran on the code and test change: all steps ok (unit: 11427 pass, 0 fail, 45 skip). The changelog fragment was edited afterwards and checked with `bun test scripts/changelog-fold.test.ts` (12 pass). - Skipped: `bun run check full`, browser and native-app runs. The change is server-side only, in an offer the existing client paths (`relayLink()` in `app/web/shell.js`, `src/lib/relay/shell.tsx`) already read `name` from. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Part of #2599 (item 1, the Android half). Items 2 and 3 already landed: #2759 and #2868 put the PC's name in both pairing offers, and #2605 moved the file path out of app.ovis.sh requests. ## Problem A relay pairing link (`https://app.ovis.sh/s/<server_id>/#offer=...`) tapped outside the app, in a message or read from the PC's QR code by the phone's camera, opens in the browser as the hosted web app. The Android app never sees it, because its manifest declares no `VIEW` filter for `https://app.ovis.sh/s/` and app.ovis.sh serves no `/.well-known/assetlinks.json`. ## Change - **Hosted shell** (`scripts/shell-build.ts`): `dist-shell/` now carries `/.well-known/assetlinks.json` and `/.well-known/apple-app-site-association`, sent as `application/json` (`_headers`). The asset links name `sh.ovis.app` with two certificates: Google Play's app signing key (copied from Play Console, App integrity, which signs every copy Play installs) and the upload key (read from the certificate in the uploaded 1.0 (4) bundle, which signs a release build installed by hand). The Apple file names `5987KT43TJ.sh.ovis.app` for `/s/*` only. The front page `/` stays the web app's. - **Android manifest**: an `autoVerify` intent-filter for `https://app.ovis.sh` with path prefix `/s/`. - **`MainActivity`**: only a link to a PC's scope (`/s/<32 hex>/`, port 443 or none) is taken (`PCStore.appLink`); any other page of app.ovis.sh leaves the open page alone. A link to pair from (the scope alone or with its `#offer=`) is taken out of its intent, kept in memory (`PCStore.link`) and shows the connect screen, both at a cold start and while a PC is open (`onNewIntent` starts the activity again, as Change PC does). A view of a PC (a file's `#read=`, a pane's `#pane=`, an older `?pane=`) opens that PC at that view when the app has it saved, as the browser did, and otherwise leaves the open page alone. A link the system hands back when the activity is restored or started from Recents is not opened again. - **`HerdrShellPlugin.takeLink`**: hands the pending link out once, and never in an activity that shows a PC: a PC's page has the bridge too and must not take another PC's pairing link. - **Connect screen** (`app/web/connect.js`): on Android it takes the link once (`HerdrShell.takeLink`), fills the address field with it and opens it through the same `open()` as a scanned QR code, so `relayLink()` checks the offer the same way and shows the same errors. The link is opened without another tap, as a scanned QR code is: tapping it is the user's action, and the hosted web app already pairs from the same link in the browser. ## What needs a new native build, and what does not - No native build: the two `.well-known` files. They go live when a release deploys the hosted shell (`release.yml` deploys `dist-shell` to Pages; Wrangler uploads `.well-known/`, its ignore list covers only `_worker.js`, `_redirects`, `_headers`, `_routes.json`, `functions` and VCS folders). - Android build: the intent-filter, `MainActivity`, `HerdrShellPlugin.takeLink` and `connect.js` ship in the app's bundle, so they reach users with the next Play build. Android verifies the link at install, so the order of the two does not matter: until both are out, such links keep opening in the browser. - iOS (not in this PR): the Associated Domains capability (`applinks:app.ovis.sh`) has to be turned on for the App ID in the Apple developer account first; adding the entitlement before that would break the next iOS build's signing. After that, the entitlement and a handler in `SceneDelegate`/`HerdrBridgeViewController` follow this same path. The `apple-app-site-association` file served here is what that step needs, so #2599 stays open for it. ## Validation - `bun test scripts/shell-build.test.ts`: the new tests failed on `origin/main` (`Export named 'ANDROID_APP_FINGERPRINTS' not found`) and pass now (17 pass). They check both files against the Android manifest's filter and `app/capacitor.config.json`'s id. - `./gradlew :app:testDebugUnitTest` (JDK 21): `PCStoreTest` 19 pass, 0 fail. The first version of the new link test failed (1 of 18) with the host check removed. - `./gradlew :app:assembleDebug`, then the APK on an Android 15 (API 35) emulator. `pm get-app-links sh.ovis.app` lists `app.ovis.sh` (state `none`: the live app.ovis.sh has no asset links yet, and a debug key is not in them). The domain was then allowed with `pm set-app-links-user-selection`, which stands in for verification, and links were sent with `am start -a VIEW -c BROWSABLE -d <link>` and no package: - A. App not running, link with an offer named "Lane QA PC": the app started cold on `https://app.ovis.sh/s/0123…cdef/` (read from the WebView's DevTools), and the connect screen later listed it as "Lane QA PC (app.ovis.sh)". - B. That PC open, link whose offer names another PC: the app went to the connect screen with the link in the address field and "This pairing link is damaged or names another PC" (screenshot below). - C. Same link sent with `FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY` (as Recents does): not opened, the app stayed on the PC it had open. - D. Control for C, the link without the flag: opened that second PC with its offer. - After the review round, on the rebuilt APK: G. a file link (`#read=%2Fhome%2Fa.md&machine=local`) of the saved PC, sent from the connect screen, opened that PC at `…/#read=%2Fhome%2Fa.md&machine=local`. H. a pane link of a PC the app does not have, sent while G was open, left G's page as it was. A and B behaved as before. - `bun run check fast`: all steps ok on 8ee5bae, the review fixes with origin/main merged in (unit: 12621 pass, 0 fail, 50 skip). - Skipped: browser regressions (no client component changed), a real pairing through a live relay (the offers above name no running PC; pairing itself is unchanged and already covered for scanned links), iOS (not changed). | B: running app, bad link (the PC from A listed under its offer's name) | A: cold start, the app opened the PC's page on app.ovis.sh | |---|---| |  |  | ## Review round (omo + Codex Terra xhigh at 73d8e8a) - Fixed, HIGH (Codex): a PC's page could call `takeLink` and race the connect screen for another PC's pairing link. `takeLink` now answers only in an activity that shows no PC. - Fixed, MEDIUM (omo, Codex): a file or pane link of the hosted shell was taken and failed on the connect screen as "not a PC", closing the open PC. Such a view now opens a saved PC at that view, and is otherwise left alone. - Fixed, MEDIUM (Codex): a malformed `/s/...` link closed the open page before the connect screen rejected it. Only `/s/<32 hex>/` links are taken now. A pairing link with a damaged offer still goes to the connect screen and shows its error, as a scanned one does. - Fixed, LOW (omo): `:443` is accepted like no port. - Not changed, LOW (omo): the Caddy mirror sends no JSON type for `/.well-known/*`; only app.ovis.sh is in the app's link, the mirror is never asked. - Not changed, LOW (omo): another app on the phone can send the app a pairing link, as it can open one in the browser today; the pairing then asks for what the offer would ask for in the browser.
Change
Part 3 of #2599. The owner said this could be fixed now. #2599 stays open for its other two parts: the app link and naming relay PCs.
On a phone paired through the Ovis relay, the hosted shell's page address held PC data in its query, so every load sent it to
app.ovis.sh. That covered a file opened in a tab of its own or as a raw file (?read=<path>&machine=), the app's own address after a reload (?ws=<id>-<workspace name>&pane=&file=<path>), an alert's cold start (?machine=&pane=), and Reconnect. A reproduction onorigin/mainwithrelay-shell-browser-qa.tsrecorded 4 such requests (before/host-requests.txt).src/lib/pageQuery.ts: in the hosted shell only, the page's query rides in the URL fragment (/s/<id>/#read=…,#ws=…&pane=…&file=…), which a browser never sends. This follows how the pairing#offer=already works. A PC's own server keeps the query exactly as before.readerHref,main.tsxreader detection,FileReaderBack,useAddressBar,Appinitial link,useSelection,PaneTerminalReconnect (a fragment change loads nothing, so the shell reloads explicitly), andpublic/sw.js(an alert's cold start uses#in a shell scope;isAppWindowreads#read=).lib/relay/boot.ts: an address from an older build that still has the query (a saved link, or a history entry Back lands on) has its query moved into the fragment. A pasted#offer=is never read as page state.docs/relay.md(Trust model) now says what the host sees. An old query-bearing link still reaches the host with its one load (the request, plus the Referer of the files fetched before the app starts). File and media bytes are answered in the phone by the shell's service worker (/s/<id>/~/api/…).Privacy policy: after #2600 merged,
origin/mainwas merged in (791c614). Its caveat thatapp.ovis.shsees a file path is gone fromovis-site/privacy(en, ko) andapp/store/{android,ios}.md, and the merge conflict indocs/relay.mdkept this branch's text.Design precedent: the pairing link's
#offer=fragment in this same shell, and the general practice of keeping client-only state in the fragment (as Paseo's hosted app does for its connection offer).Screenshots
These come from an isolated test session (
createServeron loopback, a real Bun relay,dist-shellserved as Pages serves it) in Codex dark. The black bar at the bottom is a QA overlay, not app UI: it shows the page address and how many requests to the shell host named the file (before 2, after 0 at every width).The host request logs are on the same evidence branch:
before/host-requests.txt(4 leaked) andafter/host-requests.txt(0 of 29, Referer included).Validation
bun run check fast: all checks ok, before and after merging main with docs(site): name the Ovis relay and app.ovis.sh in the privacy policy #2600.New and changed unit tests:
pageQuery,fileReader,relay/resources,relay/shellState,pwa-notification,pwa. Six of them failed onorigin/mainbefore the fix and pass after it.bun scripts/relay-shell-browser-qa.ts(full run, isolated herdr test session). Its new block opens a PC file in the app, in its own tab, as a raw tab and after a followed link, reloads, then asserts that no host request or Referer names the file, folder, workspace or pane. It failed on cleanorigin/main(4 leaked) and passes on this branch, along with the rest of the script.Reviews: Codex Terra (
gpt-6.1-terra, xhigh) and an omo code review. Resolved findings:#auth=or#offer=.#offer=read as page state.sw.jsandpageSearchread order.Documented rather than changed: an old query link's single load, and a service-worker resource URL copied out of the app.
Skipped:
bun run check fullandrelay-media-browser-qa.ts(CI's browser lane runs them; the only change to relay-media is passing"relay"toreaderHref).