Skip to content

fix(relay): the press's fallback to the join stays on the sheet it was made on - #4540

Merged
devswha merged 1 commit into
mainfrom
fix/new-pc-press-join
Nov 23, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/new-pc-press-join

Conversation

@devswha

@devswha devswha commented Nov 23, 2026

Copy link
Copy Markdown
Owner

What was wrong

This is a device recheck of main at 6b2d123 (#4531 merged as cf0b36f), on a fresh account where the phone's key is not on the PC's list. On the sheet of a PC new in the account, Ask to join (참여 요청) tried the account sign-in, and the PC answered auth_failed as expected. Then the page went to the hosted root and showed My PCs, and the join request was never sent: no Allow card on the PC, and GET /api/relay/joins stayed empty. So nobody could open such a PC from a phone.

Reproduced in a real browser first

The new scripts/relay-new-pc-press-regression.ts uses:

  • the hosted shell build (dist-shell/, routed in for https://app.ovis.sh);
  • a real PC (createServer) behind a local Bun relay, with the page's relay sockets bridged to it;
  • the in-memory account service, with Step 2 on.

Each case has an account of its own, whose PC was added in one press, so it is inside new_until. The device signs in through the provider flow, which registers its key, either as not eligible (the PC has no row for it) or as eligible. It reaches the PC's sheet one of three ways: from the PC's address, from its row in My PCs, or from the sign-in's launch. It runs at 390 (touch) and at 1440.

Before the press, each case checks that the sheet waits and that nothing reached the PC: no join, and no relay connection once the sheet is up. After the press:

  • Not eligible: the join must reach the PC's own window (GET /api/relay/joins), and the page must show the number beside the PC's Allow, still on /s/<id>/.
  • Eligible: the PC must open through the account, with no join.

On main's shell, all three not-eligible cases at 390 fail; every other case passes, including the same three at 1440. After the press, the URL went /s/<id>/ → /s/<id>/#offer=… (the fallback's link) → /s/<id>/ → https://app.ovis.sh/. The page ended on the empty front page, and no join reached the PC. An instrumented run logged a popstate with state=null on that fragment change, before its hashchange.

Cause (lines on main)

  1. src/lib/relay/shell.tsx:700: when the pressed account sign-in is refused, the "pair" step of failed() asks for the join through joinPc(...). On the PC's own page, that does replace(link.pathname + link.hash) (shell.tsx:648), which is a fragment navigation, location.replace("/s/<id>/#offer=…").
  2. A fragment navigation fires popstate (state null) before hashchange.
  3. On a phone or touch screen (BACK_QUERY), the join sheet holds a history entry through usePhoneSheetBack (src/components/AddPcSheet.tsx:99). The popstate listener in src/lib/sheetHistory.ts (:528) takes any popstate off that entry for Back, and calls the sheet's onBack (:469).
  4. The sheet's close (AddPcSheet.tsx:95) then runs onCancel and onClose. onClose is the shell's onBack (src/components/RelayShell.tsx:389), which is toFront (shell.tsx:406-415): cancelAttempt(); navigate("/"), a full load of the hosted root with the front page chosen. The hashchange handler that would have sent the join (arrived() taking the keepConfirmedPc mark) ran on a page that was already leaving.

At 1440 without touch the sheet holds no history entry, so the same flow worked there. The unit tests of #4531 stood in for the browser with recorded navigations and a same-document fragment step, without the sheet's component or its history entry, so they never saw step 3.

The device pass also reported plain Chrome. If that was a desktop-width window, it is a second failure this script does not reproduce: at 1440 every case passes on main.

Fix

In failed()'s "pair" step (src/lib/relay/shell.tsx:701), a pressed attempt whose sheet is the one up (entry.offer and sheetJoin both name that PC) now sends its join from that sheet with no navigation: show(confirmOf(entry.offer)); pair(). The keepConfirmedPc mark is no longer used for it. Any other fallback (a load's refused account sign-in, where no sheet is up) still goes through joinPc, as before.

The rules of #4531 still hold:

  • Nothing opens without a press: no change here; the script checks that nothing reaches the PC before the press in every case.
  • One fallback per press: a single pair(); the removed-device test still sees exactly one account sign-in and one join over 30 minutes.
  • A removed device gets only the join: the same join, judged by the PC; covered by the same test.
  • A PC that is not new keeps today's handling: that path is unchanged and still pinned by its test.

Tests

  • Unit (src/lib/relay/shellAccountOpen.test.tsx): the test page now has a phoneSheet model. As the phone's sheet does, a link the page takes while the join sheet is up runs the sheet's Cancel and Back. These cases now run under that model and expect the join with no navigation:

    • the four refusal cases (not_listed twice, admission, auth_failed, and a PC without the way in);
    • the removed-device / once-per-press case;
    • the wire auth_failed case.

    All 6 fail against main's shell.tsx and pass with the fix.

  • Browser: scripts/relay-new-pc-press-regression.ts, added to scripts/ci-browser.sh after relay-second-device-join-regression.ts. All 12 cases pass with the fix; on main the three not-eligible cases at 390 fail.

  • relay-second-device-join-regression.ts and relay-shell-browser-qa.ts pass.

Validation

  • dori heavy newpc2 -- bun run check fast: green (typecheck, build, 24439 unit tests).
  • In the CI runner image (herdr-ci-runner:local, through dori heavy, from a git bundle of this branch, bun run build:shell then bun run check run --build): relay-new-pc-press-regression.ts (12 of 12), relay-second-device-join-regression.ts and relay-shell-browser-qa.ts all pass.
  • Skipped: the integration suite and native Windows, since no server, shared or Windows code changed.

Known limits

  • sheetHistory.ts takes any popstate off a sheet's entry for Back, including a fragment change the page makes itself. This PR keeps the shell from making one while the join sheet is up, rather than changing how sheets read history. Any other place that changes the fragment under an open phone sheet would close that sheet the same way.
  • The PC asks the account service about a join at most once in 10 seconds (server/account/mailbox.ts, admitted). A second device asking the same PC within that time is refused (pair-unavailable) and asks again with Try again. That was so before, and the script gives each case a PC of its own.

🤖 Generated with Claude Code

…s made on

On a phone, Ask to join on a PC new in the account whose account sign-in the
PC refused (auth_failed for a key it does not list, admission, not_listed, a
PC without the way in) ended on the front page with no join sent. The
fallback asked for the join by a link to the same sheet (joinPc's
location.replace with the offer fragment). That fragment change fires
popstate, and on a phone or touch screen the sheet holds a history entry
(sheetHistory.ts), which takes any popstate off it for Back: AddPcSheet's
close ran Cancel and the shell's onBack, toFront, which went to "/".

The fallback now sends the join from the sheet the press was made on, with no
navigation, so nothing a fragment change triggers can end it; a fallback with
no such sheet up still goes through joinPc as before. A browser regression
with a real PC, the hosted shell and the account service drives it from the
PC's address, its row in My PCs and a launch, at 390 and 1440, for a device
the PC does not list (the join reaches the PC's own window) and one it does
(the press opens the PC through the account, with no join).

Co-Authored-By: Claude Opus <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • On phones, choosing Ask to join for a PC added to your account within the last 24 hours now continues to request access from that PC if account-based access fails.
    • The join confirmation stays on the same PC page, so you can see the request number without being sent back to My PCs.

When account-based opening fails after a press on a matching phone join sheet, the shell now restores confirmation and starts pairing on that sheet. Unit tests cover refusal and removed-device cases. A browser regression script checks eligibility, screen size, and entry route combinations and runs in browser CI.

Changes: Phone join-sheet fallback

Layer / File(s) Summary
Keep fallback on the open join sheet
src/lib/relay/shell.tsx, src/lib/relay/shellAccountOpen.test.tsx, changelog.d/new-pc-press-join-on-phone.md
A failed matching account-open attempt restores confirmation and calls pair() on the existing sheet. Tests cover refusal and removed-device flows without navigating away. The changelog describes the phone behavior.
Verify the fallback in browser CI
scripts/relay-new-pc-press-regression.ts, scripts/ci-browser.sh
The browser regression checks eligible and ineligible device keys across phone and desktop sizes and address, My PCs, and launch routes. The browser CI runner now executes the script.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

  • devswha/ovis#4231: Adds an Ask to join flow on a PC’s own page and changes offer handling in a related join path.
Merge Risk: Minimal · up to d11a3

On phones, Ask to join for a newly added PC now sends the join request from the open sheet instead of navigating away to the front page. The change is small and well covered by unit and browser regression tests, and I found no merge-blocking risk. One known limit remains: other fragment changes while a phone sheet is open can still close it.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the fallback from a pressed attempt now stays on the join sheet it was made on, which matches the shell.tsx fix and the phone-sheet navigation bug described in the sum…
Description check Passed The description follows the template. The Change section describes the problem (the phone sheet closed on a fragment navigation, sending the page to the hosted root), its cause with file references, a…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the fallback from a pressed attempt now stays on the join sheet it was made on, which matches the shell.tsx fix and the phone-sheet navigation bug described in the summary and objectives. It is specific and uses a conventional fix(relay) prefix.

Full details: Description check

Explanation

The description follows the template. The Change section describes the problem (the phone sheet closed on a fragment navigation, sending the page to the hosted root), its cause with file references, and the resulting behavior with the fix. The Validation section lists the commands run (bun run check fast, the browser regression, and the unit tests), their results, and the skipped integration suite and Windows checks. It also covers the contract-test question, since no HTTP/WS contract changed, and notes the changelog entry. Minor gap: the Change section does not link an issue, though the template asks for one only for features.

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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 25d8646 and d11a311.

Files selected for processing: 5

  • changelog.d/new-pc-press-join-on-phone.md
  • scripts/ci-browser.sh
  • scripts/relay-new-pc-press-regression.ts
  • src/lib/relay/shell.tsx
  • src/lib/relay/shellAccountOpen.test.tsx

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 1 remain after this review.

@devswha
devswha merged commit 8484121 into main Nov 23, 2026
15 checks passed
@devswha

devswha commented Nov 23, 2026

Copy link
Copy Markdown
Owner Author

Merged through pr-merge at head d11a311c0. 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 reviewed this head.

Follow-up to #4531, found by the device recheck (r14b): on a phone, the press's fallback never sent the join. The fallback changed the page's fragment, the phone sheet's history entry took that popstate for Back, the sheet closed and the page went to the front page before the join could be sent, so on an account whose devices the PC does not list yet nobody could open a new PC. Now, while the press's own sheet is up, the fallback sends the join from that sheet with no navigation. Every rule of #4531 holds (nothing opens without a press; one fallback per press; a removed device gets only the join). A new browser script reproduces it at phone width (three entries, eligible and not eligible keys, 390 and 1440) and runs in CI. Short independent review by an Opus reviewer agent (no Codex review: its usage limit lasts until 2026-11-28): no HIGH or MEDIUM; the in-sheet join cannot run for another PC or without a press. Not run on a device; the next preview's recheck covers it.

@devswha
devswha deleted the fix/new-pc-press-join branch November 23, 2026 22:21
devswha added a commit that referenced this pull request Nov 24, 2026
…ed wait (#4547)

## What

`scripts/conventions.test.ts` ("waits marked fixed") fails on main:
#4540 added
`scripts/relay-new-pc-press-regression.ts` with one marked fixed wait,
and #4537 added the ratchet
that allows none in a new file. The two merged side by side, so every PR
that includes main now
fails Fast checks.

The quiet period before the press ("nothing reaches the PC until the
sheet is pressed") is now a
loop bounded by a deadline that fails on the first join or relay
connection, instead of one
1.5 s wait followed by a single check. Same coverage, and a regression
is reported sooner.

## Validation

- `bun test --timeout 60000 scripts/conventions.test.ts`: 40 pass (it
failed on main with
`scripts/relay-new-pc-press-regression.ts: 1 marked fixed waits,
baseline 0`).
- Not run locally: `bun run check fast` and the browser script itself
(CI's browser job runs it).

Test-only change; no review requested.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5.2 <[email protected]>
devswha added a commit that referenced this pull request Nov 24, 2026
…wo unused modules (#4548)

## What

Test cleanup, bundle B3 of the test-suite plan: tests that leaned on
prose and docs, and two modules nothing uses.

- **R1** `scripts/install-ovis-command.test.ts`: drop "does not promise
that another ovis is never hidden". It only checked that CHANGELOG lacks
a phrase and that the guide has a sentence; no code reads either. The
guide's Uninstall command stays covered by running it (the test just
above).
- **R2** `src/lib/markdownHtml.test.ts`: the parser test read the real
README, so a README edit (logo path, width, links) could break a parser
test. It now parses a README-shaped HTML header written in the test
(centered logo with a width, `<h1>`, badges, a language row with a `.md`
file link, a website link). Every parser assertion stays.
- **R3** `src/lib/textPreview.test.ts`: the "ordinary document of the
load limit's size stays well under the Preview limit" check read the
head of the real CHANGELOG, which changes every release. It now builds a
changelog of the same size (release headings, wrapped list items with
code and links). The first check (short list items past the limit) is
unchanged.
- **R5** remove `src/lib/koreanParticle.ts` (and its test) and
`src/lib/account/deviceKey.ts`: nothing imports them
(`registerSigningBytes` lives in `shared/account-records.ts`, which
`src/lib/account/service.ts` uses). `src/lib/account/deviceKey.test.ts`
stays: it tests the account service path, not that file. The stale
`koreanParticle.test.ts` entry leaves `scripts/ci-test-timings.json`.

No production behaviour or UI changes.

## Evidence: the rewritten tests still fail when the parser breaks

Each mutation applied to the production file, the test file run, then
the file restored byte for byte (`git status` clean afterwards).

| Mutation | Result |
|---|---|
| M1 `shared/markdownHtml.ts:129` drops the image `width` | `reads a
README's HTML header as centered markdown, never as tag text` fails (1
fail, 5 pass) |
| M2 `shared/markdownHtml.ts:86` reads `.md` links as plain text | the
README header test and `links only to safe addresses and files` fail (2
fail) |
| M3 `src/lib/textPreview.ts` counts one element per character of text |
`puts a file of the load limit's short list items past what a Preview
draws` fails on the generated changelog (1 fail) |

## Validation

- `bun test src/lib/markdownHtml.test.ts src/lib/textPreview.test.ts
src/lib/account/deviceKey.test.ts scripts/install-ovis-command.test.ts
scripts/ci-test-timings.test.ts`: 73 pass, 0 fail.
- `bun run check fast` (P620, 256 s): workflow syntax, generated
types/themes, typecheck, build ok; unit 24,884 pass, 160 skip, **1
fail**: `scripts/conventions.test.ts` "waits marked fixed" on
`scripts/relay-new-pc-press-regression.ts:180`. That failure is on
`origin/main` itself (1d71a71, #4537's new ratchet met #4540's marked
wait) and is fixed by #4547; this PR does not touch that file. Once
#4547 lands this branch takes main in.
- Skipped: browser regressions (no UI or component change) and the
integration lane (no server change).
devswha added a commit that referenced this pull request Nov 24, 2026
… and answer its approvals as data (#4560)

## What

A Codex that Ovis starts in a herdr-core pane now runs on **its own app
server, with the real Codex TUI on it**, and Ovis answers its approvals
**as data** instead of keys read off the screen.

- **Launch** (`server/approvals/codex.ts`, `server/agent-launch.ts`,
herdr-core adapter `program`): Ovis writes a launcher into a fresh
`mkdtemp` folder (0700). The pane's shell runs it: `codex app-server
--listen unix://<folder>/codex.sock`, then the real TUI `codex --remote
unix://...`. No other account can reach the socket (0600, or on 0.171 a
link Ovis checks into `/tmp/codex-daemon-<uid>/<sha256(path)>`, a 0700
folder), so no token is needed. The launcher stops the server and
removes its folder when the TUI ends or the pane hangs up. The user's
Codex settings and login are used as they are: nothing is written to
them, only launch arguments.
- **Approvals** (`server/approvals/hub.ts` `hold`): Ovis subscribes to
each thread as it runs (`thread/resume`, no overrides; a request already
waiting is replayed). A command, file change or permission approval
becomes the card of the TUI's own dialog, with the command as the shell
runs it (`/bin/bash -lc` taken off), the folder it runs in, a remote
environment and any extra permissions. Yes sends `accept`, No sends what
the TUI's No sends (`cancel`). Whoever answers first wins:
`serverRequest/resolved` releases the card, and a later card answer is
refused. Options other than Yes and No (don't ask again, a grant for the
session or with strict auto review) go to the TUI's dialog as keys. MCP
elicitation stays the TUI's (it draws it as a form of its own, with no
dialog to bind a card to).
- **Turn end** (`server/core/status.ts`): how a turn ended (answered or
failed) comes from `turn/completed` instead of the rollout file.
- **Fallbacks**: a Codex version not measured (only 0.169.x–0.171.x),
arguments the launcher does not know, Windows, another machine of the
core, herdr (not herdr-core), a server that does not come up within 8 s
(the launcher then starts plain `codex`), or a connection that fails:
Codex runs as before, with the screen reader. That is why the screen
reader's approval part stays.

## Card change (do not merge before the maintainer has seen it)

The card's body now comes from Codex's request instead of the screen:
the reason, the folder, then the exact command. Before, a long command
showed the pane's own line breaks and the `Environment:` / `Reason:` /
`$` lines. Desktop 1280 and phone 390, light, Korean:

| | before (screen) | after (data) |
|---|---|---|
| short, desktop |
![](https://raw.githubusercontent.com/devswha/ovis/qa-evidence/codex-app-server-tui/before-short-desktop.png)
|
![](https://raw.githubusercontent.com/devswha/ovis/qa-evidence/codex-app-server-tui/after-short-desktop.png)
|
| long, desktop |
![](https://raw.githubusercontent.com/devswha/ovis/qa-evidence/codex-app-server-tui/before-long-desktop.png)
|
![](https://raw.githubusercontent.com/devswha/ovis/qa-evidence/codex-app-server-tui/after-long-desktop.png)
|
| short, phone |
![](https://raw.githubusercontent.com/devswha/ovis/qa-evidence/codex-app-server-tui/before-short-phone.png)
|
![](https://raw.githubusercontent.com/devswha/ovis/qa-evidence/codex-app-server-tui/after-short-phone.png)
|
| long, phone |
![](https://raw.githubusercontent.com/devswha/ovis/qa-evidence/codex-app-server-tui/before-long-phone.png)
|
![](https://raw.githubusercontent.com/devswha/ovis/qa-evidence/codex-app-server-tui/after-long-phone.png)
|

Heredoc and quotes + Korean, after: `after-multi-*.png`,
`after-quote-*.png` on the `qa-evidence/codex-app-server-tui` branch.

## Validation

- Real Codex 0.171.0 through Ovis's own code (createServer, agentLaunch,
`GET /api/pane/prompt`, `POST /api/pane/prompt/answer`) on an isolated
herdr-core, model gpt-6.2-sol-fast. The executed command was taken from
strace's `execve` of the app server:
- allow 4/4 (short, longer than the pane, a heredoc over lines, quotes
and Korean): card command == executed command, character for character;
ran once; the TUI's dialog closed.
  - deny 3/3: nothing ran.
- TUI answers first 3/3: ran once; Ovis's late answer to the same card
was refused (409).
  - Results: `e2e-results.jsonl` on the evidence branch.
- Recorded fixtures (`server/fixtures/codex-app-server-*.json`): card
command == strace execve for the four commands, and each binds to its
own TUI dialog and no other.
- `bun run check fast` on the rebased head: typecheck, build and unit
green except `scripts/conventions.test.ts`, which fails on origin/main
itself (a marked fixed wait in
`scripts/relay-new-pc-press-regression.ts` from #4540, checked on a
clean origin/main checkout). The commit before the rebase passed `check
fast` fully.
- Reviews: a Codex adversarial review (gpt-6.2-sol-fast, xhigh) and a
gate review (review-work). Their findings were fixed in the two
`fix(codex)` commits:
- the card shows the folder, environment, extra permissions and a move's
destination;
- a dialog that hides its command binds only to the one request of its
kind;
  - only the one-turn grant is answered from a card;
  - backslash-newline is parsed as the shell does;
  - the launcher waits less than the start does;
- no launcher is written in a folder another account may rename entries
in.
- Not run: Windows, macOS. Remaining follow-up (MEDIUM, not fixed here):
if the terminal's No and a card's Yes cross, the browser gets `ok`
before Ovis reads Codex's `resolved`; Codex ignores the late answer, so
nothing runs.
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.

1 participant